import { App } from '@inertiajs/react'; import { renderToStaticMarkup } from 'react-dom/server'; import { expect, test } from 'vitest'; import Metadata from '@/pages/audit/metadata'; function render(allowed: boolean) { return renderToStaticMarkup( %_', action: '0', actor_id: 7, from: '2026-11-01', to: '2026-11-01', page: 2, }, requestContext: allowed ? { number: 'QA%_', href: '/requisicoes/7#requisition-history', } : null, events: { data: [ { id: 4, action: '0', created_at: '2026-11-01T12:00:00Z', user_id: 7, }, ], total: 131, current_page: 2, last_page: 6, prev_page_url: '/auditoria/eventos?request_reference=QA&page=1', next_page_url: null, }, }, }} />, ); } test('audit investigation carries applied criteria into the whole-scope CSV and escapes the reference', () => { const html = render(false); expect(html).toContain('Referência exacta da requisição'); expect(html).toContain('QA<REQ>%_'); expect(html).toContain( '/auditoria/eventos.csv?request_reference=QA%3CREQ%3E%25_&action=0&actor_id=7&from=2026-11-01&to=2026-11-01', ); expect(html).not.toContain('/requisicoes/7'); expect(html).not.toContain('PRIVATE-'); }); test('only an independently authorised native process locator is rendered', () => { const html = render(true); expect(html).toContain('href="/requisicoes/7#requisition-history"'); expect(html).toContain( 'Consultar o processo e o histórico de QA<REQ>%_', ); });