Alléger l'annuaire
Le formulaire d'embauche, posé au bas de la liste, occupait plus de place que l'effectif qu'on vient consulter — une quinzaine de champs déployés en permanence pour un geste occasionnel. Il s'ouvre désormais en modale, depuis le bouton d'en-tête. `<dialog>` natif plutôt qu'un panneau maison : le piège de focus, la fermeture par Échap et le fond inerte viennent avec, et une `<div>` doit les réimplémenter sans jamais les tenir tout à fait. Le tableau perd sa carte et ses fonds : une liste de personnes se lit mieux sans cadre autour. Les colonnes suivent l'annuaire de référence — collaborateur, rôle, email, mobile, rattachement, invitation. Le contrat quitte le tableau, où il doublait le filtre qui le cherche déjà ; son absence reste signalée là où elle compte, dans le rattachement. Le décompte ne s'affiche plus que filtré : « 87 salariés » au-dessus de 87 lignes n'apprend rien. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
93724b9d66
commit
894e880198
11 files changed
+160
-59
No files matched your search
@@ -0,0 +1,70 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
|
||||||
|
import { AddEmployeeForm } from '@/app/(app)/equipe/AddEmployeeForm';
|
||||||
|
import { Button } from '@/components/ui/Button';
|
||||||
|
import type { ContractLocation } from '@/server/employees/queries';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajout d'un collaborateur, en modale.
|
||||||
|
*
|
||||||
|
* Le formulaire d'embauche compte une quinzaine de champs : posé au bas de la
|
||||||
|
* liste, il occupait plus de place que l'effectif qu'on vient consulter. Il ne
|
||||||
|
* s'ouvre donc qu'à la demande.
|
||||||
|
*
|
||||||
|
* `<dialog>` natif plutôt qu'un panneau maison : il apporte le piège de focus,
|
||||||
|
* la fermeture par Échap et le fond inerte, trois choses qu'une `<div>` doit
|
||||||
|
* réimplémenter et rate presque toujours.
|
||||||
|
*/
|
||||||
|
export function AddEmployeeDialog({
|
||||||
|
locations,
|
||||||
|
}: {
|
||||||
|
locations: ContractLocation[];
|
||||||
|
}) {
|
||||||
|
const dialog = useRef<HTMLDialogElement>(null);
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const element = dialog.current;
|
||||||
|
if (!element) return;
|
||||||
|
if (open && !element.open) element.showModal();
|
||||||
|
if (!open && element.open) element.close();
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button variant="primary" onClick={() => setOpen(true)}>
|
||||||
|
Ajouter un collaborateur
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<dialog
|
||||||
|
ref={dialog}
|
||||||
|
aria-labelledby="ajout-collaborateur"
|
||||||
|
onClose={() => setOpen(false)}
|
||||||
|
className="m-auto w-[min(46rem,calc(100vw-2rem))] rounded-3 border border-line-1 bg-surface p-0 text-ink-1 backdrop:bg-[rgb(0_0_0/0.4)]"
|
||||||
|
>
|
||||||
|
<header className="flex items-center gap-3 border-b border-line-1 px-5 py-4">
|
||||||
|
<h2 id="ajout-collaborateur" className="text-md font-semibold">
|
||||||
|
Ajouter un collaborateur
|
||||||
|
</h2>
|
||||||
|
<span className="flex-1" />
|
||||||
|
<Button variant="ghost" onClick={() => setOpen(false)}>
|
||||||
|
Fermer
|
||||||
|
</Button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div className="max-h-[70vh] overflow-y-auto p-5">
|
||||||
|
{open ? (
|
||||||
|
// Monté à l'ouverture : un formulaire démonté entre deux usages
|
||||||
|
// repart vide, sans traîner la saisie abandonnée la fois d'avant.
|
||||||
|
<AddEmployeeForm
|
||||||
|
locations={locations}
|
||||||
|
onSaved={() => setOpen(false)}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -39,9 +39,12 @@ const selectClass =
|
|||||||
|
|
||||||
export function AddEmployeeForm({
|
export function AddEmployeeForm({
|
||||||
locations,
|
locations,
|
||||||
|
onSaved,
|
||||||
}: {
|
}: {
|
||||||
/** Vide quand la capacité d'ouvrir un contrat manque : la section disparaît. */
|
/** Vide quand la capacité d'ouvrir un contrat manque : la section disparaît. */
|
||||||
locations: ContractLocation[];
|
locations: ContractLocation[];
|
||||||
|
/** Appelé une fois l'ajout accepté — la modale s'y referme. */
|
||||||
|
onSaved?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const [state, formAction] = useActionState<ActionState, FormData>(
|
const [state, formAction] = useActionState<ActionState, FormData>(
|
||||||
createEmployeeAction,
|
createEmployeeAction,
|
||||||
@@ -50,6 +53,14 @@ export function AddEmployeeForm({
|
|||||||
const [withContract, setWithContract] = useState(locations.length > 0);
|
const [withContract, setWithContract] = useState(locations.length > 0);
|
||||||
const [locationId, setLocationId] = useState(locations[0]?.id ?? '');
|
const [locationId, setLocationId] = useState(locations[0]?.id ?? '');
|
||||||
const [forfait, setForfait] = useState(false);
|
const [forfait, setForfait] = useState(false);
|
||||||
|
const [acknowledged, setAcknowledged] = useState<ActionState>(empty);
|
||||||
|
|
||||||
|
// Acquitté une fois pour toutes : sans cela, un succès resté en mémoire
|
||||||
|
// refermerait la modale à sa réouverture.
|
||||||
|
if (state !== acknowledged && state.ok) {
|
||||||
|
setAcknowledged(state);
|
||||||
|
onSaved?.();
|
||||||
|
}
|
||||||
|
|
||||||
const teams =
|
const teams =
|
||||||
locations.find((location) => location.id === locationId)?.teams ?? [];
|
locations.find((location) => location.id === locationId)?.teams ?? [];
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ import { useRef } from 'react';
|
|||||||
* choix plutôt que de vider la page.
|
* choix plutôt que de vider la page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** Pastilles plutôt que champs : une barre de filtres se survole, elle ne se
|
||||||
|
* remplit pas. */
|
||||||
const selectClass =
|
const selectClass =
|
||||||
'h-9 min-w-0 rounded-2 border border-line-2 bg-surface px-2 text-sm text-ink-1 outline-none focus-visible:border-focus';
|
'h-10 min-w-0 cursor-pointer rounded-full border border-line-2 bg-surface px-4 text-sm text-ink-1 outline-none hover:bg-surface-2 focus-visible:border-focus';
|
||||||
|
|
||||||
export interface FilterOptions {
|
export interface FilterOptions {
|
||||||
locations: Array<{ id: string; name: string }>;
|
locations: Array<{ id: string; name: string }>;
|
||||||
@@ -43,7 +45,7 @@ export function DirectoryFilters({ options }: { options: FilterOptions }) {
|
|||||||
type="search"
|
type="search"
|
||||||
defaultValue={current('q')}
|
defaultValue={current('q')}
|
||||||
placeholder="Rechercher par prénom, nom ou matricule."
|
placeholder="Rechercher par prénom, nom ou matricule."
|
||||||
className="h-10 rounded-3 border border-line-2 bg-surface px-3.5 text-sm text-ink-1 outline-none placeholder:text-ink-3 focus-visible:border-focus"
|
className="h-11 rounded-full border border-line-2 bg-surface px-4 text-sm text-ink-1 outline-none placeholder:text-ink-3 focus-visible:border-focus"
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
// La frappe ne déclenche pas une requête par caractère : elle
|
// La frappe ne déclenche pas une requête par caractère : elle
|
||||||
// attend un silence. Sans cela, chercher « Dupont » en lance six.
|
// attend un silence. Sans cela, chercher « Dupont » en lance six.
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
import { AddEmployeeForm } from '@/app/(app)/equipe/AddEmployeeForm';
|
import { AddEmployeeDialog } from '@/app/(app)/equipe/AddEmployeeDialog';
|
||||||
import { DirectoryFilters } from '@/app/(app)/equipe/DirectoryFilters';
|
import { DirectoryFilters } from '@/app/(app)/equipe/DirectoryFilters';
|
||||||
import { PageBody, PageHeader } from '@/components/shell/PageHeader';
|
import { PageBody, PageHeader } from '@/components/shell/PageHeader';
|
||||||
import { Badge, type Tone } from '@/components/ui/Badge';
|
import { Badge, type Tone } from '@/components/ui/Badge';
|
||||||
import { Card, CardHeader, EmptyState } from '@/components/ui/Card';
|
import { EmptyState } from '@/components/ui/Card';
|
||||||
import {
|
import {
|
||||||
listContractLocations,
|
listContractLocations,
|
||||||
listEmployees,
|
listEmployees,
|
||||||
@@ -21,8 +21,6 @@ const INVITATION_TONES: Record<string, { label: string; tone: Tone }> = {
|
|||||||
REVOKED: { label: 'Révoquée', tone: 'neutral' },
|
REVOKED: { label: 'Révoquée', tone: 'neutral' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateFormat = new Intl.DateTimeFormat('fr-FR', { dateStyle: 'medium' });
|
|
||||||
|
|
||||||
const one = (value: string | string[] | undefined): string | undefined =>
|
const one = (value: string | string[] | undefined): string | undefined =>
|
||||||
Array.isArray(value) ? value[0] : value;
|
Array.isArray(value) ? value[0] : value;
|
||||||
|
|
||||||
@@ -59,25 +57,28 @@ export default async function EquipePage({
|
|||||||
<PageBody>
|
<PageBody>
|
||||||
<PageHeader
|
<PageHeader
|
||||||
title="Équipe"
|
title="Équipe"
|
||||||
subtitle={
|
// Le décompte n'apparaît que s'il apprend quelque chose : « 87 salariés »
|
||||||
filtered
|
// au-dessus d'une liste de 87 lignes ne dit rien que la liste ne dise.
|
||||||
? `${directory.rows.length} sur ${directory.total} salariés`
|
{...(filtered
|
||||||
: `${directory.total} salarié${directory.total > 1 ? 's' : ''}`
|
? { subtitle: `${directory.rows.length} sur ${directory.total} salariés` }
|
||||||
}
|
: {})}
|
||||||
actions={
|
actions={
|
||||||
|
<>
|
||||||
<Link
|
<Link
|
||||||
href="/reglages/registre"
|
href="/reglages/registre"
|
||||||
className="inline-flex h-8 items-center rounded-2 border border-line-3 bg-surface px-3.5 text-sm font-medium text-ink-1 hover:bg-surface-2"
|
className="inline-flex h-8 items-center rounded-2 border border-line-3 bg-surface px-3.5 text-sm font-medium text-ink-1 hover:bg-surface-2"
|
||||||
>
|
>
|
||||||
Registre unique du personnel
|
Registre unique du personnel
|
||||||
</Link>
|
</Link>
|
||||||
|
<AddEmployeeDialog locations={hiringLocations} />
|
||||||
|
</>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* `useSearchParams` impose une frontière de suspense : sans elle, la
|
{/* `useSearchParams` impose une frontière de suspense : sans elle, la
|
||||||
page entière serait rendue à la demande au lieu d'être servie puis
|
page entière serait rendue à la demande au lieu d'être servie puis
|
||||||
hydratée. */}
|
hydratée. */}
|
||||||
<Suspense fallback={<div className="h-[5.5rem]" />}>
|
<Suspense fallback={<div className="h-[6rem]" />}>
|
||||||
<DirectoryFilters
|
<DirectoryFilters
|
||||||
options={{
|
options={{
|
||||||
locations: directory.locations,
|
locations: directory.locations,
|
||||||
@@ -87,7 +88,6 @@ export default async function EquipePage({
|
|||||||
/>
|
/>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
||||||
<Card>
|
|
||||||
{directory.rows.length === 0 ? (
|
{directory.rows.length === 0 ? (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
title={filtered ? 'Aucun résultat' : 'Aucun salarié'}
|
title={filtered ? 'Aucun résultat' : 'Aucun salarié'}
|
||||||
@@ -99,15 +99,15 @@ export default async function EquipePage({
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
<table className="w-full min-w-[980px] border-collapse text-sm">
|
<table className="w-full min-w-[940px] border-collapse text-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="border-b border-line-2 bg-surface-2 text-left text-micro font-semibold tracking-[0.06em] text-ink-3 uppercase">
|
<tr className="border-b border-line-2 text-left text-micro font-semibold tracking-[0.04em] text-ink-3">
|
||||||
<th className="px-4 py-2.5">Collaborateur</th>
|
<th className="px-3 py-3 font-semibold">Collaborateur</th>
|
||||||
<th className="px-4 py-2.5">Rôle</th>
|
<th className="px-3 py-3 font-semibold">Rôle</th>
|
||||||
<th className="px-4 py-2.5">Contrat</th>
|
<th className="px-3 py-3 font-semibold">Email</th>
|
||||||
<th className="px-4 py-2.5">Mobile</th>
|
<th className="px-3 py-3 font-semibold">Mobile</th>
|
||||||
<th className="px-4 py-2.5">Rattachement</th>
|
<th className="px-3 py-3 font-semibold">Rattachement</th>
|
||||||
<th className="px-4 py-2.5">Invitation</th>
|
<th className="px-3 py-3 font-semibold">Invitation</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -121,63 +121,61 @@ export default async function EquipePage({
|
|||||||
key={employee.id}
|
key={employee.id}
|
||||||
className="border-b border-line-1 last:border-b-0 hover:bg-surface-2"
|
className="border-b border-line-1 last:border-b-0 hover:bg-surface-2"
|
||||||
>
|
>
|
||||||
<td className="px-4 py-2.5">
|
<td className="px-3 py-3">
|
||||||
<Link
|
<Link
|
||||||
href={`/equipe/${employee.id}`}
|
href={`/equipe/${employee.id}`}
|
||||||
className="flex items-center gap-2.5 rounded-2"
|
className="flex items-center gap-2.5 rounded-2"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
aria-hidden
|
aria-hidden
|
||||||
className="flex size-7 flex-none items-center justify-center rounded-full bg-accent-soft text-micro font-semibold text-accent-soft-ink"
|
className="flex size-8 flex-none items-center justify-center rounded-full bg-accent-soft text-micro font-semibold text-accent-soft-ink"
|
||||||
>
|
>
|
||||||
{employee.firstName.charAt(0)}
|
{employee.firstName.charAt(0)}
|
||||||
{employee.lastName.charAt(0)}
|
{employee.lastName.charAt(0)}
|
||||||
</span>
|
</span>
|
||||||
<span className="min-w-0">
|
<span className="min-w-0">
|
||||||
<span className="block truncate font-medium">
|
<span className="block truncate font-medium underline decoration-line-3 underline-offset-2">
|
||||||
{employee.firstName} {employee.lastName}
|
{employee.firstName} {employee.lastName}
|
||||||
</span>
|
</span>
|
||||||
|
{/* Le matricule ne double la colonne « Email » que
|
||||||
|
lorsqu'il n'y en a pas : c'est alors la seule
|
||||||
|
adresse à laquelle on désigne ce salarié. */}
|
||||||
|
{employee.email ? null : (
|
||||||
<span className="block truncate text-micro text-ink-3">
|
<span className="block truncate text-micro text-ink-3">
|
||||||
{employee.email ?? `Matricule ${employee.employeeNumber}`}
|
Matricule {employee.employeeNumber}
|
||||||
</span>
|
</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-2.5">
|
<td className="px-3 py-3">
|
||||||
<Badge tone="accent">{employee.roleName}</Badge>
|
<Badge tone="accent">{employee.roleName}</Badge>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-2.5">
|
<td className="px-3 py-3 text-ink-2">
|
||||||
{employee.contract ? (
|
{employee.email ?? (
|
||||||
<span className="flex flex-wrap items-center gap-1.5">
|
<span className="text-ink-3">Sans compte</span>
|
||||||
<span>{employee.contract.label}</span>
|
|
||||||
{employee.contract.forfaitJours ? (
|
|
||||||
<Badge tone="accent">Forfait jours</Badge>
|
|
||||||
) : null}
|
|
||||||
<span className="tnum text-micro text-ink-3">
|
|
||||||
depuis le{' '}
|
|
||||||
{dateFormat.format(employee.contract.since)}
|
|
||||||
</span>
|
|
||||||
</span>
|
|
||||||
) : (
|
|
||||||
<Badge tone="warn">Sans contrat</Badge>
|
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className="tnum px-4 py-2.5 text-ink-2">
|
<td className="tnum px-3 py-3 text-ink-2">
|
||||||
{employee.phone ?? (
|
{employee.phone ?? (
|
||||||
<span className="text-ink-3">Non renseigné</span>
|
<span className="text-ink-3">Non renseigné</span>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-2.5 text-ink-2">
|
<td className="px-3 py-3 text-ink-2">
|
||||||
{employee.locationName ?? '—'}
|
{employee.locationName ? (
|
||||||
|
<>
|
||||||
|
{employee.locationName}
|
||||||
{employee.teamName ? ` / ${employee.teamName}` : ''}
|
{employee.teamName ? ` / ${employee.teamName}` : ''}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Badge tone="warn">Sans contrat</Badge>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-2.5">
|
<td className="px-3 py-3">
|
||||||
{invitation ? (
|
{invitation ? (
|
||||||
<Badge tone={invitation.tone}>{invitation.label}</Badge>
|
<Badge tone={invitation.tone}>{invitation.label}</Badge>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-micro text-ink-3">
|
<span className="text-micro text-ink-3">—</span>
|
||||||
Sans accès applicatif
|
|
||||||
</span>
|
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -187,14 +185,6 @@ export default async function EquipePage({
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Card>
|
|
||||||
|
|
||||||
<Card>
|
|
||||||
<CardHeader title="Ajouter un collaborateur" />
|
|
||||||
<div className="p-4">
|
|
||||||
<AddEmployeeForm locations={hiringLocations} />
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
</PageBody>
|
</PageBody>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -113,6 +113,9 @@ test('une pièce sans politique n’est jamais purgée', async ({ page }) => {
|
|||||||
// compte, et une pièce partagée verrait son sort décidé par un autre test.
|
// compte, et une pièce partagée verrait son sort décidé par un autre test.
|
||||||
const suffix = `${Date.now()}-garde`;
|
const suffix = `${Date.now()}-garde`;
|
||||||
await page.goto('/equipe');
|
await page.goto('/equipe');
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const create = page.locator('form').filter({ hasText: 'Ajouter' });
|
const create = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await create.getByLabel('Prénom').fill('Garde');
|
await create.getByLabel('Prénom').fill('Garde');
|
||||||
await create.getByLabel('Nom', { exact: true }).fill(`Garde${suffix}`);
|
await create.getByLabel('Nom', { exact: true }).fill(`Garde${suffix}`);
|
||||||
@@ -167,6 +170,9 @@ test('une pièce échue est effectivement effacée', async ({ page }) => {
|
|||||||
await expect(page.getByText('Durée enregistrée.')).toBeVisible();
|
await expect(page.getByText('Durée enregistrée.')).toBeVisible();
|
||||||
|
|
||||||
await page.goto('/equipe');
|
await page.goto('/equipe');
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const create = page.locator('form').filter({ hasText: 'Ajouter' });
|
const create = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await create.getByLabel('Prénom').fill('Purge');
|
await create.getByLabel('Prénom').fill('Purge');
|
||||||
await create.getByLabel('Nom', { exact: true }).fill(`Purge${suffix}`);
|
await create.getByLabel('Nom', { exact: true }).fill(`Purge${suffix}`);
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ async function createEmployee(page: Page, tag: string) {
|
|||||||
const lastName = `Dossier${suffix}`;
|
const lastName = `Dossier${suffix}`;
|
||||||
|
|
||||||
await page.goto('/equipe');
|
await page.goto('/equipe');
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await form.getByLabel('Prénom').fill('Inès');
|
await form.getByLabel('Prénom').fill('Inès');
|
||||||
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
||||||
|
|||||||
+11
-4
@@ -14,6 +14,9 @@ async function createEmployee(page: Page) {
|
|||||||
const lastName = `Fiche${suffix}`;
|
const lastName = `Fiche${suffix}`;
|
||||||
|
|
||||||
await page.goto('/equipe');
|
await page.goto('/equipe');
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await form.getByLabel('Prénom').fill('Awa');
|
await form.getByLabel('Prénom').fill('Awa');
|
||||||
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
||||||
@@ -99,6 +102,9 @@ test('une embauche pose le contrat en même temps que le dossier', async ({
|
|||||||
const lastName = `Embauche${suffix}`;
|
const lastName = `Embauche${suffix}`;
|
||||||
|
|
||||||
await page.goto('/equipe');
|
await page.goto('/equipe');
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await form.getByLabel('Prénom').fill('Sofia');
|
await form.getByLabel('Prénom').fill('Sofia');
|
||||||
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
||||||
@@ -113,10 +119,11 @@ test('une embauche pose le contrat en même temps que le dossier', async ({
|
|||||||
await form.getByRole('button', { name: 'Ajouter' }).click();
|
await form.getByRole('button', { name: 'Ajouter' }).click();
|
||||||
await expect(page.getByText('Salarié ajouté.')).toBeVisible();
|
await expect(page.getByText('Salarié ajouté.')).toBeVisible();
|
||||||
|
|
||||||
// Le contrat est visible depuis l'annuaire, sans passer par la fiche.
|
// Le rattachement paraît dans l'annuaire : un dossier sans contrat y porte
|
||||||
await expect(page.getByRole('row', { name: new RegExp(lastName) })).toContainText(
|
// « Sans contrat », celui-ci porte son établissement.
|
||||||
'CDI',
|
await expect(
|
||||||
);
|
page.getByRole('row', { name: new RegExp(lastName) }),
|
||||||
|
).not.toContainText('Sans contrat');
|
||||||
|
|
||||||
await page.getByRole('link', { name: new RegExp(lastName) }).click();
|
await page.getByRole('link', { name: new RegExp(lastName) }).click();
|
||||||
// Le bandeau porte le contrat : c'est ce qui distingue un dossier embauché
|
// Le bandeau porte le contrat : c'est ce qui distingue un dossier embauché
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ async function createEmployee(page: Page, tag: string) {
|
|||||||
const email = `sacha.${suffix}@exemple.test`;
|
const email = `sacha.${suffix}@exemple.test`;
|
||||||
|
|
||||||
await page.goto('/equipe');
|
await page.goto('/equipe');
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await form.getByLabel('Prénom').fill(firstName);
|
await form.getByLabel('Prénom').fill(firstName);
|
||||||
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ test('un salarié sans compte applicatif est créable', async ({ page }) => {
|
|||||||
// deux passages, et un nom fixe finirait par désigner plusieurs salariés.
|
// deux passages, et un nom fixe finirait par désigner plusieurs salariés.
|
||||||
const matricule = `E9${Date.now() % 100000}`;
|
const matricule = `E9${Date.now() % 100000}`;
|
||||||
const nom = `Sanscompte${matricule}`;
|
const nom = `Sanscompte${matricule}`;
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await form.locator('input[name="firstName"]').fill('Sans');
|
await form.locator('input[name="firstName"]').fill('Sans');
|
||||||
await form.locator('input[name="lastName"]').fill(nom);
|
await form.locator('input[name="lastName"]').fill(nom);
|
||||||
|
|||||||
@@ -158,6 +158,9 @@ async function inviteWithRole(page: Page, roleLabel: string) {
|
|||||||
const lastName = `Role${suffix}`;
|
const lastName = `Role${suffix}`;
|
||||||
|
|
||||||
await page.goto('/equipe');
|
await page.goto('/equipe');
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const create = page.locator('form').filter({ hasText: 'Ajouter' });
|
const create = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await create.getByLabel('Prénom').fill('Alix');
|
await create.getByLabel('Prénom').fill('Alix');
|
||||||
await create.getByLabel('Nom', { exact: true }).fill(lastName);
|
await create.getByLabel('Nom', { exact: true }).fill(lastName);
|
||||||
|
|||||||
@@ -151,6 +151,9 @@ async function createAccessibleEmployee(page: Page) {
|
|||||||
const email = `facteur.${suffix}@exemple.test`;
|
const email = `facteur.${suffix}@exemple.test`;
|
||||||
|
|
||||||
await page.goto('/equipe');
|
await page.goto('/equipe');
|
||||||
|
// Le formulaire d’embauche n’est plus posé au bas de la liste : il s’ouvre
|
||||||
|
// en modale, à la demande.
|
||||||
|
await page.getByRole('button', { name: 'Ajouter un collaborateur' }).click();
|
||||||
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
const form = page.locator('form').filter({ hasText: 'Ajouter' });
|
||||||
await form.getByLabel('Prénom').fill('Noé');
|
await form.getByLabel('Prénom').fill('Noé');
|
||||||
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
await form.getByLabel('Nom', { exact: true }).fill(lastName);
|
||||||
|
|||||||
Reference in new issue
Block a user