Files
DndGamePlayer/app/main/project/zipStore.legacyContract.test.ts
T
Ivan Fontosh f823a7c05f fix(project): prevent deleted projects from resurrecting
- Migrate legacy project zips by moving instead of copying
- Remove legacy zip copies on project delete
- Add contract test for legacy migration/delete behavior

Made-with: Cursor
2026-04-22 15:29:22 +08:00

26 lines
1.2 KiB
TypeScript

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('zipStore: deleteProjectById removes legacy sibling copies by entry.fileName', () => {
const src = fs.readFileSync(path.join(here, 'zipStore.ts'), 'utf8');
assert.match(src, /async deleteProjectById/);
assert.match(src, /for \(const legacyRoot of getLegacyProjectsRootDirs\(\)\)/);
assert.match(src, /path\.join\(legacyRoot, entry\.fileName\)/);
assert.match(src, /rmWithRetries\(fs\.rm, legacyZipPath, \{ force: true \}\)/);
});
void test('zipStore: legacy migration moves or copy\\+rm so deleted projects are not resurrected', () => {
const src = fs.readFileSync(path.join(here, 'zipStore.ts'), 'utf8');
assert.match(src, /migrateLegacyProjectZipsIfNeeded/);
assert.match(src, /if \(destZips\.has\(name\)\) continue/);
assert.match(src, /await fs\.rename\(from, to\)/);
assert.match(src, /await fs\.copyFile\(from, to\)/);
assert.match(src, /rmWithRetries\(fs\.rm, from, \{ force: true \}\)/);
assert.match(src, /не «возрождались»/);
});