- Add GA4 event tracking E2E tests (4 cases: page view, form submit, button click, product page) - Add mobile-specific E2E tests (16 cases: navigation, form, product browsing) - Add user journey tests (UJ-01: homepage to contact, UJ-02: product discovery) - Fix E2E test selectors and assertions for consistency - Update visual regression baselines across all browsers (chromium/firefox/webkit) - Update Playwright config for new test files
30 lines
1.5 KiB
TypeScript
30 lines
1.5 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test('主导航产品下拉菜单可在 hover 时展开', { tag: '@smoke' }, async ({ page }) => {
|
|
await page.goto('/', { waitUntil: 'networkidle' });
|
|
// 等待桌面导航 hydration 完成
|
|
await expect(page.locator('nav[aria-label="主导航"]')).toBeVisible({ timeout: 10000 });
|
|
|
|
const productsButton = page.locator('nav[aria-label="主导航"] button:has-text("产品")');
|
|
await expect(productsButton).toHaveAttribute('aria-expanded', 'false');
|
|
|
|
await productsButton.hover();
|
|
await expect(productsButton).toHaveAttribute('aria-expanded', 'true');
|
|
await expect(page.locator('text=企业套装').first()).toBeVisible();
|
|
await expect(page.locator('text=ERP 管理系统').first()).toBeVisible();
|
|
});
|
|
|
|
test('主导航解决方案下拉菜单可在 hover 时展开', { tag: '@smoke' }, async ({ page }) => {
|
|
await page.goto('/', { waitUntil: 'networkidle' });
|
|
// 等待桌面导航 hydration 完成
|
|
await expect(page.locator('nav[aria-label="主导航"]')).toBeVisible({ timeout: 10000 });
|
|
|
|
const solutionsButton = page.locator('nav[aria-label="主导航"] button:has-text("解决方案")');
|
|
await expect(solutionsButton).toHaveAttribute('aria-expanded', 'false');
|
|
|
|
await solutionsButton.hover();
|
|
await expect(solutionsButton).toHaveAttribute('aria-expanded', 'true');
|
|
await expect(page.locator('text=行业解决方案').first()).toBeVisible();
|
|
await expect(page.locator('text=制造业').first()).toBeVisible();
|
|
});
|