d94a11d466
RotatedImage: размер контейнера через clientWidth/Height (не getBoundingClientRect), чтобы cover при 90°/270° работал под zoom React Flow; убраны отладочные логи. Главное меню в dev: пункт «Вид» с DevTools (Ctrl+Shift+I без пустого application menu). Список проектов: project.list без лицензии; список подгружается при неактивной лицензии; ProjectPicker с подсказками; listProjects пропускает битые zip. Сохранение проектов: atomicReplace — замена zip без rm до commit; восстановление *.dnd.zip.tmp при старте; тесты. EditorApp: блокировка UI при открытых окнах презентации и пульта; стили оверлея. Made-with: Cursor
67 lines
3.2 KiB
TypeScript
67 lines
3.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, /не «возрождались»/);
|
|
});
|
|
|
|
void test('zipStore: openProjectById flushes pending saveNow before cache reset', () => {
|
|
const src = fs.readFileSync(path.join(here, 'zipStore.ts'), 'utf8');
|
|
// When switching projects we rm cacheDir and unzip zip; ensure pending debounced pack is flushed first.
|
|
assert.match(src, /async openProjectById/);
|
|
assert.match(src, /if \(this\.openProject\)\s*\{\s*await this\.saveNow\(\);\s*\}/);
|
|
assert.match(src, /await fs\.rm\(cacheDir, \{ recursive: true, force: true \}\)/);
|
|
assert.match(src, /await unzipToDir\(zipPath, cacheDir\)/);
|
|
});
|
|
|
|
void test('zipStore: exportProjectZipToPath flushes saveNow for currently open project', () => {
|
|
const src = fs.readFileSync(path.join(here, 'zipStore.ts'), 'utf8');
|
|
assert.match(src, /async exportProjectZipToPath/);
|
|
assert.match(src, /if \(this\.openProject\?\.id === projectId\)\s*\{\s*await this\.saveNow\(\);\s*\}/);
|
|
assert.match(src, /await fs\.copyFile\(src, dest\)/);
|
|
});
|
|
|
|
void test('zipStore: normalizeScene defaults previewThumbAssetId for older projects', () => {
|
|
const src = fs.readFileSync(path.join(here, 'zipStore.ts'), 'utf8');
|
|
assert.match(src, /previewThumbAssetId/);
|
|
assert.match(src, /function normalizeScene\(/);
|
|
});
|
|
|
|
void test('zipStore: listProjects skips unreadable archives', () => {
|
|
const src = fs.readFileSync(path.join(here, 'zipStore.ts'), 'utf8');
|
|
assert.match(
|
|
src,
|
|
/async listProjects[\s\S]+?for \(const filePath of files\)[\s\S]+?try \{[\s\S]+?readProjectJsonFromZip/,
|
|
);
|
|
});
|
|
|
|
void test('atomicReplace: replaceFileAtomic must not rm destination before successful commit', () => {
|
|
const src = fs.readFileSync(path.join(here, 'atomicReplace.ts'), 'utf8');
|
|
const i = src.indexOf('export async function replaceFileAtomic');
|
|
assert.ok(i >= 0);
|
|
const j = src.indexOf('export async function recoverOrphanDndZipTmpInRoot', i);
|
|
assert.ok(j > i);
|
|
const block = src.slice(i, j);
|
|
assert.match(block, /rename\(finalPath, backupPath\)/);
|
|
assert.doesNotMatch(block, /\.rm\(\s*finalPath/);
|
|
});
|