4631a1bece
Add darkenScene with Opening brush in presentation, persist reveal strokes per scene during a session, and close projects properly on return to home. Harden dnd asset streaming to avoid Windows main-process crashes when reopening projects. Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { SceneDarknessStore } from './sceneDarknessStore';
|
|
|
|
void test('SceneDarknessStore: сохраняет штрихи при переключении сцен', () => {
|
|
const store = new SceneDarknessStore();
|
|
store.switchScene('scene_a', true);
|
|
store.dispatch({
|
|
kind: 'stroke.add',
|
|
stroke: {
|
|
id: 's1',
|
|
seed: 1,
|
|
createdAtMs: 100,
|
|
points: [{ x: 0.5, y: 0.5, tMs: 100 }],
|
|
radiusN: 0.08,
|
|
},
|
|
});
|
|
|
|
store.switchScene('scene_b', true);
|
|
assert.equal(store.getState().strokes.length, 0);
|
|
|
|
store.switchScene('scene_a', true);
|
|
assert.equal(store.getState().strokes.length, 1);
|
|
assert.equal(store.getState().strokes[0]?.id, 's1');
|
|
});
|
|
|
|
void test('SceneDarknessStore: resetSession очищает кэш', () => {
|
|
const store = new SceneDarknessStore();
|
|
store.switchScene('scene_a', true);
|
|
store.dispatch({
|
|
kind: 'stroke.add',
|
|
stroke: {
|
|
id: 's1',
|
|
seed: 1,
|
|
createdAtMs: 100,
|
|
points: [{ x: 0.2, y: 0.2, tMs: 100 }],
|
|
radiusN: 0.08,
|
|
},
|
|
});
|
|
store.resetSession();
|
|
store.switchScene('scene_a', true);
|
|
assert.equal(store.getState().strokes.length, 0);
|
|
});
|
|
|
|
void test('SceneDarknessStore: draft синхронизируется и сбрасывается при commit', () => {
|
|
const store = new SceneDarknessStore();
|
|
store.switchScene('scene_a', true);
|
|
store.dispatch({
|
|
kind: 'draft.set',
|
|
draft: { points: [{ x: 0.1, y: 0.1, tMs: 1 }], radiusN: 0.05 },
|
|
});
|
|
assert.ok(store.getState().draft);
|
|
store.dispatch({
|
|
kind: 'stroke.add',
|
|
stroke: {
|
|
id: 's1',
|
|
seed: 1,
|
|
createdAtMs: 100,
|
|
points: [{ x: 0.1, y: 0.1, tMs: 1 }],
|
|
radiusN: 0.05,
|
|
},
|
|
});
|
|
assert.equal(store.getState().draft, null);
|
|
assert.equal(store.getState().strokes.length, 1);
|
|
});
|