Files
DndGamePlayer/app/renderer/shared/useAssetImageUrl.cache.test.ts
Ivan Fontosh d9fbecf5a7 perf: cut ControlApp re-renders and lazy-load VFX packs
Move audio scrub/volume and brush drafts off root React ticks, coalesce overlay layout IPC, cache machine fingerprint and asset URLs, share one scene overlay host, and stop idle Pixi ticker. Also harden console against EPIPE on window load failures.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-23 11:58:16 +08:00

25 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));
/** Регресс: списки сцен/материалов не должны дёргать assetFileUrl на каждый mount одного id. */
void test('useAssetUrl: module cache + invalidate при смене проекта', () => {
const src = fs.readFileSync(path.join(here, 'useAssetImageUrl.ts'), 'utf8');
const projectState = fs.readFileSync(path.join(here, '../editor/state/projectState.ts'), 'utf8');
assert.ok(src.includes('urlCache'));
assert.ok(src.includes('invalidateAssetUrlCache'));
assert.ok(src.includes('peekAssetUrlCache'));
assert.ok(src.includes('session.stateChanged'));
assert.match(src, /urlCache\.set\(id,\s*r\.url\)/);
assert.match(src, /peekAssetUrlCache\(id\)/);
assert.ok(projectState.includes('invalidateAssetUrlCache'));
assert.match(projectState, /openProject[\s\S]*?invalidateAssetUrlCache\(\)/);
assert.match(projectState, /closeProject[\s\S]*?invalidateAssetUrlCache\(\)/);
});