import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; import test from 'node:test'; import { fileURLToPath } from 'node:url'; const here = path.dirname(fileURLToPath(import.meta.url)); void test('projectState: list/get after delete invalidates in-flight initial load (epoch guard)', () => { const src = fs.readFileSync(path.join(here, 'projectState.ts'), 'utf8'); assert.match(src, /projectDataEpochRef/); assert.match(src, /const epoch = projectDataEpochRef\.current/); assert.match(src, /if \(projectDataEpochRef\.current !== epoch\) return/); assert.match( src, /const deleteProject = async[\s\S]+?projectDataEpochRef\.current \+= 1[\s\S]+?await api\.invoke/, ); assert.match( src, /const openProject = async[\s\S]+?projectDataEpochRef\.current \+= 1[\s\S]+?await api\.invoke/, ); assert.match(src, /const refreshProjects = async \(\) => \{[\s\S]+?projectDataEpochRef\.current \+= 1/); });