Include external models in project snapshots
This commit is contained in:
@@ -32,6 +32,12 @@ function minimalSnapshot() {
|
||||
},
|
||||
distributionBoards: [],
|
||||
externalCsvConfiguration: null,
|
||||
externalModel: {
|
||||
source: null,
|
||||
importBatches: [],
|
||||
roomMappings: [],
|
||||
objects: [],
|
||||
},
|
||||
circuitLists: [],
|
||||
circuitSections: [],
|
||||
distributionBoardComponents: [],
|
||||
@@ -149,6 +155,7 @@ describe("project state snapshot model", () => {
|
||||
baseline.schemaVersion = 1 as typeof baseline.schemaVersion;
|
||||
delete (baseline.project as Record<string, unknown>).isPublicBuilding;
|
||||
delete (baseline as Record<string, unknown>).externalCsvConfiguration;
|
||||
delete (baseline as Record<string, unknown>).externalModel;
|
||||
|
||||
const upgraded = parseProjectStateSnapshot(baseline);
|
||||
|
||||
@@ -161,11 +168,35 @@ describe("project state snapshot model", () => {
|
||||
const previous = structuredClone(minimalSnapshot());
|
||||
previous.schemaVersion = 2 as typeof previous.schemaVersion;
|
||||
delete (previous as Record<string, unknown>).externalCsvConfiguration;
|
||||
delete (previous as Record<string, unknown>).externalModel;
|
||||
|
||||
const upgraded = parseProjectStateSnapshot(previous);
|
||||
|
||||
assert.equal(upgraded.schemaVersion, projectStateSnapshotSchemaVersion);
|
||||
assert.equal(upgraded.externalCsvConfiguration, null);
|
||||
assert.deepEqual(upgraded.externalModel, {
|
||||
source: null,
|
||||
importBatches: [],
|
||||
roomMappings: [],
|
||||
objects: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("upgrades snapshot version 3 with an empty external model", () => {
|
||||
const previous = structuredClone(minimalSnapshot());
|
||||
previous.schemaVersion = 3 as typeof previous.schemaVersion;
|
||||
delete (previous as Record<string, unknown>).externalModel;
|
||||
|
||||
const upgraded = parseProjectStateSnapshot(previous);
|
||||
|
||||
assert.equal(upgraded.schemaVersion, projectStateSnapshotSchemaVersion);
|
||||
assert.equal(upgraded.externalCsvConfiguration, null);
|
||||
assert.deepEqual(upgraded.externalModel, {
|
||||
source: null,
|
||||
importBatches: [],
|
||||
roomMappings: [],
|
||||
objects: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects malformed baseline and unknown snapshot shapes", () => {
|
||||
|
||||
Reference in New Issue
Block a user