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 勾选项的复位随下一笔。
No files matched your search
@@ -51,7 +51,12 @@ test.describe('移动端导航 - 汉堡菜单 @mobile @regression', () => {
|
||||
await expect(mobileNav).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// 检查关键导航项
|
||||
const expectedLinks = ['产品', '解决方案', '服务', '关于我们', '联系我们'];
|
||||
// 锚点取自实测真源(§11.3 同一手法):一级导航在 ADR-0008 决策二改成双轴后,
|
||||
// NAVIGATION_V2 只有 行业 / 能力 / 洞察 / 关于我们 四项
|
||||
// (src/lib/constants/navigation.ts),旧断言里的「产品 / 解决方案 / 服务」是上一版 IA 的标签;
|
||||
// 「联系我们」也不是第六个阅读项 —— 顶栏与抽屉里的入口都写作「预约咨询」
|
||||
// (header.tsx:165 与 :299,注释明写它是咨询按钮而非导航项)。
|
||||
const expectedLinks = ['行业', '能力', '洞察', '关于我们', '预约咨询'];
|
||||
for (const linkText of expectedLinks) {
|
||||
const link = mobileNav.locator(`text=${linkText}`).first();
|
||||
await expect(link).toBeVisible({ timeout: 5000 });
|
||||
|
||||
@@ -608,9 +608,25 @@ test.describe('P1: 品牌视觉审计 - 特殊场景覆盖', { tag: '@regression
|
||||
).toBe(false);
|
||||
}
|
||||
|
||||
// 首页确实渲染 blockquote(social-proof-section.tsx:102),因此零命中就是契约被破坏,
|
||||
// 不能像旧实现那样走「catch + console.log」静默通过(§5.21)
|
||||
expect(checked, '未找到任何可见的客户评价区域,本用例等于零断言').toBeGreaterThan(0);
|
||||
// 前提修正(2026-10-17,随 §14 定性):原地板断言是「首页必然渲染 blockquote」,
|
||||
// 依据写的是 social-proof-section.tsx:102 —— 那个组件在本树已经不存在(grep 为空),
|
||||
// 而 ADR-0008 决策三把首页成果区换成了 ResultsSlot:case-study 模型 0 行时
|
||||
// **保留形状、写清状态**(prisma/seeds/case-studies.ts:11 明示「暂无对外可验证的客户案例」)。
|
||||
// ⇒ 「必须找到一条证言」这个契约已被裁定作废:我们拒绝伪造证言。
|
||||
// 本例因此换成两条同样可失败、且不依赖伪造内容的断言:
|
||||
// ① 成果区必须以**可见的空态**在场(形状保留 + 文案写清状态),不是整段消失;
|
||||
// ② 页面上任何 blockquote(将来真有授权案例上线时)都不得含非法 "novalon" 文本。
|
||||
// 反向自证:把空态文案或成果区删掉 ⇒ ①转红;伪造一条含 novalon 的证言 ⇒ ②转红。
|
||||
const slot = page.locator('[data-testid^="results-slot-"]').first();
|
||||
await expect(slot, '首页成果区必须存在(零编造裁定保留形状,不允许整段消失)').toBeVisible();
|
||||
await expect(
|
||||
page.getByText('还没有可以公开的成果'),
|
||||
'成果区必须肉眼可见是空态,不能被读成客户案例',
|
||||
).toBeVisible();
|
||||
|
||||
// 地板:要么扫到了可见证言(并已在上面逐条验过禁词),要么空态断言成立。
|
||||
// 二者皆无 = 契约被破坏,本例不退化成零断言(§5.21 的纪律原样保留)。
|
||||
expect(checked > 0 || (await slot.count()) > 0).toBe(true);
|
||||
});
|
||||
|
||||
test('打印视图品牌信息保留', async ({ page }) => {
|
||||
|
||||
@@ -354,6 +354,13 @@ test.describe("可访问性 - WCAG 2.1 AA 合规", { tag: "@regression" }, () =>
|
||||
"link",
|
||||
"navigation",
|
||||
"main",
|
||||
// WAI-ARIA:div 上允许 role="region"(它是 landmark 角色,需要可访问名)。
|
||||
// 本仓首页能力面板就是这么标的(home-content-v16.tsx 的 cap-panel-*,
|
||||
// 2026-10-17 补 aria-label)。这条白名单原先漏收 region,把合法用法判成违规;
|
||||
// 独立仪器侧的核对:全站 axe 节点计数闸在同一批产物上 violationNodes=0
|
||||
// (注意 axe 的 landmark-name 规则属 best-practice 标签,我们的闸只跑 WCAG A/AA,
|
||||
// 所以「axe 没红」不等于「面板有名字」——名字是这次补的产品侧修复)。
|
||||
"region",
|
||||
"banner",
|
||||
"contentinfo",
|
||||
"dialog",
|
||||
@@ -393,11 +400,29 @@ test.describe("可访问性 - WCAG 2.1 AA 合规", { tag: "@regression" }, () =>
|
||||
).toBe(0);
|
||||
});
|
||||
|
||||
test("焦点管理清晰可见", async ({ page }) => {
|
||||
test("焦点管理清晰可见", async ({ page, browserName }) => {
|
||||
// Tab 到第一个链接并检查焦点样式
|
||||
// N-27:去掉 `if (focusedElement.count() > 0)` 守卫。'/' 首个 Tab 焦点落在跳转链接
|
||||
// (layout.tsx:201),按不到焦点元素本身就应失败。
|
||||
await page.keyboard.press("Tab");
|
||||
//
|
||||
// 2026-10-17(§14 定性):本例原先对所有引擎都用 `Tab`,但 webkit 与 chromium-mobile 上
|
||||
// `:focus` 始终为空(实取 locator(':focus') element(s) not found,15s 超时;
|
||||
// 我先试过 bringToFront + 点空白再 Tab,**没有用**,所以这不是"页面没获得窗口焦点"那类前置问题)。
|
||||
// 根因是引擎行为:Safari/WebKit 需要系统级「Press Tab to highlight each item」才把 Tab 用于全元素循环,
|
||||
// Playwright 起的 webkit 不带这个设置 ⇒ Tab 不会把焦点落到链接上,这与产品有无焦点样式无关。
|
||||
//
|
||||
// 处置:**同一契约换按引擎可靠的手段**,断言一条不减 ——
|
||||
// ① 焦点必须能落到首个可聚焦元素(chromium 用 Tab,webkit/mobile 用显式 focus);
|
||||
// ② 该元素必须有可见焦点指示(outline / box-shadow / data-focus-visible)。
|
||||
// 独立仪器侧佐证:全站 axe 节点计数闸在本批产物上 violationNodes=0,
|
||||
// 而 chromium 桌面 project 仍走真实的键盘 Tab 路径。
|
||||
if (browserName === "chromium") {
|
||||
await page.keyboard.press("Tab");
|
||||
} else {
|
||||
const skip = page.locator("[data-skip-to-content]").first();
|
||||
await expect(skip, "webkit/mobile:跳转链接必须存在且可聚焦").toBeVisible();
|
||||
await skip.focus();
|
||||
}
|
||||
await page.waitForTimeout(200);
|
||||
|
||||
const focusedElement = page.locator(":focus").first();
|
||||
|
||||
@@ -158,6 +158,11 @@ export default defineConfig({
|
||||
cwd: '..',
|
||||
env: {
|
||||
CMS_REVALIDATE_SECRET: process.env.CMS_REVALIDATE_SECRET || 'e2e-test-secret',
|
||||
// 登录限流是**进程内内存桶**,而这里的 server 跨整轮用例存活 ⇒ `@admin` 旅程每条各自登录一次,
|
||||
// 全量功能 E2E 第 11 次起必得 429(§14 的 UJ-03/06/07:单跑绿、全量红的真因)。
|
||||
// 只在 E2E harness 抬高额度;生产与默认环境不经过这里,仍是 10 次/15 分钟/IP
|
||||
// (默认值与覆盖行为由 src/app/api/auth/login/route.test.ts 的双向用例钉住)。
|
||||
LOGIN_RATE_LIMIT_MAX: '500',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 332 KiB |
|
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 154 KiB |
|
Before Width: | Height: | Size: 713 KiB After Width: | Height: | Size: 713 KiB |
|
Before Width: | Height: | Size: 784 KiB After Width: | Height: | Size: 784 KiB |
|
Before Width: | Height: | Size: 715 KiB After Width: | Height: | Size: 715 KiB |
|
Before Width: | Height: | Size: 713 KiB After Width: | Height: | Size: 713 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 592 KiB After Width: | Height: | Size: 592 KiB |
|
Before Width: | Height: | Size: 2.4 MiB After Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 2.6 MiB After Width: | Height: | Size: 2.6 MiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
|
Before Width: | Height: | Size: 932 KiB After Width: | Height: | Size: 929 KiB |
|
Before Width: | Height: | Size: 416 KiB After Width: | Height: | Size: 415 KiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.8 MiB After Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 456 KiB After Width: | Height: | Size: 454 KiB |
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 192 KiB |
|
Before Width: | Height: | Size: 927 KiB After Width: | Height: | Size: 927 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 931 KiB After Width: | Height: | Size: 932 KiB |
|
Before Width: | Height: | Size: 927 KiB After Width: | Height: | Size: 927 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.0 MiB |
|
Before Width: | Height: | Size: 451 KiB After Width: | Height: | Size: 451 KiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 2.4 MiB After Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
|
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
@@ -149,7 +149,10 @@ test.describe('网站全面测试验收', { tag: '@regression' }, () => {
|
||||
await expect(nav).toBeVisible();
|
||||
await expectHydrated(nav);
|
||||
|
||||
const contactLink = nav.locator('a[href="/contact"]').first();
|
||||
// 桌面顶栏里没有 `a[href="/contact"]`:NAVIGATION_V2 只有 行业/能力/洞察/关于我们 四项,
|
||||
// 联系入口是 header.tsx:165 的常驻 CTA(data-testid="consult-button",aria-label「预约咨询」),
|
||||
// 位于 desktop-navigation 之外。注释里那句「联系我们不在列表里」就是这条设计决定。
|
||||
const contactLink = page.getByTestId('consult-button').first();
|
||||
await expect(contactLink).toBeVisible();
|
||||
await Promise.all([
|
||||
page.waitForURL((url) => url.pathname === '/contact', {
|
||||
|
||||
@@ -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>
|
||||
|
||||