44215d3b2d
- 更新 Playwright 配置,添加认证状态管理和 setup 项目 - 优化 E2E 测试用例,简化测试流程 - 添加 auth-debug.spec.ts 用于调试认证问题 - 添加 playwright/.auth/user.json 认证状态文件
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('冒烟测试 - 基础流程', () => {
|
|
test.use({ storageState: { cookies: [], origins: [] } });
|
|
|
|
test('管理员登录和登出', async ({ page }) => {
|
|
await test.step('导航到登录页面', async () => {
|
|
await page.goto('/login');
|
|
await page.waitForLoadState('networkidle');
|
|
});
|
|
|
|
await test.step('输入登录信息', async () => {
|
|
await page.fill('input[type="text"]', 'admin');
|
|
await page.fill('input[type="password"]', 'Test@123');
|
|
});
|
|
|
|
await test.step('点击登录按钮', async () => {
|
|
await page.click('button:has-text("登录")');
|
|
await page.waitForURL(/.*dashboard/, { timeout: 10000 });
|
|
});
|
|
|
|
await test.step('验证登录成功', async () => {
|
|
await expect(page).toHaveURL(/.*dashboard/);
|
|
});
|
|
|
|
await test.step('点击用户菜单', async () => {
|
|
const avatarButton = page.locator('.el-avatar').first();
|
|
await avatarButton.click();
|
|
await page.waitForTimeout(500);
|
|
});
|
|
|
|
await test.step('点击退出登录', async () => {
|
|
await page.click('text=退出登录');
|
|
await page.waitForURL(/.*login/, { timeout: 10000 });
|
|
});
|
|
|
|
await test.step('验证登出成功', async () => {
|
|
await expect(page).toHaveURL(/.*login/);
|
|
});
|
|
});
|
|
});
|