Works council members, expectant mothers, parents on leave, registered disabled employees, apprentices — each has its own rules that come before a dismissal. The tool does not judge whether one is lawful, but it must not stay quiet about it either, and looking it up on the contract tab is exactly the step that gets skipped under time pressure. So: a checkbox, an optional end date, and a red warning at the top of the termination panel naming the date — or saying plainly that no end was recorded. It shows for a no-show too; the protection runs from the start of the contract, not the first day worked. The date is optional on purpose. A works council mandate has a known end, a pregnancy does not, and a mandatory field would force an invented number. A constraint says only what cannot be: an end date without the flag, which would be a leftover nobody could interpret. The field goes the whole way through — hire, data change, contract sheet, export, report criteria (as a yes/no and as a date range), and the import. A field that exists in one screen and not the next is how people stop trusting the numbers. Terminating is now offered for planned entries as well, labelled "Nicht angetreten", with No Show preselected. Without it a person who never turned up stayed a planned entry forever, since nothing else can end one. One finding worth recording: tsc has been reporting success on a broken program. A generated file under .next got corrupted when a build ran against a live dev server, and its syntax errors suppressed semantic checking everywhere else — two genuine type errors in this change went unreported until I typechecked with .next excluded. The file is removed and the ordinary typecheck is meaningful again. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
126 lines
4.5 KiB
TypeScript
126 lines
4.5 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { VertragTab } from "@/components/employees/tabs/VertragTab";
|
|
import type { Database } from "@/lib/supabase/types";
|
|
|
|
type EmployeeRow = Database["public"]["Tables"]["employees"]["Row"];
|
|
|
|
// Auf dem Vertragsblatt stand ein Feld „Merkmale" mit allem Zutreffenden,
|
|
// durch Kommas getrennt — und einem Gedankenstrich, wenn nichts zutraf.
|
|
// Daraus liess sich nicht ablesen, ob jemand keinen Dienstwagen hat oder ob
|
|
// die Frage nie beantwortet wurde. Und beim Dienstwagen fehlte, worum es
|
|
// eigentlich geht: ob Verbrenner oder E-KFZ.
|
|
|
|
function mitarbeiter(teil: Partial<EmployeeRow> = {}): EmployeeRow {
|
|
return {
|
|
id: "e1",
|
|
personnel_number: 3038,
|
|
first_name: "Hannah",
|
|
last_name: "Winkler",
|
|
gender: "w",
|
|
birth_date: "1990-04-01",
|
|
sv_nummer: null,
|
|
nationality: "Österreich",
|
|
address: null,
|
|
address_country: null,
|
|
postal_code: null,
|
|
city: null,
|
|
email: null,
|
|
phone: null,
|
|
job_title: "IT-Security-Spezialist:in",
|
|
location_id: "l1",
|
|
employment_type: "Vollzeit",
|
|
weekly_hours: 38.5,
|
|
monthly_salary_gross: null,
|
|
contract_type: "unbefristet",
|
|
contract_end_date: null,
|
|
paygrade: "C",
|
|
source: "Extern",
|
|
status: "Aktiv",
|
|
entry_date: "2017-07-15",
|
|
exit_date: null,
|
|
exit_reason: null,
|
|
karenz_start_date: null,
|
|
karenz_return_date: null,
|
|
absence_type: null,
|
|
avatar_color: null,
|
|
worker_type: "Angestellte:r",
|
|
collective_agreement: "Handel",
|
|
work_days: ["Mo", "Di", "Mi", "Do", "Fr"],
|
|
is_betriebsrat: false,
|
|
has_dienstwagen: false,
|
|
dienstwagen_art: null,
|
|
has_kuendigungsschutz: false,
|
|
kuendigungsschutz_bis: null,
|
|
is_laterale_fuehrung: false,
|
|
is_c_level: false,
|
|
title_prefix: [],
|
|
title_suffix: [],
|
|
emergency_contact_name: null,
|
|
emergency_contact_phone: null,
|
|
emergency_contact_relation: null,
|
|
created_at: "2017-07-15T00:00:00.000Z",
|
|
updated_at: "2017-07-15T00:00:00.000Z",
|
|
...teil,
|
|
} as EmployeeRow;
|
|
}
|
|
|
|
/** Der Wert, der unter einer Beschriftung steht. */
|
|
function wertZu(label: string): string {
|
|
return screen.getByText(label).parentElement!.querySelector("dd")!.textContent ?? "";
|
|
}
|
|
|
|
describe("VertragTab — Merkmale", () => {
|
|
it("führt jedes Merkmal als eigene Zeile, nicht als Aufzählung", () => {
|
|
render(<VertragTab employee={mitarbeiter()} />);
|
|
for (const label of ["Dienstwagen", "Betriebsrat", "Laterale Führung", "C-Level"]) {
|
|
expect(screen.getByText(label)).toBeInTheDocument();
|
|
}
|
|
expect(screen.queryByText("Merkmale")).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("sagt Nein, statt das Feld leer zu lassen", () => {
|
|
// „–" liesse offen, ob niemand die Frage beantwortet hat.
|
|
render(<VertragTab employee={mitarbeiter()} />);
|
|
expect(wertZu("Dienstwagen")).toBe("Nein");
|
|
expect(wertZu("Betriebsrat")).toBe("Nein");
|
|
expect(wertZu("C-Level")).toBe("Nein");
|
|
});
|
|
|
|
it("nennt beim Dienstwagen die Antriebsart statt eines blossen Ja", () => {
|
|
render(<VertragTab employee={mitarbeiter({ has_dienstwagen: true, dienstwagen_art: "Elektro" })} />);
|
|
expect(wertZu("Dienstwagen")).toBe("E-KFZ");
|
|
});
|
|
|
|
it("unterscheidet den Verbrenner davon", () => {
|
|
render(<VertragTab employee={mitarbeiter({ has_dienstwagen: true, dienstwagen_art: "Verbrenner" })} />);
|
|
expect(wertZu("Dienstwagen")).toBe("Verbrenner");
|
|
});
|
|
|
|
it("zeigt gesetzte Merkmale als Ja", () => {
|
|
render(<VertragTab employee={mitarbeiter({ is_betriebsrat: true, is_c_level: true })} />);
|
|
expect(wertZu("Betriebsrat")).toBe("Ja");
|
|
expect(wertZu("C-Level")).toBe("Ja");
|
|
expect(wertZu("Laterale Führung")).toBe("Nein");
|
|
});
|
|
});
|
|
|
|
describe("VertragTab — Kündigungsschutz", () => {
|
|
it("nennt das Enddatum statt eines blossen Ja", () => {
|
|
// „Ja" allein liesse offen, ob der Schutz noch läuft — und genau danach
|
|
// fragt jemand, der auf dieses Blatt schaut.
|
|
render(<VertragTab employee={mitarbeiter({ has_kuendigungsschutz: true, kuendigungsschutz_bis: "2027-06-30" })} />);
|
|
expect(wertZu("Besonderer Kündigungsschutz")).toBe("bis 30.06.2027");
|
|
});
|
|
|
|
it("sagt es auch, wenn das Ende offen ist", () => {
|
|
render(<VertragTab employee={mitarbeiter({ has_kuendigungsschutz: true, kuendigungsschutz_bis: null })} />);
|
|
expect(wertZu("Besonderer Kündigungsschutz")).toBe("Ja (Ende offen)");
|
|
});
|
|
|
|
it("steht ohne Schutz auf Nein", () => {
|
|
render(<VertragTab employee={mitarbeiter()} />);
|
|
expect(wertZu("Besonderer Kündigungsschutz")).toBe("Nein");
|
|
});
|
|
});
|