fix(e2e): 移除测试文件中的重复登录逻辑

问题:
- 其他测试文件仍在使用beforeEach进行登录
- 这会覆盖setup中保存的登录状态
- 导致测试失败

修复:
- 移除audit-workflow.spec.ts中的beforeEach登录
- 移除system-config-workflow.spec.ts中的beforeEach登录
- 移除file-management-workflow.spec.ts中的beforeEach登录

优势:
- 统一使用setup保存的登录状态
- 减少重复代码
- 提高测试稳定性
This commit is contained in:
张翔
2026-04-07 11:55:41 +08:00
parent b34c09bdaf
commit 4363af5ed1
4 changed files with 22 additions and 24 deletions
@@ -1,14 +1,6 @@
import { test, expect } from '@playwright/test';
test.describe('审计工作流', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login');
await page.locator('input[placeholder*="用户名"]').fill('admin');
await page.locator('input[placeholder*="密码"]').fill('admin123');
await page.locator('button:has-text("登录")').click();
await page.waitForURL('**/dashboard', { timeout: 30000 });
});
test('执行操作并查看操作日志', async ({ page }) => {
await test.step('执行用户管理操作', async () => {
await page.goto('/users');
@@ -1,14 +1,6 @@
import { test, expect } from '@playwright/test';
test.describe('文件管理工作流', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login');
await page.locator('input[placeholder*="用户名"]').fill('admin');
await page.locator('input[placeholder*="密码"]').fill('admin123');
await page.locator('button:has-text("登录")').click();
await page.waitForURL('**/dashboard', { timeout: 30000 });
});
test('文件上传流程', async ({ page }) => {
await test.step('导航到文件管理', async () => {
await page.goto('/dashboard');
@@ -1,14 +1,6 @@
import { test, expect } from '@playwright/test';
test.describe('系统配置工作流', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/login');
await page.locator('input[placeholder*="用户名"]').fill('admin');
await page.locator('input[placeholder*="密码"]').fill('admin123');
await page.locator('button:has-text("登录")').click();
await page.waitForURL('**/dashboard', { timeout: 30000 });
});
test('查看系统配置', async ({ page }) => {
await test.step('导航到系统配置', async () => {
await page.goto('/dashboard');
@@ -0,0 +1,22 @@
{
"cookies": [],
"origins": [
{
"origin": "http://localhost:3002",
"localStorage": [
{
"name": "userId",
"value": "1"
},
{
"name": "username",
"value": "admin"
},
{
"name": "token",
"value": "eyJhbGciOiJIUzM4NCJ9.eyJyb2xlcyI6W10sInVzZXJJZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInN1YiI6ImFkbWluIiwiaWF0IjoxNzc1NTMzNzQ5LCJleHAiOjE3NzU2MjAxNDl9.FH-r-jQL6ojOAB0xjxj41mTiVnRl8vhMZ5yRuDjgbjI9Y1AzSLRveN6I7aGToelN"
}
]
}
]
}