fix(data): 增加全局保存失败保护

This commit is contained in:
Script Generator
2026-07-03 19:36:18 +08:00
parent 516a5f1b63
commit b4a3c990b4
17 changed files with 727 additions and 132 deletions

View File

@@ -0,0 +1,18 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import test from 'node:test';
test('server data save failures are surfaced through a global browser event', () => {
const source = readFileSync(join(process.cwd(), 'lib/server-data.ts'), 'utf8');
assert.match(source, /export const SERVER_DATA_SAVE_ERROR_EVENT = 'ftb:server-data-save-error';/);
assert.match(source, /window\.dispatchEvent\(\s*new CustomEvent\(SERVER_DATA_SAVE_ERROR_EVENT/);
});
test('layout shell renders the global server data save error banner', () => {
const source = readFileSync(join(process.cwd(), 'components/layout/LayoutShell.tsx'), 'utf8');
assert.match(source, /import \{ ServerDataSaveErrorBanner \} from '@\/components\/ServerDataSaveErrorBanner';/);
assert.match(source, /<ServerDataSaveErrorBanner \/>/);
});