32 lines
1.4 KiB
JavaScript
32 lines
1.4 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import test from "node:test";
|
|
|
|
const source = fs.readFileSync(path.resolve("app/(app)/validations/quick-start/page.tsx"), "utf8");
|
|
|
|
test("quickstart renders selectable location and contact controls", () => {
|
|
assert.match(source, /function SelectionCard/);
|
|
assert.match(source, /label="Standort"/);
|
|
assert.match(source, /label="Ansprechpartner"/);
|
|
assert.match(source, /<select/);
|
|
assert.match(source, /onChange=\{\(value\) => \{/);
|
|
});
|
|
|
|
test("quickstart auto-selects single customer masterdata and clears stale selections", () => {
|
|
assert.match(source, /data\.locations\.length === 1/);
|
|
assert.match(source, /data\.contacts\.length === 1/);
|
|
assert.match(source, /data\.devices\.length === 1/);
|
|
assert.match(source, /setSelectedLocationId\(""\)/);
|
|
assert.match(source, /setSelectedContactId\(""\)/);
|
|
assert.match(source, /setSelectedDeviceId\(""\)/);
|
|
});
|
|
|
|
test("quickstart button depends on valid ids rather than display objects", () => {
|
|
assert.match(source, /hasValidLocation/);
|
|
assert.match(source, /hasValidContact/);
|
|
assert.match(source, /hasValidDevice/);
|
|
assert.match(source, /location_id: selectedLocationId \|\| null/);
|
|
assert.match(source, /contact_id: selectedContactId \|\| null/);
|
|
assert.match(source, /window\.location\.replace\(`\/validations\/\$\{created\.id\}\/edit`\)/);
|
|
});
|