<?php

it('documents period invoice states and authenticated attachment content', function (): void {
    $openApiFiles = [app_path('openapi.yaml')];
    $rootOpenApiFile = dirname(app_path(), 3) . '/openapi.yaml';

    if (is_file($rootOpenApiFile)) {
        $openApiFiles[] = $rootOpenApiFile;
    }

    foreach ($openApiFiles as $openApiFile) {
        expect($openApiFile)->toBeFile();
        $content = file_get_contents($openApiFile);
        expect($content)->not->toBeFalse();
        $content = (string)$content;

        expect($content)->toContain('/orders/attachments/content:');
        expect($content)->toContain('OrderAttachmentDownloadLinkResponse:');
        expect($content)->toContain('InvoicingPeriodResponseEnvelope:');
        expect($content)->toContain('InvoicingPeriodInvoiceCollection:');
        expect($content)->toContain('enum: [open, closed, economic_draft, economic_booked]');
        expect($content)->toContain('available_pdf_type:');
        expect($content)->toContain('enum: [draft, booked, none]');
    }
});
