Sprint 2: wire React workflows, store lifecycle, and interactive canvas
CI / test (push) Waiting to run
CI / test (push) Waiting to run
This commit is contained in:
1 parent
d029e480d0
commit
5a4e116475
12 files changed
+1098
-75
No files matched your search
@@ -120,3 +120,46 @@ test("transaction scaffold groups multiple actions into one undo step", () => {
|
||||
assert.equal(u1.placement.x, null);
|
||||
assert.equal(u1.placement.y, null);
|
||||
});
|
||||
|
||||
test("compile lifecycle state transitions are deterministic", () => {
|
||||
const storeA = createSchemetaStore();
|
||||
const storeB = createSchemetaStore();
|
||||
|
||||
storeA.actions.beginCompile("Compile");
|
||||
storeA.actions.failCompile("Compile", "Bad payload");
|
||||
storeA.actions.beginCompile("Analyze");
|
||||
storeA.actions.completeCompile("Analyze");
|
||||
|
||||
storeB.actions.beginCompile("Compile");
|
||||
storeB.actions.failCompile("Compile", "Bad payload");
|
||||
storeB.actions.beginCompile("Analyze");
|
||||
storeB.actions.completeCompile("Analyze");
|
||||
|
||||
assert.deepEqual(storeA.getState().lifecycle, storeB.getState().lifecycle);
|
||||
assert.equal(storeA.getState().lifecycle.isCompiling, false);
|
||||
assert.equal(storeA.getState().lifecycle.lastError, null);
|
||||
assert.equal(storeA.getState().lifecycle.lastAction, "Analyze");
|
||||
});
|
||||
|
||||
test("compile lifecycle updates do not alter undo/redo history", () => {
|
||||
const store = createSchemetaStore();
|
||||
store.actions.setModel(baseModel());
|
||||
store.actions.moveComponent("U1", { x: 90, y: 70 });
|
||||
|
||||
const beforeUndo = store.getState();
|
||||
const pastBeforeLifecycle = beforeUndo.history.past.length;
|
||||
|
||||
store.actions.beginCompile("Compile");
|
||||
store.actions.failCompile("Compile", "Synthetic error");
|
||||
store.actions.beginCompile("Compile");
|
||||
store.actions.completeCompile("Compile");
|
||||
|
||||
assert.equal(store.getState().history.past.length, pastBeforeLifecycle);
|
||||
assert.equal(store.getState().lifecycle.lastAction, "Compile");
|
||||
assert.equal(store.getState().lifecycle.lastError, null);
|
||||
|
||||
store.actions.undo();
|
||||
const u1 = store.getState().model.instances.find((x) => x.ref === "U1");
|
||||
assert.equal(u1.placement.x, null);
|
||||
assert.equal(u1.placement.y, null);
|
||||
});
|
||||
Reference in new issue
Block a user