Alpenwerk HR 0.2.2 - C-Level als Auswahl aus der fachlichen Liste (C1 … VD) statt Ja/Nein; überall als Code angezeigt - Standorte mit Unterstandorten: bei „Shop“ folgt die Auswahl des einzelnen Shops - Angehörige und Notfallkontakte im Import: Verhältnis aus der Liste, bei „Sonstige“ mit eigenem Text - Wochenstunden mit zwei Nachkommastellen (z. B. 19,25) - Langzeitabwesenheit: „Endet am“ statt Rückkehr; eine anschliessende Abwesenheit lässt sich nur nach der Wochenhilfe (Mutterschutz) planen - Notizen mit Fälligkeit erscheinen erst ab diesem Tag in der Glocke - Testinstallationen: mit TESTSYSTEM=1 in app.env trägt jede Seite den Schriftzug „Testsystem“ und einen roten Rahmen - Next.js 16.4.6
80 lines
3.6 KiB
TypeScript
80 lines
3.6 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { BLATT_ANGEHOERIGE, BLATT_NOTFALLKONTAKTE } from "@/lib/austausch/katalog";
|
|
import { kurzname, oberstandorte, oberstandortVon, unterstandorte, zuweisbareStandorte } from "@/lib/standorte";
|
|
import { verhaeltnisAusDatei, verhaeltnisFuerDatei } from "@/lib/verhaeltnis";
|
|
|
|
describe("Verhältnis in der Austauschdatei", () => {
|
|
it("teilt einen frei eingetragenen Wert in „Sonstige“ und den Text", () => {
|
|
expect(verhaeltnisFuerDatei("Onkel")).toEqual({ auswahl: "Sonstige", sonstige: "Onkel" });
|
|
expect(verhaeltnisFuerDatei("Kind")).toEqual({ auswahl: "Kind", sonstige: null });
|
|
expect(verhaeltnisFuerDatei("Sonstige")).toEqual({ auswahl: "Sonstige", sonstige: null });
|
|
expect(verhaeltnisFuerDatei(null)).toEqual({ auswahl: null, sonstige: null });
|
|
});
|
|
|
|
it("speichert bei „Sonstige“ den Text, ohne Text „Sonstige“", () => {
|
|
expect(verhaeltnisAusDatei("Sonstige", " Nachbarin ")).toEqual({ wert: "Nachbarin" });
|
|
expect(verhaeltnisAusDatei("Sonstige", null)).toEqual({ wert: "Sonstige" });
|
|
expect(verhaeltnisAusDatei("Kind", null)).toEqual({ wert: "Kind" });
|
|
expect(verhaeltnisAusDatei(null, null)).toEqual({ wert: null });
|
|
});
|
|
|
|
it("weist einen Text ohne „Sonstige“ ab", () => {
|
|
expect(verhaeltnisAusDatei("Kind", "Onkel")).toHaveProperty("fehler");
|
|
expect(verhaeltnisAusDatei(null, "Onkel")).toHaveProperty("fehler");
|
|
});
|
|
|
|
it("hat in beiden Blättern die Spalte gleich hinter der Auswahl, die Auswahl ohne freie Eingabe", () => {
|
|
for (const [blatt, feld] of [
|
|
[BLATT_ANGEHOERIGE, "relationship"],
|
|
[BLATT_NOTFALLKONTAKTE, "relation"],
|
|
] as const) {
|
|
const i = blatt.spalten.findIndex((s) => s.feld === feld);
|
|
expect(blatt.spalten[i + 1].feld).toBe(`${feld}_sonstige`);
|
|
const format = blatt.spalten[i].format;
|
|
expect(format.art === "auswahl" && format.frei).toBeFalsy();
|
|
}
|
|
});
|
|
});
|
|
|
|
const ALLE = [
|
|
{ id: "hernals", name: "Wien-Hernals", parent_id: null },
|
|
{ id: "shop", name: "Shop", parent_id: null },
|
|
{ id: "w17", name: "Shop W17", parent_id: "shop" },
|
|
{ id: "hbf", name: "Shop Wien Hauptbahnhof", parent_id: "shop" },
|
|
];
|
|
|
|
describe("Standorte mit Unterstandorten", () => {
|
|
it("zeigt zuerst die oberste Ebene und unter „Shop“ die Shops", () => {
|
|
expect(oberstandorte(ALLE).map((s) => s.id)).toEqual(["hernals", "shop"]);
|
|
expect(unterstandorte(ALLE, "shop").map((s) => s.id)).toEqual(["w17", "hbf"]);
|
|
expect(unterstandorte(ALLE, "hernals")).toEqual([]);
|
|
expect(kurzname(ALLE[3], ALLE[1])).toBe("Wien Hauptbahnhof");
|
|
});
|
|
|
|
it("findet zu einem gespeicherten Shop die erste Auswahl", () => {
|
|
expect(oberstandortVon(ALLE, "w17")).toBe("shop");
|
|
expect(oberstandortVon(ALLE, "hernals")).toBe("hernals");
|
|
expect(oberstandortVon(ALLE, "")).toBe("");
|
|
});
|
|
|
|
it("bietet in Filtern nur Standorte an, auf denen jemand sitzen kann", () => {
|
|
expect(zuweisbareStandorte(ALLE).map((s) => s.id)).toEqual(["hernals", "w17", "hbf"]);
|
|
});
|
|
|
|
it("legt in der Migration genau die sechs Shops an", () => {
|
|
const sql = readFileSync(join(process.cwd(), "db/migrations/20261123140000_standort_shop.sql"), "utf8");
|
|
const einfuegen = sql.match(/from \(values ([^\n]+)\) v\(name\)\non conflict/)?.[1];
|
|
expect(einfuegen).toBeDefined();
|
|
expect([...einfuegen!.matchAll(/'([^']+)'/g)].map((m) => m[1])).toEqual([
|
|
"Shop W17",
|
|
"Shop Wodo",
|
|
"Shop Parndorf",
|
|
"Shop Donaupark",
|
|
"Shop W1",
|
|
"Shop Wien Hauptbahnhof",
|
|
]);
|
|
});
|
|
});
|