Files
novalon-website/e2e/smoke/critical-paths.spec.ts
T
张翔 07d2315935 feat: 创建冒烟测试(快速层)
新增文件:
- e2e/smoke/health-check.spec.ts - 健康检查测试
- e2e/smoke/critical-paths.spec.ts - 关键路径测试

测试内容:
- 应用启动验证
- 健康检查API验证
- 静态资源访问验证
- 首页加载验证
- 管理员登录验证
- 新闻/产品/联系页面访问验证

特性:
- 使用 @smoke @critical 标签,支持按标签运行
- 快速验证核心功能,适合CI/CD流水线
- 测试执行时间短,无复杂依赖
2026-04-09 13:23:06 +08:00

40 lines
1.3 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { testFixtures } from '../fixtures/test-data';
test.describe('关键路径测试 @smoke @critical', () => {
test('首页加载正常', async ({ page }) => {
await page.goto('/');
await expect(page.locator('header')).toBeVisible();
await expect(page.locator('footer')).toBeVisible();
await expect(page.locator('nav')).toBeVisible();
});
test('管理员能够登录', async ({ page }) => {
await page.goto('/admin/login');
await page.fill('#email', testFixtures.adminUser.email);
await page.fill('#password', testFixtures.adminUser.password);
await page.click('button[type="submit"]');
await expect(page).toHaveURL(/\/admin(?!\/login)/);
});
test('新闻页面可访问', async ({ page }) => {
await page.goto('/news');
await expect(page).toHaveURL(/\/news/);
await expect(page.locator('header')).toBeVisible();
});
test('产品页面可访问', async ({ page }) => {
await page.goto('/products');
await expect(page).toHaveURL(/\/products/);
await expect(page.locator('header')).toBeVisible();
});
test('联系页面可访问', async ({ page }) => {
await page.goto('/contact');
await expect(page).toHaveURL(/\/contact/);
await expect(page.locator('form')).toBeVisible();
});
});