feat(orion): extend report layout settings to version 1.1
This commit is contained in:
parent
12e1761a5b
commit
613ffdc8b7
591 changed files with 3601 additions and 999 deletions
|
|
@ -0,0 +1,32 @@
|
|||
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`\)/);
|
||||
});
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import test from "node:test";
|
||||
import path from "node:path";
|
||||
|
||||
const page = fs.readFileSync(path.resolve("app/(app)/settings/report-layout/page.tsx"), "utf8");
|
||||
const shell = fs.readFileSync(path.resolve("components/app-shell.tsx"), "utf8");
|
||||
const bff = fs.readFileSync(path.resolve("app/api/report-settings/route.ts"), "utf8");
|
||||
const previewBff = fs.readFileSync(path.resolve("app/api/report-settings/preview/route.ts"), "utf8");
|
||||
|
||||
test("admin navigation contains report settings only for admins", () => {
|
||||
assert.match(shell, /href: "\/settings\/report-layout"/);
|
||||
assert.match(shell, /label: "Berichtseinstellungen"/);
|
||||
assert.match(shell, /adminOnly: true/);
|
||||
});
|
||||
|
||||
test("report settings page gates non-admin users and loads saved settings", () => {
|
||||
assert.match(page, /user\?\.role !== "admin"/);
|
||||
assert.match(page, /fetch\("\/api\/report-settings"/);
|
||||
assert.match(page, /queryKey: \["report-settings"\]/);
|
||||
assert.match(page, /Berichtseinstellungen werden geladen/);
|
||||
});
|
||||
|
||||
test("dirty state controls reset and save behavior", () => {
|
||||
assert.match(page, /const dirty = !sameSettings\(draft, saved\)/);
|
||||
assert.match(page, /disabled=\{!dirty \|\| saveMutation\.isPending/);
|
||||
assert.match(page, /setDraft\(saved\)/);
|
||||
assert.match(page, /Änderungen verworfen/);
|
||||
});
|
||||
|
||||
test("page sends PUT and preview PDF through Atlas BFF", () => {
|
||||
assert.match(page, /method: "PUT"/);
|
||||
assert.match(page, /JSON\.stringify\(values\)/);
|
||||
assert.match(page, /\/api\/report-settings\/preview/);
|
||||
assert.match(page, /Vorschau aktualisieren/);
|
||||
assert.match(page, /PDF wird erzeugt/);
|
||||
assert.match(page, /<iframe title="Orion PDF-Vorschau"/);
|
||||
assert.match(page, /URL\.createObjectURL/);
|
||||
});
|
||||
|
||||
test("report settings page exposes v1.1 setting groups", () => {
|
||||
for (const label of [
|
||||
"Seitenlayout",
|
||||
"Seitenränder",
|
||||
"Abschnittsabstände",
|
||||
"Deckblatt kompakt",
|
||||
"Tabellen",
|
||||
"Tabellenlayout",
|
||||
"Tabellenschrift",
|
||||
"Bildposition",
|
||||
"Maximale Bilder pro Seite",
|
||||
"Bildbeschriftungen",
|
||||
"Kopf- und Fußzeile",
|
||||
"Kopfzeile anzeigen",
|
||||
"Fußzeile anzeigen",
|
||||
"Firmenlogo"
|
||||
]) {
|
||||
assert.match(page, new RegExp(label));
|
||||
}
|
||||
});
|
||||
|
||||
test("BFF routes use HttpOnly cookie and forward PDF content", () => {
|
||||
assert.match(bff, /AUTH_COOKIE_NAME/);
|
||||
assert.match(bff, /Authorization: `Bearer \$\{token\}`/);
|
||||
assert.match(bff, /\/report-settings/);
|
||||
assert.match(previewBff, /content-type/);
|
||||
assert.match(previewBff, /application\/pdf/);
|
||||
assert.match(previewBff, /orion-layout-preview\.pdf/);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue