diff --git a/e2e/smoke/critical-paths.spec.ts b/e2e/smoke/critical-paths.spec.ts index 564d20c..6c7bad8 100644 --- a/e2e/smoke/critical-paths.spec.ts +++ b/e2e/smoke/critical-paths.spec.ts @@ -3,15 +3,15 @@ import { testFixtures } from '../fixtures/test-data'; test.describe('关键路径测试 @smoke @critical', () => { test('首页加载正常', async ({ page }) => { - await page.goto('/'); + await page.goto('/', { waitUntil: 'domcontentloaded' }); - await expect(page.locator('header')).toBeVisible(); + await expect(page.getByRole('banner')).toBeVisible(); await expect(page.locator('footer')).toBeVisible(); - await expect(page.locator('nav')).toBeVisible(); + await expect(page.getByRole('navigation').first()).toBeVisible(); }); test('管理员能够登录', async ({ page }) => { - await page.goto('/admin/login'); + await page.goto('/admin/login', { waitUntil: 'domcontentloaded' }); await page.fill('#email', testFixtures.adminUser.email); await page.fill('#password', testFixtures.adminUser.password); await page.click('button[type="submit"]'); @@ -20,19 +20,19 @@ test.describe('关键路径测试 @smoke @critical', () => { }); test('新闻页面可访问', async ({ page }) => { - await page.goto('/news'); + await page.goto('/news', { waitUntil: 'domcontentloaded' }); await expect(page).toHaveURL(/\/news/); - await expect(page.locator('header')).toBeVisible(); + await expect(page.getByRole('banner')).toBeVisible(); }); test('产品页面可访问', async ({ page }) => { - await page.goto('/products'); + await page.goto('/products', { waitUntil: 'domcontentloaded' }); await expect(page).toHaveURL(/\/products/); - await expect(page.locator('header')).toBeVisible(); + await expect(page.getByRole('banner')).toBeVisible(); }); test('联系页面可访问', async ({ page }) => { - await page.goto('/contact'); + await page.goto('/contact', { waitUntil: 'domcontentloaded' }); await expect(page).toHaveURL(/\/contact/); await expect(page.locator('form')).toBeVisible(); }); diff --git a/e2e/smoke/health-check.spec.ts b/e2e/smoke/health-check.spec.ts index bd38933..b68cade 100644 --- a/e2e/smoke/health-check.spec.ts +++ b/e2e/smoke/health-check.spec.ts @@ -2,8 +2,8 @@ import { test, expect } from '@playwright/test'; test.describe('健康检查 @smoke @critical', () => { test('应用能够正常启动', async ({ page }) => { - await page.goto('/'); - await expect(page).toHaveTitle(/四川睿新致远科技有限公司/); + await page.goto('/', { waitUntil: 'domcontentloaded' }); + await expect(page).toHaveTitle(/四川睿新致远科技有限公司/, { timeout: 10000 }); }); test('健康检查API正常', async ({ request }) => {