Add Revit CSV project dialog
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import {
|
||||
getExternalCsvConfiguration,
|
||||
previewExternalCsv,
|
||||
updateExternalCsvConfiguration,
|
||||
} from "../src/frontend/utils/api.js";
|
||||
import { createDefaultExternalCsvConfiguration } from "../src/external-model/csv/external-csv-contracts.js";
|
||||
import { externalCsvTestColumns } from "./fixtures/revit-csv-fixtures.js";
|
||||
|
||||
describe("Revit CSV frontend API", () => {
|
||||
it("uses the project-scoped configuration and preview endpoints", 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)) : null,
|
||||
});
|
||||
return new Response(JSON.stringify({ configuration: null }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
};
|
||||
const configuration = createDefaultExternalCsvConfiguration(externalCsvTestColumns);
|
||||
|
||||
try {
|
||||
await getExternalCsvConfiguration("project-1");
|
||||
await updateExternalCsvConfiguration("project-1", 7, configuration);
|
||||
await previewExternalCsv("project-1", "revit.csv", "YWJj");
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
|
||||
assert.deepEqual(requests, [
|
||||
{
|
||||
url: "/api/projects/project-1/external-csv/configuration",
|
||||
method: "GET",
|
||||
body: null,
|
||||
},
|
||||
{
|
||||
url: "/api/projects/project-1/external-csv/configuration",
|
||||
method: "PUT",
|
||||
body: { expectedRevision: 7, configuration },
|
||||
},
|
||||
{
|
||||
url: "/api/projects/project-1/external-csv/preview",
|
||||
method: "POST",
|
||||
body: { fileName: "revit.csv", contentBase64: "YWJj" },
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user