Files
gym-manage/e2e-tests/smoke/login-logout.spec.ts
T
张翔 44215d3b2d test(e2e): 改进 Playwright 测试框架和 E2E 测试
- 更新 Playwright 配置,添加认证状态管理和 setup 项目
- 优化 E2E 测试用例,简化测试流程
- 添加 auth-debug.spec.ts 用于调试认证问题
- 添加 playwright/.auth/user.json 认证状态文件
2026-04-18 13:06:07 +08:00

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/);
});
});
});