fix: 修复移动端导航菜单选择器问题

feat: 为主导航菜单和页面区块添加ARIA属性

fix: 解决工作时间信息获取问题

perf: 优化页面滚动功能实现

fix: 修正联系页面标题显示问题

test: 运行完整测试套件验证修复效果

docs: 添加修复完成报告
This commit is contained in:
张翔
2026-03-07 15:20:40 +08:00
parent 11b0123c20
commit feb646efe5
12 changed files with 8241 additions and 1 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+544
View File
@@ -0,0 +1,544 @@
# 测试套件修复计划
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
**目标:** 修复表单测试中的元素定位、CSS选择器和Toast组件处理问题,使所有9个失败的表单测试通过。
**架构:** 通过在系统代码中添加data-testid属性、修正测试代码的CSS选择器、更新Toast组件处理逻辑,实现测试与实际UI的同步。
**技术栈:** Playwright测试框架、React组件、TypeScript、CSS选择器
---
## 问题分析
当前9个表单测试失败的根本原因:
1. **元素定位器不匹配** - 测试使用了不存在的`data-testid`属性
2. **CSS选择器转义错误** - 错误消息选择器使用了双转义
3. **Toast组件处理不当** - 测试没有正确处理动态Toast显示
4. **缺少等待机制** - 没有等待异步UI更新完成
---
### Task 1: 在系统代码中添加data-testid属性
**目标:** 为表单元素添加data-testid属性,使测试能够正确定位元素。
**文件:**
- 修改: `/Users/zhangxiang/Codes/Gitee/home-page/novalon-website/src/components/sections/contact-section.tsx`
**Step 1: 为姓名输入框添加data-testid**
```tsx
<Input
label="姓名"
id="name"
placeholder="请输入您的姓名"
required
data-testid="name-input"
value={formData.name}
onChange={(e) => handleChange('name', e.target.value)}
onBlur={(e) => handleBlur('name', e.target.value)}
error={errors.name}
/>
```
**Step 2: 为电话输入框添加data-testid**
```tsx
<Input
label="电话"
id="phone"
type="tel"
placeholder="请输入您的电话"
required
data-testid="phone-input"
value={formData.phone}
onChange={(e) => handleChange('phone', e.target.value)}
onBlur={(e) => handleBlur('phone', e.target.value)}
error={errors.phone}
/>
```
**Step 3: 为邮箱输入框添加data-testid**
```tsx
<Input
label="邮箱"
id="email"
type="email"
placeholder="请输入您的邮箱"
required
data-testid="email-input"
value={formData.email}
onChange={(e) => handleChange('email', e.target.value)}
onBlur={(e) => handleBlur('email', e.target.value)}
error={errors.email}
/>
```
**Step 4: 为留言输入框添加data-testid**
```tsx
<Textarea
label="留言内容"
id="message"
placeholder="请输入您想咨询的内容"
rows={5}
required
data-testid="message-input"
value={formData.message}
onChange={(e) => handleChange('message', e.target.value)}
onBlur={(e) => handleBlur('message', e.target.value)}
error={errors.message}
/>
```
**Step 5: 为提交按钮添加data-testid**
```tsx
<Button
type="submit"
size="lg"
className="w-full group mt-auto min-h-[52px] md:min-h-0"
disabled={isSubmitting}
data-testid="submit-button"
>
```
**Step 6: 为成功消息添加data-testid**
```tsx
{isSubmitted ? (
<div className="text-center py-12 flex-1 flex items-center justify-center" data-testid="success-message">
<div className="w-16 h-16 bg-[#C41E3A] rounded-full flex items-center justify-center mx-auto mb-4 animate-stamp-in">
<CheckCircle2 className="w-8 h-8 text-white" />
</div>
<h4 className="text-xl font-semibold text-[#1A1A2E] mb-2"></h4>
<p className="text-[#718096]"></p>
</div>
) : (
```
**Step 7: 为Toast组件添加data-testid**
```tsx
{showToast && (
<Toast
message={toastMessage}
type={toastType}
onClose={() => setShowToast(false)}
data-testid="toast-notification"
/>
)}
```
**Step 8: 为错误消息容器添加data-testid**
在Input组件中,为错误消息添加data-testid
```tsx
{error && (
<p id={errorId} className="mt-1 text-sm text-[#C41E3A]" role="alert" data-testid="error-message">
{error}
</p>
)}
```
**Step 9: 验证data-testid属性已正确添加**
运行: `cd /Users/zhangxiang/Codes/Gitee/home-page/novalon-website && npm run dev`
预期: 开发服务器正常启动,无编译错误
**Step 10: 提交更改**
```bash
git add src/components/sections/contact-section.tsx src/components/ui/input.tsx src/components/ui/textarea.tsx
git commit -m "feat: add data-testid attributes for form elements to improve testability"
```
---
### Task 2: 修正测试代码中的CSS选择器
**目标:** 修正ContactPage中的CSS选择器,使用正确的转义和data-testid定位。
**文件:**
- 修改: `/Users/zhangxiang/Codes/Gitee/home-page/novalon-website/test-framework/shared/pages/ContactPage.ts`
**Step 1: 修正getFormErrorMessage方法**
```typescript
async getFormErrorMessage(): Promise<string> {
const errorElement = await this.page.locator('[data-testid="error-message"]').first();
return await errorElement.textContent() || '';
}
```
**Step 2: 修正getFormSuccessMessage方法**
```typescript
async getFormSuccessMessage(): Promise<string> {
await this.page.waitForTimeout(1000);
const successElement = await this.page.locator('[data-testid="success-message"]');
if (await successElement.count() > 0) {
return await successElement.textContent() || '';
}
return '';
}
```
**Step 3: 添加getToastMessage方法**
```typescript
async getToastMessage(): Promise<{ message: string; type: 'success' | 'error' }> {
const toastElement = await this.page.locator('[data-testid="toast-notification"]');
if (await toastElement.count() > 0) {
const message = await toastElement.textContent() || '';
const type = await toastElement.getAttribute('data-type') as 'success' | 'error';
return { message, type };
}
return { message: '', type: 'success' };
}
```
**Step 4: 添加waitForToast方法**
```typescript
async waitForToast(timeout: number = 5000): Promise<boolean> {
try {
await this.page.waitForSelector('[data-testid="toast-notification"]', { timeout });
return true;
} catch {
return false;
}
}
```
**Step 5: 添加waitForToastHidden方法**
```typescript
async waitForToastHidden(timeout: number = 5000): Promise<boolean> {
try {
await this.page.waitForSelector('[data-testid="toast-notification"]', { state: 'hidden', timeout });
return true;
} catch {
return false;
}
}
```
**Step 6: 运行表单测试验证选择器修复**
运行: `cd test-framework && npm run test:dev-audit:forms`
预期: 部分测试通过,元素定位错误减少
**Step 7: 提交更改**
```bash
git add test-framework/shared/pages/ContactPage.ts
git commit -m "fix: correct CSS selectors and add toast handling methods in ContactPage"
```
---
### Task 3: 更新表单测试以正确处理Toast组件
**目标:** 修改测试用例,正确处理Toast组件的异步显示和消失。
**文件:**
- 修改: `/Users/zhangxiang/Codes/Gitee/home-page/novalon-website/test-framework/dev-audit/forms/forms.spec.ts`
**Step 1: 修改"联系表单 - 有效数据提交"测试**
```typescript
test('联系表单 - 有效数据提交', async ({ page }) => {
const contactPage = new ContactPage(page);
await page.route('**/api/contact', async route => {
await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({ success: true, message: '消息已发送' })
});
});
await contactPage.navigate();
await contactPage.fillContactForm({
name: formData.valid.name,
email: formData.valid.email,
phone: formData.valid.phone,
message: formData.valid.message,
subject: '测试主题'
});
await contactPage.submitForm();
await contactPage.waitForToast();
const toastMessage = await contactPage.getToastMessage();
expect(toastMessage.message).toContain('成功');
expect(toastMessage.type).toBe('success');
await contactPage.waitForToastHidden();
});
```
**Step 2: 修改"联系表单 - 必填字段验证"测试**
```typescript
test('联系表单 - 必填字段验证', async ({ page }) => {
const contactPage = new ContactPage(page);
await contactPage.navigate();
await contactPage.fillContactForm({
name: '',
email: '',
phone: '',
message: '',
subject: ''
});
await contactPage.submitForm();
await page.waitForTimeout(500);
const errorMessage = await contactPage.getFormErrorMessage();
expect(errorMessage).toBeTruthy();
});
```
**Step 3: 修改"联系表单 - 邮箱格式验证"测试**
```typescript
test('联系表单 - 邮箱格式验证', async ({ page }) => {
const contactPage = new ContactPage(page);
await contactPage.navigate();
await contactPage.fillContactForm({
name: '测试用户',
email: formData.invalid.email,
phone: '13800138000',
message: '测试消息',
subject: '测试主题'
});
await contactPage.submitForm();
await page.waitForTimeout(500);
const errorMessage = await contactPage.getFormErrorMessage();
expect(errorMessage).toContain('邮箱');
});
```
**Step 4: 修改"联系表单 - API错误处理"测试**
```typescript
test('联系表单 - API错误处理', async ({ page }) => {
const contactPage = new ContactPage(page);
await page.route('**/api/contact', async route => {
await route.fulfill({
status: 500,
contentType: 'application/json',
body: JSON.stringify({ success: false, message: '服务器错误' })
});
});
await contactPage.navigate();
await contactPage.fillContactForm({
name: formData.valid.name,
email: formData.valid.email,
phone: formData.valid.phone,
message: formData.valid.message,
subject: '测试主题'
});
await contactPage.submitForm();
await contactPage.waitForToast();
const toastMessage = await contactPage.getToastMessage();
expect(toastMessage.message).toContain('失败');
expect(toastMessage.type).toBe('error');
await contactPage.waitForToastHidden();
});
```
**Step 5: 运行表单测试验证Toast处理**
运行: `cd test-framework && npm run test:dev-audit:forms`
预期: 所有表单测试通过,Toast组件正确处理
**Step 6: 提交更改**
```bash
git add test-framework/dev-audit/forms/forms.spec.ts
git commit -m "fix: update form tests to properly handle toast component and async UI updates"
```
---
### Task 4: 更新Input和Textarea组件以支持data-testid
**目标:** 确保UI组件正确传递data-testid属性。
**文件:**
- 修改: `/Users/zhangxiang/Codes/Gitee/home-page/novalon-website/src/components/ui/input.tsx`
- 修改: `/Users/zhangxiang/Codes/Gitee/home-page/novalon-website/src/components/ui/textarea.tsx`
**Step 1: 更新Input组件接口**
```typescript
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
label?: string
error?: string
'data-testid'?: string
}
```
**Step 2: 在Input组件中使用data-testid**
```typescript
<input
type={type}
id={inputId}
data-slot="input"
data-testid={props['data-testid']}
className={cn(
// ... existing className
)}
ref={ref}
aria-required={props.required ? "true" : undefined}
aria-invalid={error ? "true" : "false"}
aria-describedby={error ? errorId : undefined}
{...props}
/>
```
**Step 3: 更新Textarea组件接口**
```typescript
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
label?: string
error?: string
'data-testid'?: string
}
```
**Step 4: 在Textarea组件中使用data-testid**
```typescript
<textarea
id={textareaId}
data-slot="textarea"
data-testid={props['data-testid']}
className={cn(
// ... existing className
)}
ref={ref}
aria-required={props.required ? "true" : undefined}
aria-invalid={error ? "true" : "false"}
aria-describedby={error ? errorId : undefined}
{...props}
/>
```
**Step 5: 验证组件正确传递data-testid**
运行: `cd /Users/zhangxiang/Codes/Gitee/home-page/novalon-website && npm run dev`
预期: 开发服务器正常启动,组件正确编译
**Step 6: 提交更改**
```bash
git add src/components/ui/input.tsx src/components/ui/textarea.tsx
git commit -m "feat: add data-testid support to Input and Textarea components"
```
---
### Task 5: 运行完整测试套件验证修复
**目标:** 运行所有测试验证修复效果。
**文件:**
- 无需修改
**Step 1: 运行表单测试**
运行: `cd test-framework && npm run test:dev-audit:forms`
预期: 所有表单测试通过(20/20)
**Step 2: 运行性能测试**
运行: `cd test-framework && npm run test:dev-audit:performance`
预期: 所有性能测试通过(35/35)
**Step 3: 运行完整测试套件**
运行: `cd test-framework && npm run test:dev-audit`
预期: 所有测试通过(85/85),通过率100%
**Step 4: 生成测试报告**
运行: `cd test-framework && npx ts-node scripts/generate-report.ts`
预期: 生成完整的测试报告,显示所有测试通过
**Step 5: 查看测试结果**
运行: `cat test-framework/reports/results.json | jq '.stats'`
预期输出:
```json
{
"startTime": "2026-03-06T...",
"duration": ...,
"expected": 85,
"skipped": 0,
"unexpected": 0,
"flaky": 0
}
```
**Step 6: 提交最终验证**
```bash
git add test-framework/reports/
git commit -m "test: verify all tests passing after test suite fixes"
```
---
## 验收标准
- [ ] 所有表单测试通过(20/20
- [ ] 所有性能测试通过(35/35
- [ ] 所有SEO测试通过
- [ ] 所有可访问性测试通过
- [ ] 完整测试套件通过率100%(85/85)
- [ ] 测试报告显示所有测试通过
- [ ] 无测试超时错误
- [ ] 无元素定位错误
---
## 风险与注意事项
1. **Toast组件时序问题** - 需要确保测试等待足够时间让Toast显示和消失
2. **移动端兼容性** - 某些测试在移动设备上可能需要额外的等待时间
3. **并发测试冲突** - 多个测试同时运行可能导致状态污染,确保每个测试独立运行
4. **API模拟准确性** - 确保API模拟响应与真实API响应格式一致
---
## 后续优化建议
1. **添加视觉回归测试** - 使用Percy或Applitools进行UI视觉测试
2. **增加测试覆盖率** - 添加更多边界条件和异常场景测试
3. **性能基准测试** - 建立性能基准,监控性能回归
4. **测试数据管理** - 使用测试数据工厂生成更多样化的测试数据
5. **CI/CD集成** - 将测试集成到持续集成流程中
@@ -0,0 +1,554 @@
# Critical Issues Fix Implementation Plan
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
**Goal:** Fix all critical and high-priority issues identified in the deployment readiness assessment to achieve 95%+ test pass rate and enable safe deployment.
**Architecture:** Fix mobile navigation issues, update page selectors, correct page titles, and improve scrolling functionality using Playwright E2E tests with TDD approach.
**Tech Stack:** Playwright, TypeScript, Next.js 16, React 19, Tailwind CSS 4
---
## Task 1: Fix Mobile Navigation Menu Functionality
**Priority:** P0 (Critical)
**Estimated Time:** 2-3 hours
**Files:**
- Modify: `e2e/src/pages/BasePage.ts`
- Modify: `e2e/src/pages/HomePage.ts`
- Modify: `src/components/layout/mobile-menu.tsx`
- Test: `e2e/src/tests/smoke/navigation.smoke.spec.ts`
**Step 1: Analyze the mobile menu component structure**
Run: `cat src/components/layout/mobile-menu.tsx`
Expected: Identify the mobile menu button and menu container structure
**Step 2: Update BasePage mobile menu selectors**
```typescript
// e2e/src/pages/BasePage.ts
export class BasePage {
readonly page: Page;
readonly mobileMenuButton: Locator;
readonly mobileMenu: Locator;
readonly mobileMenuCloseButton: Locator;
constructor(page: Page) {
this.page = page;
this.mobileMenuButton = page.getByRole('button', { name: /打开菜单|menu/i });
this.mobileMenu = page.locator('[role="dialog"], [role="navigation"], .mobile-menu');
this.mobileMenuCloseButton = page.getByRole('button', { name: /关闭|close/i });
}
async openMobileMenu() {
await this.mobileMenuButton.click();
await this.mobileMenu.waitFor({ state: 'visible', timeout: 5000 });
}
async closeMobileMenu() {
if (await this.mobileMenu.isVisible()) {
await this.mobileMenuCloseButton.click();
await this.mobileMenu.waitFor({ state: 'hidden', timeout: 5000 });
}
}
async isMobileMenuOpen() {
return await this.mobileMenu.isVisible();
}
}
```
**Step 3: Update HomePage to extend BasePage properly**
```typescript
// e2e/src/pages/HomePage.ts
import { BasePage } from './BasePage';
export class HomePage extends BasePage {
readonly navigation: Locator;
readonly logo: Locator;
constructor(page: Page) {
super(page);
this.navigation = page.locator('nav, [role="navigation"]');
this.logo = page.getByRole('link', { name: /四川睿新致远|novalon/i });
}
}
```
**Step 4: Run navigation smoke tests to verify fixes**
Run: `cd e2e && npm run test:smoke -- --grep "导航冒烟测试"`
Expected: See current failures for mobile menu tests
**Step 5: Fix mobile menu component if needed**
Check: `src/components/layout/mobile-menu.tsx`
Ensure the mobile menu has proper ARIA attributes:
```tsx
<button
aria-label="打开菜单"
aria-expanded={isOpen}
onClick={toggleMenu}
>
{/* Menu icon */}
</button>
{isOpen && (
<nav
role="navigation"
aria-label="主导航"
className="mobile-menu"
>
{/* Menu items */}
<button
aria-label="关闭菜单"
onClick={toggleMenu}
>
{/* Close icon */}
</button>
</nav>
)}
```
**Step 6: Run navigation smoke tests again**
Run: `cd e2e && npm run test:smoke -- --grep "导航冒烟测试"`
Expected: Mobile menu tests should pass
**Step 7: Commit mobile menu fixes**
```bash
git add e2e/src/pages/BasePage.ts e2e/src/pages/HomePage.ts src/components/layout/mobile-menu.tsx
git commit -m "fix: resolve mobile navigation menu selector issues"
```
---
## Task 2: Fix Main Navigation Menu Display
**Priority:** P0 (Critical)
**Estimated Time:** 1-2 hours
**Files:**
- Modify: `e2e/src/pages/HomePage.ts`
- Modify: `e2e/src/tests/smoke/navigation.smoke.spec.ts`
- Modify: `src/components/layout/header.tsx`
**Step 1: Update HomePage navigation selector to use Locator**
```typescript
// e2e/src/pages/HomePage.ts
export class HomePage extends BasePage {
readonly navigation: Locator;
constructor(page: Page) {
super(page);
this.navigation = page.locator('nav, [role="navigation"], .main-nav');
}
}
```
**Step 2: Update navigation smoke test to use proper Locator**
```typescript
// e2e/src/tests/smoke/navigation.smoke.spec.ts
test('应该显示主导航菜单', async ({ homePage }) => {
const nav = homePage.page.locator('nav, [role="navigation"]');
await expect(nav.first()).toBeVisible();
});
```
**Step 3: Ensure header component has proper semantic HTML**
Check: `src/components/layout/header.tsx`
```tsx
<nav role="navigation" aria-label="主导航" className="main-nav">
<ul>
<li><a href="/services"></a></li>
<li><a href="/products"></a></li>
<li><a href="/cases"></a></li>
<li><a href="/news"></a></li>
<li><a href="/about"></a></li>
</ul>
</nav>
```
**Step 4: Run navigation tests**
Run: `cd e2e && npm run test:smoke -- --grep "应该显示主导航菜单"`
Expected: Test should pass
**Step 5: Commit navigation display fixes**
```bash
git add e2e/src/pages/HomePage.ts e2e/src/tests/smoke/navigation.smoke.spec.ts src/components/layout/header.tsx
git commit -m "fix: resolve main navigation menu display issues"
```
---
## Task 3: Fix Page Section Display Issues
**Priority:** P0 (Critical)
**Estimated Time:** 2-3 hours
**Files:**
- Modify: `e2e/src/pages/HomePage.ts`
- Modify: `e2e/src/tests/smoke/home-page.smoke.spec.ts`
- Modify: `src/components/sections/*.tsx`
**Step 1: Add section locators to HomePage**
```typescript
// e2e/src/pages/HomePage.ts
export class HomePage extends BasePage {
readonly heroSection: Locator;
readonly servicesSection: Locator;
readonly productsSection: Locator;
readonly casesSection: Locator;
readonly footer: Locator;
constructor(page: Page) {
super(page);
this.heroSection = page.locator('section:has(h1), [role="region"]:has(h1)');
this.servicesSection = page.getByRole('region', { name: /核心业务|服务/i });
this.productsSection = page.getByRole('region', { name: /产品/i });
this.casesSection = page.getByRole('region', { name: /案例/i });
this.footer = page.locator('footer');
}
async scrollToSection(section: Locator) {
await section.scrollIntoViewIfNeeded();
await this.page.waitForTimeout(500);
}
}
```
**Step 2: Update home page smoke tests to use section locators**
```typescript
// e2e/src/tests/smoke/home-page.smoke.spec.ts
test('应该显示所有主要区块', async ({ homePage }) => {
await expect(homePage.heroSection).toBeVisible();
await expect(homePage.servicesSection).toBeVisible();
await expect(homePage.productsSection).toBeVisible();
await expect(homePage.casesSection).toBeVisible();
});
test('应该显示页脚', async ({ homePage }) => {
await expect(homePage.footer).toBeVisible();
});
```
**Step 3: Ensure sections have proper ARIA roles**
Check each section component and add role if missing:
```tsx
<section role="region" aria-labelledby="services-heading">
<h2 id="services-heading"> </h2>
{/* Section content */}
</section>
```
**Step 4: Run home page smoke tests**
Run: `cd e2e && npm run test:smoke -- --grep "首页冒烟测试"`
Expected: Section display tests should pass
**Step 5: Commit section display fixes**
```bash
git add e2e/src/pages/HomePage.ts e2e/src/tests/smoke/home-page.smoke.spec.ts src/components/sections/
git commit -m "fix: resolve page section display issues"
```
---
## Task 4: Fix Work Hours Information Retrieval
**Priority:** P1 (High)
**Estimated Time:** 30 minutes
**Files:**
- Modify: `e2e/src/pages/ContactPage.ts`
- Modify: `src/app/(marketing)/contact/page.tsx`
**Step 1: Update ContactPage work hours selector**
```typescript
// e2e/src/pages/ContactPage.ts
export class ContactPage extends BasePage {
async getWorkHours() {
const workHoursItems = this.page.locator('[aria-label="工作时间"] + div, .work-hours > div');
const count = await workHoursItems.count();
const items = [];
for (let i = 0; i < count; i++) {
const item = workHoursItems.nth(i);
const day = await item.locator('div').first().textContent();
const hours = await item.locator('div').nth(1).textContent();
if (day && hours) {
items.push({ day: day.trim(), hours: hours.trim() });
}
}
return items;
}
}
```
**Step 2: Ensure contact page has proper work hours structure**
Check: `src/app/(marketing)/contact/page.tsx`
```tsx
<div aria-label="工作时间" className="work-hours">
<div>
<div></div>
<div>9:00 - 18:00</div>
</div>
</div>
```
**Step 3: Run contact page smoke tests**
Run: `cd e2e && npm run test:smoke -- --grep "联系页面冒烟测试.*工作时间"`
Expected: Work hours tests should pass
**Step 4: Commit work hours fixes**
```bash
git add e2e/src/pages/ContactPage.ts src/app/(marketing)/contact/page.tsx
git commit -m "fix: resolve work hours information retrieval"
```
---
## Task 5: Fix Page Scrolling Functionality
**Priority:** P1 (High)
**Estimated Time:** 1-2 hours
**Files:**
- Modify: `e2e/src/pages/BasePage.ts`
- Modify: `e2e/src/tests/smoke/navigation.smoke.spec.ts`
- Modify: `e2e/src/tests/smoke/home-page.smoke.spec.ts`
**Step 1: Add robust scrolling methods to BasePage**
```typescript
// e2e/src/pages/BasePage.ts
async scrollToTop() {
await this.page.evaluate(() => {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
await this.page.waitForTimeout(1000);
}
async scrollToBottom() {
await this.page.evaluate(() => {
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
});
await this.page.waitForTimeout(1000);
}
async scrollToElement(selector: string) {
const element = this.page.locator(selector);
await element.scrollIntoViewIfNeeded({ timeout: 5000 });
await this.page.waitForTimeout(500);
}
```
**Step 2: Update scrolling tests with better error handling**
```typescript
// e2e/src/tests/smoke/navigation.smoke.spec.ts
test('应该能够滚动到页面顶部', async ({ homePage }) => {
await homePage.scrollToBottom();
await homePage.scrollToTop();
const scrollPosition = await homePage.page.evaluate(() => window.scrollY);
expect(scrollPosition).toBeLessThan(100);
});
test('应该能够滚动到页面底部', async ({ homePage }) => {
await homePage.scrollToBottom();
const scrollPosition = await homePage.page.evaluate(() => {
return window.scrollY + window.innerHeight;
});
const pageHeight = await homePage.page.evaluate(() => document.body.scrollHeight);
expect(scrollPosition).toBeGreaterThanOrEqual(pageHeight - 100);
});
```
**Step 3: Run scrolling tests**
Run: `cd e2e && npm run test:smoke -- --grep "滚动"`
Expected: Scrolling tests should pass
**Step 4: Commit scrolling fixes**
```bash
git add e2e/src/pages/BasePage.ts e2e/src/tests/smoke/navigation.smoke.spec.ts e2e/src/tests/smoke/home-page.smoke.spec.ts
git commit -m "fix: resolve page scrolling functionality issues"
```
---
## Task 6: Fix Contact Page Title
**Priority:** P2 (Medium)
**Estimated Time:** 10 minutes
**Files:**
- Modify: `src/app/(marketing)/contact/page.tsx`
- Modify: `e2e/src/tests/smoke/contact-page.smoke.spec.ts`
**Step 1: Update contact page title**
```typescript
// src/app/(marketing)/contact/page.tsx
export const metadata = {
title: '联系我们 - 四川睿新致远科技有限公司',
description: '无论您有任何问题或合作意向,我们都很乐意与您交流',
};
```
**Step 2: Update page heading to match title**
```tsx
// src/app/(marketing)/contact/page.tsx
<h1></h1>
```
**Step 3: Update test to match actual title**
```typescript
// e2e/src/tests/smoke/contact-page.smoke.spec.ts
test('应该显示正确的页面标题', async ({ contactPage }) => {
const title = await contactPage.page.title();
expect(title).toBeTruthy();
expect(title.length).toBeGreaterThan(0);
expect(title).toContain('联系');
});
```
**Step 4: Run contact page title test**
Run: `cd e2e && npm run test:smoke -- --grep "应该显示正确的页面标题"`
Expected: Title test should pass
**Step 5: Commit title fixes**
```bash
git add src/app/(marketing)/contact/page.tsx e2e/src/tests/smoke/contact-page.smoke.spec.ts
git commit -m "fix: correct contact page title"
```
---
## Task 7: Run Full Test Suite and Verify
**Priority:** P0 (Critical)
**Estimated Time:** 45 minutes
**Files:**
- Test: All smoke tests
**Step 1: Run all smoke tests**
Run: `cd e2e && npm run test:smoke`
Expected: All smoke tests should pass with >95% pass rate
**Step 2: Generate test report**
Run: `cd e2e && npm run test:report`
Expected: HTML report generated
**Step 3: Check test results**
Run: `cd e2e && node analyze-results.js`
Expected: Pass rate should be >95%
**Step 4: If any tests fail, analyze and fix**
Run: `cd e2e && npx playwright show-report`
Expected: Identify any remaining failures and create additional fix tasks
**Step 5: Commit test results**
```bash
git add e2e/test-results/ e2e/analyze-results.js
git commit -m "test: verify all critical fixes with full test suite"
```
---
## Task 8: Create Deployment Readiness Report
**Priority:** P0 (Critical)
**Estimated Time:** 30 minutes
**Files:**
- Create: `docs/reports/2026-03-07-fixes-completion-report.md`
**Step 1: Generate completion report**
Create report with:
- Summary of all fixes implemented
- Before and after test results
- Remaining issues (if any)
- Deployment readiness status
- Recommendations
**Step 2: Commit report**
```bash
git add docs/reports/2026-03-07-fixes-completion-report.md
git commit -m "docs: add fixes completion report"
```
---
## Verification Checklist
After completing all tasks, verify:
- [ ] All P0 issues fixed (mobile navigation, main navigation, page sections)
- [ ] All P1 issues fixed (work hours, scrolling)
- [ ] All P2 issues fixed (page title)
- [ ] Smoke test pass rate >95%
- [ ] No critical failures remaining
- [ ] All changes committed with clear messages
- [ ] Completion report generated
---
## Rollback Plan
If any fix introduces new issues:
1. Identify the problematic commit
2. Revert the specific commit: `git revert <commit-hash>`
3. Re-run tests to verify stability
4. Document the issue for future investigation
---
## Success Criteria
- Smoke test pass rate: >95%
- Navigation tests: 100% pass
- Home page tests: 100% pass
- Contact page tests: 100% pass
- Zero P0 or P1 issues remaining
- Ready for deployment with confidence
+267
View File
@@ -0,0 +1,267 @@
# 独立会话执行指导
## 📋 工作环境已准备就绪
**Worktree路径**: `/Users/zhangxiang/Codes/Gitee/home-page/novalon-website-fix-critical-issues`
**分支名称**: `fix/critical-issues`
**基础分支**: `feat-init`
---
## 🚀 执行步骤
### 步骤1: 打开新的IDE会话
在新的IDE窗口或终端中打开worktree目录:
```bash
cd /Users/zhangxiang/Codes/Gitee/home-page/novalon-website-fix-critical-issues
```
### 步骤2: 验证环境
```bash
# 检查当前分支
git branch
# 应该显示: * fix/critical-issues
# 检查git状态
git status
# 应该显示: clean working directory
```
### 步骤3: 安装依赖(如果需要)
```bash
# 如果node_modules不存在,安装依赖
npm install
# 如果e2e目录需要依赖
cd e2e && npm install
```
### 步骤4: 启动开发服务器
```bash
# 在worktree根目录启动开发服务器
npm run dev
# 服务器将在 http://localhost:3000 启动
```
### 步骤5: 在新会话中调用executing-plans技能
在新的Trae IDE会话中,执行以下操作:
1. **打开新会话**
- 在新的IDE窗口中打开worktree目录
- 确保工作目录是: `/Users/zhangxiang/Codes/Gitee/home-page/novalon-website-fix-critical-issues`
2. **调用executing-plans技能**
```
@executing-plans
```
3. **指定修复计划文件**
```
请执行修复计划: docs/plans/2026-03-07-critical-issues-fix.md
```
---
## 📝 修复计划概览
修复计划包含8个任务:
1. **Task 1**: 修复移动端导航菜单功能 (P0, 2-3小时)
2. **Task 2**: 修复主导航菜单显示 (P0, 1-2小时)
3. **Task 3**: 修复页面区块显示问题 (P0, 2-3小时)
4. **Task 4**: 修复工作时间信息获取 (P1, 30分钟)
5. **Task 5**: 修复页面滚动功能 (P1, 1-2小时)
6. **Task 6**: 修复联系页面标题 (P2, 10分钟)
7. **Task 7**: 运行完整测试套件验证 (P0, 45分钟)
8. **Task 8**: 创建修复完成报告 (P0, 30分钟)
**预计总时间**: 1-2个工作日
---
## 🔍 执行检查点
### 检查点1: P0问题修复完成
**时间**: 第1天下午
**验证**:
- [ ] 移动端导航菜单功能正常
- [ ] 主导航菜单显示正常
- [ ] 页面区块显示完整
**测试命令**:
```bash
cd e2e
npm run test:smoke -- --grep "导航冒烟测试"
npm run test:smoke -- --grep "首页冒烟测试"
```
### 检查点2: 所有问题修复完成
**时间**: 第2天上午
**验证**:
- [ ] P0问题全部修复
- [ ] P1问题全部修复
- [ ] P2问题全部修复
**测试命令**:
```bash
cd e2e
npm run test:smoke
```
### 检查点3: 测试通过率达到标
**时间**: 第2天下午
**验证**:
- [ ] 测试通过率 >95%
- [ ] 无P0或P1问题
- [ ] 准备上线
**测试命令**:
```bash
cd e2e
npm run test:smoke
node analyze-results.js
```
---
## 📊 成功标准
修复完成后,应该达到以下标准:
- ✅ 测试通过率 >95%
- ✅ 导航测试 100%通过
- ✅ 首页测试 100%通过
- ✅ 联系页面测试 100%通过
- ✅ 零个P0或P1问题
- ✅ 准备上线
---
## 🔄 回滚计划
如果修复过程中出现问题:
### 回滚单个提交
```bash
# 查看提交历史
git log --oneline
# 回滚到指定提交
git revert <commit-hash>
# 重新测试
cd e2e && npm run test:smoke
```
### 回滚到初始状态
```bash
# 重置到worktree创建时的状态
git reset --hard b7d400e
# 清理未跟踪的文件
git clean -fd
```
---
## 📞 技术支持
**遇到问题时**:
1. 检查修复计划文件: `docs/plans/2026-03-07-critical-issues-fix.md`
2. 查看测试报告: `e2e/test-results/results.json`
3. 运行测试分析: `e2e/analyze-results.js`
**常见问题**:
- **问题**: 测试超时
- **解决**: 增加测试超时时间或检查网络连接
- **问题**: 选择器找不到元素
- **解决**: 检查页面结构,更新选择器
- **问题**: 移动端菜单无法打开
- **解决**: 检查mobile-menu组件的ARIA属性
---
## ✅ 完成后的操作
修复完成后,执行以下操作:
### 1. 生成最终测试报告
```bash
cd e2e
npm run test:smoke
node analyze-results.js
```
### 2. 创建修复完成报告
修复计划中的Task 8会自动生成报告
### 3. 合并到主分支
```bash
# 切换到主分支
cd /Users/zhangxiang/Codes/Gitee/home-page/novalon-website
git checkout feat-init
# 合并修复分支
git merge fix/critical-issues
# 推送到远程
git push
```
### 4. 清理worktree
```bash
# 删除worktree
git worktree remove /Users/zhangxiang/Codes/Gitee/home-page/novalon-website-fix-critical-issues
```
---
## 📋 执行清单
在开始执行前,确认:
- [ ] 已打开新的IDE会话
- [ ] 工作目录是worktree路径
- [ ] 开发服务器已启动
- [ ] 已调用executing-plans技能
- [ ] 已指定修复计划文件
---
## 🎯 下一步
**现在请执行以下操作**:
1. 在新的IDE窗口中打开: `/Users/zhangxiang/Codes/Gitee/home-page/novalon-website-fix-critical-issues`
2. 在新会话中调用:
```
@executing-plans
```
3. 指定修复计划:
```
请执行修复计划: docs/plans/2026-03-07-critical-issues-fix.md
```
4. 按照计划逐个任务执行
---
**祝您修复顺利!** 🚀
如有任何问题,请参考修复计划文件或联系技术支持。