import fs from 'node:fs'; import path from 'node:path'; import { App } from '@inertiajs/react'; import { renderToStaticMarkup } from 'react-dom/server'; import { expect, test } from 'vitest'; import { ActionBar, FormErrors, PageTitle, Panel, TableViewport, } from '@/components/procurement'; import RequisitionForm from '@/pages/requisitions/form'; import SupplierEdit from '@/pages/suppliers/edit'; import ProcurementReports from '@/pages/reports/procurement'; import type { Supplier } from '@/types/procurement'; function render( component: Parameters[0]['initialComponent'], props: object, ) { const html = renderToStaticMarkup( , ); if (process.env.SGC_PRESENTATION_PREVIEW) { const root = path.resolve(process.env.SGC_PRESENTATION_PREVIEW); const allowed = path.resolve('storage/framework/testing') + path.sep; if (!root.startsWith(allowed)) throw Error('Private preview path required'); fs.mkdirSync(root, { recursive: true }); const name = component === RequisitionForm ? 'requisition' : component === SupplierEdit ? 'supplier' : 'report'; fs.writeFileSync( path.join(root, name + '.html'), 'SGC - ' + name + ' - dados sinteticos' + html + '', ); } return html; } test('shared panels have distinct accessible titles and preserve their own content', () => { const html = renderToStaticMarkup( <>

Versao original

, ); const headings = [...html.matchAll(/

match[1], ); expect(new Set(headings).size).toBe(2); for (const id of headings) expect(html).toContain(`aria-labelledby="${id}"`); expect(html).toContain('name="reference"'); expect(html).toContain('Versao original'); }); test('shared actions preserve submission and disabled semantics without adding commands', () => { const html = renderToStaticMarkup(
Cancelar
, ); expect(html).toContain('role="group"'); expect(html).toContain('href="/requisicoes"'); expect(html).toContain('type="submit" disabled'); expect(html.match(/