Files
compras/tests/frontend/candidate-portal.test.tsx
T
nala c6373365bf
tests / ci (push) Canceled after 0s
commit9
2026-10-30 20:02:30 +02:00

73 lines
2.5 KiB
TypeScript

import { App } from '@inertiajs/react';
import type { Page } from '@inertiajs/core';
import { renderToString } from 'react-dom/server';
import { expect, test } from 'vitest';
import Entry from '@/pages/candidate/entry';
import Profile from '@/pages/candidate/profile';
const page = {
component: 'candidate/entry',
url: '/candidaturas/1',
version: 'candidate',
props: { errors: {} },
clearHistory: false,
encryptHistory: true,
} satisfies Page;
test.each([true, false])(
'registration availability (%s) preserves existing login and does not promise submission',
(registration_open) => {
const initialPage = {
...page,
props: {
...page.props,
company: { id: 1, name: 'Empresa fictícia' },
portal: {
version: 2,
registration_open,
notice: 'Aviso fictício da empresa.',
},
},
};
const html = renderToString(
<App initialPage={initialPage} initialComponent={Entry} />,
);
expect(html).toContain('Entrar na minha área');
expect(html.includes('Criar a minha conta')).toBe(registration_open);
expect(html).toContain('Criar um perfil não constitui candidatura');
expect(html).not.toContain('/dashboard');
},
);
test('candidate profile renders geography and retained version without internal evaluation controls', () => {
const initialPage = {
...page,
component: 'candidate/profile',
props: {
...page.props,
companyId: 1,
email: 'test@example.invalid',
profile: {
version: 3,
data: {
name: 'Pessoa fictícia',
phone: '',
summary: 'Perfil fictício.',
availability: {
province: 'Província fictícia',
district: 'Distrito fictício',
locality: 'Localidade fictícia',
},
},
},
},
};
const html = renderToString(
<App initialPage={initialPage} initialComponent={Profile} />,
);
expect(html).toContain('value="Província fictícia"');
expect(html).toContain('value="Distrito fictício"');
expect(html).toContain('value="Localidade fictícia"');
expect(html).toContain('Guardar nova versão do perfil');
expect(html).not.toContain('Aprovar');
expect(html).not.toContain('/pessoas');
});