mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-01 14:46:36 +08:00
axe a11y 审计扩展到登录 OTP 验证表单(input-otp 分段输入,FieldLabel htmlFor 正确关联,零违规)与人机验证小部件手动模式(零违规)。环境修复:tests/setup.ts 加 ResizeObserver mock(input-otp 依赖,jsdom 未内置)。vitest 118→120 全绿。
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":120,"measure_s":71}
This commit is contained in:
@@ -6,6 +6,8 @@ import axe from 'axe-core';
|
||||
|
||||
import { LoginPage } from '@/components/auth/login-page';
|
||||
import { RegisterPage } from '@/components/auth/register-page';
|
||||
import { OTPForm } from '@/components/auth/otp-form';
|
||||
import { CapWidget } from '@/components/auth/cap-widget';
|
||||
import { UserProvider } from '@/contexts/user-context';
|
||||
import zhCN from '@/messages/zh-CN.json';
|
||||
|
||||
@@ -100,4 +102,30 @@ describe('a11y(axe-core 结构性规则)', () => {
|
||||
await screen.findByRole('button', { name: /创建账号|submit/ });
|
||||
expect(await runAxe(document.body)).toEqual([]);
|
||||
});
|
||||
|
||||
it('登录 OTP 验证表单无 axe 违规', async () => {
|
||||
renderWithProviders(
|
||||
<main>
|
||||
<OTPForm
|
||||
code=''
|
||||
setCode={() => {}}
|
||||
loginCodeTip='验证码已发送至邮箱'
|
||||
loginCooldown={0}
|
||||
isPending={false}
|
||||
onResend={() => {}}
|
||||
onSubmit={() => {}}
|
||||
/>
|
||||
</main>,
|
||||
);
|
||||
|
||||
await screen.findByRole('button', { name: /重新发送/ });
|
||||
expect(await runAxe(document.body)).toEqual([]);
|
||||
});
|
||||
|
||||
it('人机验证小部件(手动模式)无 axe 违规', async () => {
|
||||
renderWithProviders(<main><CapWidget autoStart={false} onToken={() => {}} /></main>);
|
||||
|
||||
await screen.findByRole('button');
|
||||
expect(await runAxe(document.body)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
import '@testing-library/jest-dom/vitest';
|
||||
|
||||
// input-otp(登录 OTP 组件)依赖 ResizeObserver,jsdom 未内置
|
||||
class ResizeObserverMock {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
}
|
||||
if (typeof globalThis.ResizeObserver === 'undefined') {
|
||||
globalThis.ResizeObserver = ResizeObserverMock as unknown as typeof ResizeObserver;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user