import { App } from '@inertiajs/react';
import type { Page } from '@inertiajs/core';
import { renderToString } from 'react-dom/server';
import { expect, test } from 'vitest';
import Registry from '@/pages/people/registry';
import PeopleShow from '@/pages/people/show';
import { PeopleRegistryChoice } from '@/components/people-registry-choice';
const page = {
component: 'people/registry',
url: '/pessoas/cadastro',
version: 'registry',
props: { errors: {} },
clearHistory: false,
encryptHistory: true,
} satisfies Page;
const person = {
id: 7,
name: 'Pessoa do cadastro',
reference: 'CAD-7',
profile_summary: 'Perfil profissional reutilizável.',
active: true,
version: 2,
canEdit: false,
};
test.each([true, false])(
'registry respects directory editing authority (%s) without linking to restricted processes',
(canCreate) => {
const initialPage = {
...page,
props: {
...page.props,
ready: true,
canCreate,
records: {
data: [person],
total: 1,
prev_page_url: null,
next_page_url: null,
},
filters: {},
},
};
const html = renderToString(
,
);
expect(html).toContain('Pessoa do cadastro');
expect(html).toContain('Perfil profissional reutilizável.');
expect(html.includes('Registar pessoa')).toBe(canCreate);
expect(html).not.toContain('Guardar nova versão');
expect(html).not.toContain('/pessoas/7');
},
);
test('process registry selection identifies source version without repeating an entire registration form', () => {
const html = renderToString(
{}}
/>,
);
expect(html).toContain('CAD-7');
expect(html.replace(//g, '')).toContain('v2');
expect(html).toContain('Pesquisar cadastro');
expect(html).toContain('A candidatura conserva a versão');
expect(html).not.toContain('