38 lines
2.5 KiB
TypeScript
38 lines
2.5 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { describe, it } from "node:test";
|
|
import { createDefaultExternalModelConfiguration } from "../src/external-model/configuration/external-model-configuration.js";
|
|
import { detectExternalModelWorkbook, getExternalModelConfiguration, updateExternalModelConfiguration } from "../src/frontend/utils/api.js";
|
|
|
|
describe("Revit XLSX settings", () => {
|
|
it("uses the project-scoped configuration endpoint with expectedRevision", async () => {
|
|
const requests: Array<{ url: string; method: string; body: unknown }> = [];
|
|
const originalFetch = globalThis.fetch;
|
|
globalThis.fetch = async (input, init) => {
|
|
requests.push({ url: String(input), method: init?.method ?? "GET", body: init?.body ? JSON.parse(String(init.body)) : undefined });
|
|
return new Response(JSON.stringify({ configuration: null, history: { currentRevision: 8 } }), { status: 200, headers: { "Content-Type": "application/json" } });
|
|
};
|
|
try {
|
|
const configuration = createDefaultExternalModelConfiguration();
|
|
await getExternalModelConfiguration("project-1");
|
|
await updateExternalModelConfiguration("project-1", 7, configuration);
|
|
await detectExternalModelWorkbook("project-1", new File([new Uint8Array([1, 2])], "sample.xlsx"), configuration);
|
|
assert.deepEqual(requests, [
|
|
{ url: "/api/projects/project-1/external-model/configuration", method: "GET", body: undefined },
|
|
{ url: "/api/projects/project-1/external-model/configuration", method: "PUT", body: { expectedRevision: 7, configuration } },
|
|
{ url: "/api/projects/project-1/external-model/configuration/detect", method: "POST", body: { fileName: "sample.xlsx", contentBase64: "AQI=", configuration } },
|
|
]);
|
|
} finally { globalThis.fetch = originalFetch; }
|
|
});
|
|
|
|
it("exposes the Revit route and removes the old project modal", () => {
|
|
const projectPage = readFileSync("src/app/projects/[projectId]/page.tsx", "utf8");
|
|
const revitPage = readFileSync("src/app/projects/[projectId]/revit/page.tsx", "utf8");
|
|
const settings = readFileSync("src/frontend/components/revit-xlsx-settings-modal.tsx", "utf8");
|
|
assert.match(projectPage, /href={`\/projects\/\$\{projectId\}\/revit`}/);
|
|
assert.doesNotMatch(projectPage, /RevitCsvModal|Revit-CSV/);
|
|
assert.match(revitPage, /Importstatus/);
|
|
assert.match(settings, /Musterdatei prüfen/);
|
|
assert.match(settings, /Kombinierte Stromkreisspalte/);
|
|
});
|
|
});
|