fix(data): 增加全局保存失败保护
This commit is contained in:
18
apps/web/lib/server-data-save-error-source.test.ts
Normal file
18
apps/web/lib/server-data-save-error-source.test.ts
Normal 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 \/>/);
|
||||
});
|
||||
Reference in New Issue
Block a user