test(web): add 291 tests for parsers, hooks, and UI components

Lib utilities: scopeImportParser (31), status-styles (58),
planningEntryIds (10), uuid (11).

Hooks: useFilters (28), useRowOrder (18), usePermissions (30),
useViewPrefs (24).

Components: AnimatedModal (14), DateInput (22), InfoTooltip (13),
ProgressRing (19).

Web test suite: 75 → 87 files, 553 → 844 tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 17:14:11 +02:00
parent 98dca6126f
commit a3d75973ee
12 changed files with 2626 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
import { describe, expect, it } from "vitest";
import { getPlanningEntryMutationId } from "./planningEntryIds.js";
describe("getPlanningEntryMutationId", () => {
// ---------------------------------------------------------------------------
// Priority: entityId first
// ---------------------------------------------------------------------------
it("returns entityId when all three fields are present", () => {
const result = getPlanningEntryMutationId({
id: "id-1",
entityId: "entity-1",
sourceAllocationId: "alloc-1",
});
expect(result).toBe("entity-1");
});
it("returns entityId when sourceAllocationId is absent", () => {
const result = getPlanningEntryMutationId({
id: "id-1",
entityId: "entity-1",
});
expect(result).toBe("entity-1");
});
it("returns entityId when sourceAllocationId is null", () => {
const result = getPlanningEntryMutationId({
id: "id-1",
entityId: "entity-1",
sourceAllocationId: null,
});
expect(result).toBe("entity-1");
});
// ---------------------------------------------------------------------------
// Fallback: sourceAllocationId when entityId is absent/null/undefined
// ---------------------------------------------------------------------------
it("returns sourceAllocationId when entityId is null", () => {
const result = getPlanningEntryMutationId({
id: "id-1",
entityId: null,
sourceAllocationId: "alloc-1",
});
expect(result).toBe("alloc-1");
});
it("returns sourceAllocationId when entityId is undefined", () => {
const result = getPlanningEntryMutationId({
id: "id-1",
entityId: undefined,
sourceAllocationId: "alloc-1",
});
expect(result).toBe("alloc-1");
});
it("returns sourceAllocationId when entityId field is omitted", () => {
const result = getPlanningEntryMutationId({
id: "id-1",
sourceAllocationId: "alloc-1",
});
expect(result).toBe("alloc-1");
});
// ---------------------------------------------------------------------------
// Final fallback: id
// ---------------------------------------------------------------------------
it("returns id when both entityId and sourceAllocationId are null", () => {
const result = getPlanningEntryMutationId({
id: "id-1",
entityId: null,
sourceAllocationId: null,
});
expect(result).toBe("id-1");
});
it("returns id when both entityId and sourceAllocationId are undefined", () => {
const result = getPlanningEntryMutationId({
id: "id-1",
entityId: undefined,
sourceAllocationId: undefined,
});
expect(result).toBe("id-1");
});
it("returns id when only id is provided", () => {
const result = getPlanningEntryMutationId({ id: "id-only" });
expect(result).toBe("id-only");
});
// ---------------------------------------------------------------------------
// Return-type guarantee
// ---------------------------------------------------------------------------
it("always returns a string", () => {
const cases = [
{ id: "x", entityId: "e", sourceAllocationId: "a" },
{ id: "x", entityId: null, sourceAllocationId: "a" },
{ id: "x", entityId: null, sourceAllocationId: null },
];
cases.forEach((entry) => {
expect(typeof getPlanningEntryMutationId(entry)).toBe("string");
});
});
});