refactor: strengthen client boundaries and quality gates

This commit is contained in:
hectorzhao
2026-08-28 14:26:58 +08:00
parent 3af145abe5
commit ad27acad7e
51 changed files with 7703 additions and 697 deletions
+29
View File
@@ -0,0 +1,29 @@
import { render, screen } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
import { RouteLoadBoundary } from './RouteLoadBoundary';
function BrokenRoute(): never {
throw new Error('chunk load failed');
}
describe('RouteLoadBoundary', () => {
it('shows a recoverable Chinese error state when a route chunk throws', () => {
vi.spyOn(console, 'error').mockImplementation(() => undefined);
render(
<RouteLoadBoundary>
<BrokenRoute />
</RouteLoadBoundary>,
);
expect(screen.getByRole('alert')).toHaveTextContent('页面资源加载失败');
expect(screen.getByRole('button', { name: '重新加载' })).toBeEnabled();
});
it('renders healthy route content unchanged', () => {
render(
<RouteLoadBoundary>
<p></p>
</RouteLoadBoundary>,
);
expect(screen.getByText('正常页面')).toBeVisible();
});
});