fix: 提升管理端启动与导航稳定性
- 等待初始路由就绪并提供可恢复的启动失败页面 - 收敛失效登录导航并按需加载 SVG 图标资源
This commit is contained in:
27
easyflow-ui-admin/app/src/startup-error.test.ts
Normal file
27
easyflow-ui-admin/app/src/startup-error.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user