fix(a11y,e2e): 修 §14 定性出的 6 类功能 E2E 红,含一条 fail-open 与一处我自己造成的重复键
产品侧(真缺陷): - detail-trust-section 渲染绕过门槛(publishableCases 算了却仍 map caseStudies)⇒ 只要一条过闸,未授权/无 verified 的案例照样上线。改回 publishableCases.map, 新增 detail-trust-gate.test.tsx 3 例;变异验证:回退成 caseStudies.map ⇒ 2 条精确转红。 - 4 个文字链接触摸目标 23px < WCAG 2.5.8 的 24px(home 全部洞察/了解这一能力、 成果槽两条 CTA)⇒ 走间距刻度 min-h-6 补齐,不塞任意值。判据本身复跑通过。 - 首页能力面板 role=region 缺可访问名(landmark 无名;axe 的 landmark-name 属 best-practice 标签,我们的闸只跑 A/AA 所以没报)⇒ 补 aria-label。 - 登录限流额度改为可按环境覆盖(默认仍 10 次/15 分钟/IP,生产姿态不变); 真因:进程内内存桶 + dev server 跨整轮存活 ⇒ @admin 旅程第 11 次登录起必得 429, 即 §14 里「单跑绿、全量红」的机理。route.test.ts 加双向用例(未设=10;设 3 ⇒ 第 4 次限流)。 测试侧(锚点/引擎): - mobile.spec:45、website-acceptance:139 的重锚:锚点取自真源 navigation.ts (一级只剩 行业/能力/洞察/关于我们,联系入口是 consult-button 而非导航项)。 - p4:403 焦点管理:webkit/chromium-mobile 上 Tab 不落到链接(Safari 系需系统级 「Press Tab to highlight each item」,Playwright 起的 webkit 不带), 我先试 bringToFront + 点空白**没有用**,故改为同契约按引擎取证(chromium 走真实键盘 Tab,其余显式 focus 跳转链接),断言一条不减;复跑 webkit+mobile 2 passed。 - playwright.config.ts:我把 env 插成了重复键(TS1117),由本批新加的 type-check:e2e 当场抓到 ——这条闸的价值的又一次现场证明。已合并进既有 env 对象。 待办:全量功能 E2E 终跑(4 project)正在后台,读数与 PR 勾选项的复位随下一笔。
This commit is contained in:
1 parent
220ece524d
commit
1e80167b7c
41 files changed
+105
-13
No files matched your search
@@ -237,7 +237,7 @@ function InsightsBlock({ news, pageCopy }: { news?: NewsItem[]; pageCopy?: Recor
|
||||
</h2>
|
||||
<StaticLink
|
||||
href="/insights"
|
||||
className="inline-flex items-center gap-1 text-sm font-medium text-text-primary hover:text-brand-ink transition-colors duration-hover"
|
||||
className="min-h-6 inline-flex items-center gap-1 text-sm font-medium text-text-primary hover:text-brand-ink transition-colors duration-hover"
|
||||
>
|
||||
全部洞察
|
||||
<ArrowRight className="w-4 h-4" aria-hidden="true" />
|
||||
@@ -374,7 +374,7 @@ function CapabilitiesAccordion({ services }: { services?: CapabilityRow[] }) {
|
||||
</span>
|
||||
</button>
|
||||
{open && (
|
||||
<div id={`cap-panel-${id}`} role="region" className="pb-8 pl-[3.25rem] pr-2">
|
||||
<div id={`cap-panel-${id}`} role="region" aria-label={`${title} 能力详情`} className="pb-8 pl-[3.25rem] pr-2">
|
||||
<p className="text-sm text-text-secondary leading-relaxed max-w-2xl">
|
||||
{String(s.description ?? '')}
|
||||
</p>
|
||||
@@ -387,7 +387,7 @@ function CapabilitiesAccordion({ services }: { services?: CapabilityRow[] }) {
|
||||
)}
|
||||
<StaticLink
|
||||
href={`/services/${id}`}
|
||||
className="mt-6 inline-flex items-center gap-1 text-sm font-medium text-brand-ink hover:text-brand-ink-hover transition-colors duration-hover"
|
||||
className="mt-6 min-h-6 inline-flex items-center gap-1 text-sm font-medium text-brand-ink hover:text-brand-ink-hover transition-colors duration-hover"
|
||||
>
|
||||
了解这一能力
|
||||
<ArrowRight className="w-4 h-4" aria-hidden="true" />
|
||||
|
||||
@@ -173,3 +173,32 @@ describe('POST /api/auth/login', () => {
|
||||
expect(mockVerifyPassword).toHaveBeenCalledTimes(10);
|
||||
});
|
||||
});
|
||||
|
||||
describe('登录限流额度:默认值与 dev 覆盖(双向用例,§14)', () => {
|
||||
const original = process.env.LOGIN_RATE_LIMIT_MAX;
|
||||
|
||||
afterEach(() => {
|
||||
if (original === undefined) delete process.env.LOGIN_RATE_LIMIT_MAX;
|
||||
else process.env.LOGIN_RATE_LIMIT_MAX = original;
|
||||
jest.resetModules();
|
||||
});
|
||||
|
||||
it('未设环境变量 ⇒ 默认 10(生产姿态一字不动)', async () => {
|
||||
delete process.env.LOGIN_RATE_LIMIT_MAX;
|
||||
jest.resetModules();
|
||||
const mod = await import('./route');
|
||||
expect(mod.LOGIN_RATE_LIMIT_MAX).toBe(10);
|
||||
});
|
||||
|
||||
it('设成 3 ⇒ 取 3,且第 4 次判定为限流(证明覆盖真生效,不是只读了个常量)', async () => {
|
||||
process.env.LOGIN_RATE_LIMIT_MAX = '3';
|
||||
jest.resetModules();
|
||||
const mod = await import('./route');
|
||||
expect(mod.LOGIN_RATE_LIMIT_MAX).toBe(3);
|
||||
const ip = '203.0.113.99';
|
||||
for (let i = 0; i < 3; i += 1) {
|
||||
expect(mod.loginRateLimiter.isLimited(ip)).toBe(false);
|
||||
}
|
||||
expect(mod.loginRateLimiter.isLimited(ip)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -12,9 +12,18 @@ const TIMING_EQUALIZER_HASH = '$2b$10$VUixc994Qoz7jP1YEF2v/Oo9wc0uojx05w0cQIbcMo
|
||||
// 登录端点此前无任何限流:匿名者可无限驱动 cost-10 bcrypt(CPU DoS)并离线式撞库。
|
||||
// 按 IP 限流(不锁账号),与 contact 同姿态;判定在 bcrypt 之前,才真正省掉工作量。
|
||||
// 导出以便测试跨用例 reset()。
|
||||
//
|
||||
// 额度可按环境覆盖(默认仍是 10 —— 生产姿态一字不动):
|
||||
// 这是**进程内内存桶**,而 E2E 的 dev/standalone server 跨整轮用例存活,
|
||||
// `@admin` 旅程每条都各自登录一次 ⇒ 全量功能 E2E 里第 11 次起必得 429,
|
||||
// 表现为「单跑绿、全量红」(§14 的 UJ-03/06/07 就是这个,而不是登录逻辑坏了)。
|
||||
// 因此只在 e2e harness 里把上限抬到几百次;判定路径与默认值由
|
||||
// `route.test.ts` 的双向用例钉住(未设环境变量 ⇒ 10;设了 ⇒ 取该值)。
|
||||
export const LOGIN_RATE_LIMIT_MAX = Number(process.env.LOGIN_RATE_LIMIT_MAX ?? 10);
|
||||
|
||||
export const loginRateLimiter = createMemoryRateLimiter({
|
||||
windowMs: 15 * 60 * 1000,
|
||||
max: 10,
|
||||
max: LOGIN_RATE_LIMIT_MAX,
|
||||
});
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
|
||||
@@ -213,14 +213,14 @@ function EmptyTreatments({
|
||||
<div className="mt-8 flex flex-wrap gap-4">
|
||||
<StaticLink
|
||||
href={href}
|
||||
className="inline-flex items-center gap-1 text-sm font-medium text-text-primary hover:text-brand-ink transition-colors duration-hover"
|
||||
className="min-h-6 inline-flex items-center gap-1 text-sm font-medium text-text-primary hover:text-brand-ink transition-colors duration-hover"
|
||||
>
|
||||
看我们怎么证明过程可控
|
||||
<ArrowRight className="w-4 h-4" aria-hidden="true" />
|
||||
</StaticLink>
|
||||
<StaticLink
|
||||
href="/contact"
|
||||
className="inline-flex items-center gap-1 text-sm font-medium text-brand-ink hover:text-brand-ink-hover transition-colors duration-hover"
|
||||
className="min-h-6 inline-flex items-center gap-1 text-sm font-medium text-brand-ink hover:text-brand-ink-hover transition-colors duration-hover"
|
||||
>
|
||||
成为首批共创客户
|
||||
</StaticLink>
|
||||
|
||||
Reference in new issue
Block a user