Session, project, and deliverable caches were written from scattered effects, and the legacy message migration ran twice on mount. One hook keeps that write path in a single place. Co-authored-by: Cursor <cursoragent@cursor.com>
17 lines
912 B
TypeScript
17 lines
912 B
TypeScript
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import test from 'node:test';
|
|
|
|
test('App persists workbench state through one hook and migrates legacy messages once', () => {
|
|
const app = readFileSync(new URL('../App.tsx', import.meta.url), 'utf8');
|
|
const hook = readFileSync(new URL('./useWorkbenchPersistence.ts', import.meta.url), 'utf8');
|
|
assert.equal((app.match(/useWorkbenchPersistence\(/g) || []).length, 1);
|
|
assert.equal(app.includes('migrateAndClearLegacyMessages'), false);
|
|
assert.equal(app.includes('saveSessions('), false);
|
|
assert.equal(app.includes('saveProjects('), false);
|
|
for (const name of ['saveSessions', 'saveProjects', 'saveDeliverables', 'saveUsers', 'migrateAndClearLegacyMessages']) {
|
|
assert.equal(hook.includes(name), true, `hook missing ${name}`);
|
|
}
|
|
assert.equal((hook.match(/migrateAndClearLegacyMessages/g) || []).length, 2);
|
|
});
|