From 0258b8d39a4d2568864d424a890bc7613367ae97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=BF=94?= Date: Sat, 25 Apr 2026 09:01:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20E2E=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 Logo alt 属性,使用繁体字"睿新致遠" - 修复关于我们页面电话测试选择器 - 修复表单验证测试,改用 blur 触发验证 - 修复无障碍访问测试,处理多个 nav 元素情况 - 所有测试通过(42/42) --- e2e/website-acceptance.spec.ts | 30 ++++++++++++++++++------------ src/components/layout/header.tsx | 2 +- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/e2e/website-acceptance.spec.ts b/e2e/website-acceptance.spec.ts index e1d9986..64a6d3c 100644 --- a/e2e/website-acceptance.spec.ts +++ b/e2e/website-acceptance.spec.ts @@ -71,11 +71,8 @@ test.describe('网站全面测试验收', () => { await page.goto('/about'); await page.waitForLoadState('networkidle'); - const contactSection = page.locator('text=/联系我们/').locator('..').locator('..'); - if (await contactSection.isVisible()) { - const phoneText = contactSection.locator('text=/联系电话|028-88888888/'); - expect(await phoneText.count()).toBe(0); - } + const phoneElements = page.locator('text=/电话|028-|1[3-9]\\d{9}/'); + expect(await phoneElements.count()).toBe(0); }); test('响应式设计正常工作', async ({ page }) => { @@ -120,12 +117,14 @@ test.describe('网站全面测试验收', () => { await page.goto('/contact'); await page.waitForLoadState('networkidle'); - const submitButton = page.locator('button[type="submit"]'); - await submitButton.click(); - const nameInput = page.locator('input[name="name"]'); - const errorMessage = nameInput.locator('..').locator('text=/至少需要2个字符/'); - await expect(errorMessage).toBeVisible(); + await nameInput.fill('a'); + await nameInput.blur(); + + await page.waitForTimeout(500); + + const errorMessage = page.locator('text=至少需要2个字符').first(); + await expect(errorMessage).toBeVisible({ timeout: 10000 }); }); test('页面加载性能良好', async ({ page }) => { @@ -142,8 +141,15 @@ test.describe('网站全面测试验收', () => { }); test('无障碍访问正常', async ({ page }) => { - const accessibilityIssues = await page.accessibility.snapshot(); - expect(accessibilityIssues).toBeDefined(); + const mainHeading = page.locator('h1'); + await expect(mainHeading).toBeVisible(); + + const nav = page.locator('nav').first(); + await expect(nav).toBeVisible(); + + const buttons = page.locator('button'); + const buttonCount = await buttons.count(); + expect(buttonCount).toBeGreaterThan(0); }); test('联系我们页面没有返回按钮覆盖logo', async ({ page }) => { diff --git a/src/components/layout/header.tsx b/src/components/layout/header.tsx index d899824..1b09756 100644 --- a/src/components/layout/header.tsx +++ b/src/components/layout/header.tsx @@ -110,7 +110,7 @@ function HeaderContent() { >