<?php

declare(strict_types=1);

use Tests\Support\TestLaneManifest;

it('wires the dev push workflow to the confidence lane and publishes the lane-owned JUnit artifact bundle', function (): void {
    $workflowProfile = TestLaneManifest::workflowProfile('main-confidence');
    $workflowContents = (string) file_get_contents(repo_path($workflowProfile['filePath']));

    expect(file_exists(repo_path($workflowProfile['filePath'])))->toBeTrue()
        ->and($workflowProfile['triggerClass'])->toBe('mainline-push')
        ->and($workflowProfile['branchFilters'])->toBe(['dev'])
        ->and($workflowContents)->toContain('push:')
        ->and($workflowContents)->toContain('- dev')
        ->and($workflowContents)->toContain('permissions:')
        ->and($workflowContents)->toContain('actions: read')
        ->and($workflowContents)->toContain('contents: read')
        ->and($workflowContents)->toContain('./scripts/platform-test-lane confidence --workflow-id=main-confidence --trigger-class=mainline-push')
        ->and($workflowContents)->toContain('TENANTATLAS_GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}')
        ->and($workflowContents)->toContain('./scripts/platform-test-report confidence --workflow-id=main-confidence --trigger-class=mainline-push --fetch-latest-history')
        ->and($workflowContents)->toContain('./scripts/platform-test-artifacts confidence .gitea-artifacts/main-confidence --workflow-id=main-confidence --trigger-class=mainline-push')
        ->and($workflowContents)->toContain('name: confidence-artifacts')
        ->and($workflowContents)->not->toContain('test:junit', './scripts/platform-test-lane fast-feedback', './scripts/platform-test-lane heavy-governance');
});
