mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
axe a11y 审计扩展到最复杂认证路径:注册页开启人机验证(CapWidget 自动求解→已通过状态 + 完整表单),mock getCapToken 避免 jsdom 无 Worker 环境限制。零违规。vitest 120→121 全绿。
Result: {"status":"keep","total_issues":8,"golint_canonicalheader":0,"golint_errname":0,"golint_errorlint":1,"golint_exhaustive":0,"golint_forcetypeassert":0,"golint_gosec":0,"golint_intrange":0,"golint_modernize":3,"golint_nilnil":3,"golint_perfsprint":0,"golint_prealloc":0,"golint_recvcheck":1,"golint_usestdlibvars":0,"golint_wastedassign":0,"golint_total":8,"golint_test_testifylint":0,"golint_test_thelper":0,"golint_test_usetesting":0,"golint_test_total":0,"golint_vetx_total":0,"eslint_problems":0,"eslint_errors":0,"eslint_warnings":0,"tsc_errors":0,"vitest_failed":0,"vitest_total":121,"measure_s":71}
This commit is contained in:
@@ -35,6 +35,10 @@ vi.mock('@/lib/services/auth', async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock('@/lib/cap-solver', () => ({
|
||||
getCapToken: vi.fn().mockResolvedValue('test-cap-token'),
|
||||
}));
|
||||
|
||||
vi.mock('@/lib/services/config', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/lib/services/config')>();
|
||||
return {
|
||||
@@ -128,4 +132,19 @@ describe('a11y(axe-core 结构性规则)', () => {
|
||||
await screen.findByRole('button');
|
||||
expect(await runAxe(document.body)).toEqual([]);
|
||||
});
|
||||
|
||||
it('注册页(开启人机验证)无 axe 违规', async () => {
|
||||
getPublicConfigMock.mockResolvedValue({
|
||||
registration_enabled: 'true',
|
||||
password_register_enabled: 'true',
|
||||
cap_login_enabled: 'true',
|
||||
cap_auto_solve: 'true',
|
||||
});
|
||||
renderWithProviders(<RegisterPage />);
|
||||
|
||||
await screen.findByRole('button', { name: /创建账号|submit/ });
|
||||
// CAPTCHA 自动求解完成后进入已通过状态
|
||||
await screen.findByText('人机验证通过');
|
||||
expect(await runAxe(document.body)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user