Give each characteristic its own line, and name the car
The contract sheet had one field, "Merkmale", holding whatever applied, comma-separated — and a dash when nothing did. Two problems in one row. A dash cannot distinguish "has no company car" from "nobody ever answered the question", and the entry read "Dienstwagen" without saying which kind, which is the thing worth knowing since electric vehicles are tracked separately. Betriebsrat, Dienstwagen, laterale Führung and C-Level are now four lines like every other line on the sheet, each with Ja or Nein. The company car shows its drivetrain instead: E-KFZ or Verbrenner. That label existed in three places — the dropdown, the hire summary and now here. It lives in lib/dienstwagen.ts, so the same car cannot end up named differently depending on which screen you are looking at. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
104
tests/components/VertragTab.test.tsx
Normal file
104
tests/components/VertragTab.test.tsx
Normal file
@@ -0,0 +1,104 @@
|
||||
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,
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user