<?php

it('registers workflow lifecycle endpoints for the n8n module', function (): void {
    $routeFile = app_path('routes/moduleN8nRoute.php');
    $content = file_get_contents($routeFile);

    expect($content)->not->toBeFalse();
    expect($content)->toContain('/modules/n8n/workflows');
    expect($content)->toContain('/modules/n8n/workflows/{id}');
    expect($content)->toContain('/modules/n8n/workflows/{id}/publish');
    expect($content)->toContain('/modules/n8n/workflows/{id}/deactivate');
    expect($content)->toContain("requirePermission('modules_n8n_workflows_view')");
    expect($content)->toContain("requirePermission('modules_n8n_workflows_manage')");
});

it('registers execution and webhook trigger endpoints for the n8n module', function (): void {
    $routeFile = app_path('routes/moduleN8nRoute.php');
    $content = file_get_contents($routeFile);

    expect($content)->not->toBeFalse();
    expect($content)->toContain('/modules/n8n/webhooks/trigger');
    expect($content)->toContain('/modules/n8n/executions');
    expect($content)->toContain('/modules/n8n/executions/{id}/retry');
    expect($content)->toContain('/modules/n8n/executions/{id}/stop');
    expect($content)->toContain("requirePermission('modules_n8n_workflows_run')");
    expect($content)->toContain("requirePermission('modules_n8n_executions_view')");
});
