Files
EasyFlow/easyflow-ui-admin/app/src/startup-error.test.ts
陈子默 da59c713f9 fix: 提升管理端启动与导航稳定性
- 等待初始路由就绪并提供可恢复的启动失败页面

- 收敛失效登录导航并按需加载 SVG 图标资源
2026-07-24 19:02:28 +08:00

28 lines
881 B
TypeScript

import { afterEach, describe, expect, it, vi } from 'vitest';
import { renderStartupError } from './startup-error';
describe('startup error fallback', () => {
afterEach(() => {
document.body.replaceChildren();
});
it('renders a recoverable error state and reloads on demand', () => {
const root = document.createElement('div');
const reload = vi.fn();
document.body.append(root);
expect(renderStartupError({ reload, root })).toBe(true);
expect(root.querySelector('[role="alert"]')).not.toBeNull();
expect(root.textContent).toContain('页面加载失败');
const retryButton = root.querySelector<HTMLButtonElement>('button');
retryButton?.click();
expect(reload).toHaveBeenCalledOnce();
});
it('returns false when the application root is missing', () => {
expect(renderStartupError({ root: null })).toBe(false);
});
});