Files
novalon-website/src/app/global-error.test.tsx
T
zhangxiang a366bd1400 fix(qa): 第五轮系统性质量保障缺陷修复 + 单元/集成测试
安全/鉴权:登出清服务端 httpOnly 令牌、登录 IP 限流前置 bcrypt、停用账号
令牌在 6 个内联 role handler 失效、admin/items 存在性 oracle 认证前置、
同意偏好 sanitize fail-closed、api-crypto 按 HTTP 方法判体。

CMS:workflow 状态更新+审计收进交互式 $transaction(失败即回滚)、编辑器
richtext 走 textarea 防换行损毁、array/object 子字段按作用域读写防污染、
about/contact/erp-upgrade 补 ISR revalidate 与路由映射。

UI/a11y:AnimatedCounter 入视口前显起点、CLS 累计上报、MetricCard 动画入
effect 并卸载取消 rAF、后台状态四态映射/搜索防抖+序号守卫/媒体单 input/
吞错改横幅/表单 label-aria 关联。

新增对应判别性单测与 pagination/rate-limit/client-ip/sanitize/validate-content-data
等模块及 tests-integration 真库集成层。
2026-09-28 10:48:07 +08:00

34 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* PR-NEXT: 追加 src/app/global-error.tsx 的回归测试
*/
import { render, screen, fireEvent } from '@testing-library/react';
import GlobalError from './global-error';
describe('GlobalError - 根布局错误兜底页', () => {
it('自带文档壳并声明中文语言(axe html-has-lang)', () => {
const { container } = render(
<GlobalError error={Object.assign(new Error('boom'), { digest: 'd-1' })} retry={jest.fn()} />
);
const html = container.querySelector('html');
expect(html).not.toBeNull();
expect(html).toHaveAttribute('lang', 'zh-CN');
expect(container.querySelector('body')).not.toBeNull();
expect(container.querySelector('title')?.textContent).toContain('四川睿新致远科技有限公司');
});
it('给出可操作出口且重试按钮接线到 retry', () => {
const retry = jest.fn();
render(<GlobalError error={Object.assign(new Error('boom'), { digest: undefined })} retry={retry} />);
fireEvent.click(screen.getByRole('button', { name: '重试' }));
expect(retry).toHaveBeenCalledTimes(1);
expect(screen.getByRole('link', { name: '返回首页' })).toHaveAttribute('href', '/');
});
it('有 digest 时展示错误编号,供工单定位', () => {
render(
<GlobalError error={Object.assign(new Error('boom'), { digest: 'abc123' })} retry={jest.fn()} />
);
expect(screen.getByText(/abc123/)).toBeInTheDocument();
});
});