Files
planflow/tests/e2e/navigation.spec.ts
T
Claude 8a314991d3 WP-03: employee records and contracts on real data
Replaces the demo module behind the team directory and the employee
record with scoped queries, and adds contracts, amendments, work
permits and the forfait-jours fields.

Writing the end-to-end test exposed a modelling error worth naming:
first and last names lived only on User, so an employee without an
application account had no name at all — the directory rendered
"— Salarié E0007". Most sales staff never sign in, and the personnel
register requires their name, so the name belongs to the record, not
to the login. Moved to EmployeeProfile with a data migration that
carries the existing names down from User.

Contract rules are pure functions tested at the boundaries. The case
that matters is an open-ended contract: a CDI with no end date overlaps
every later period, which a naive comparison of two date pairs misses,
and two overlapping active contracts would count one employee twice in
payroll. The check runs inside the transaction, not only in the form.

Forfait jours is refused without a written individual agreement and a
dated employee consent: without them the arrangement is unenforceable,
and enabling it would also switch off every weekly-duration control.

Salary and bank details are not merely hidden when the capability is
missing — they are never loaded. A field absent from the response
cannot leak through HTML, a log or an error message.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cr9dkEHwbDgkWPnyGj1Rjv
2026-08-07 23:17:16 +00:00

63 lines
2.4 KiB
TypeScript

import { expect, test } from '@playwright/test';
test('les six écrans se chargent et affichent leur contenu', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'Aperçu RH' })).toBeVisible();
await page.getByRole('link', { name: 'Plannings' }).click();
await expect(
page.getByRole('heading', { name: /Planning · semaine 33/ }),
).toBeVisible();
// La grille doit porter des créneaux, pas seulement son ossature.
await expect(page.getByText('Congés payés').first()).toBeVisible();
await page.getByRole('link', { name: 'Vue jour' }).click();
await expect(
page.getByRole('heading', { name: /Planning · mercredi 12 août/ }),
).toBeVisible();
await page.getByRole('link', { name: 'Équipe', exact: true }).click();
await expect(page.getByRole('heading', { name: 'Équipe' })).toBeVisible();
// La fiche est atteinte depuis l'annuaire réel, plus depuis un lien codé
// en dur : l'identifiant est celui de la base.
await page.getByRole('link', { name: /Camille Ferrand/ }).first().click();
await expect(
page.getByRole('heading', { name: /Camille Ferrand/ }),
).toBeVisible();
await page.getByRole('link', { name: 'Congés' }).click();
await expect(
page.getByRole('heading', { name: 'Calendrier des absences' }),
).toBeVisible();
});
test('le thème bascule et survit à un rechargement', async ({ page }) => {
await page.goto('/');
const html = page.locator('html');
await expect(html).toHaveAttribute('data-theme', 'light');
await page.getByRole('button', { name: /^Thème/ }).click();
await expect(html).toHaveAttribute('data-theme', 'dark');
// Le script inline doit reposer le thème avant le premier rendu : sans lui,
// la page reviendrait en clair puis basculerait — un flash blanc.
await page.reload();
await expect(html).toHaveAttribute('data-theme', 'dark');
});
test('une entrée de navigation non construite mène à un écran explicite', async ({
page,
}) => {
await page.goto('/');
await page.getByRole('link', { name: 'Profils incomplets' }).click();
await expect(
page.getByRole('heading', { name: 'Profils incomplets' }),
).toBeVisible();
// `exact` évite de heurter l'annonceur de route de Next, qui répète le titre
// du document — « Écran à venir · PlanFlow ».
await expect(
page.getByText('Écran à venir', { exact: true }),
).toBeVisible();
});