test(e2e): 改进 Playwright 测试框架和 E2E 测试

- 更新 Playwright 配置,添加认证状态管理和 setup 项目
- 优化 E2E 测试用例,简化测试流程
- 添加 auth-debug.spec.ts 用于调试认证问题
- 添加 playwright/.auth/user.json 认证状态文件
This commit is contained in:
张翔
2026-04-18 13:06:07 +08:00
parent a2bb6be0b9
commit 44215d3b2d
16 changed files with 235 additions and 292 deletions
@@ -4,13 +4,16 @@ test.describe('文件管理工作流', () => {
test('文件上传流程', async ({ page }) => {
await test.step('导航到文件管理', async () => {
await page.goto('/dashboard');
await page.waitForLoadState('networkidle');
await page.waitForLoadState('domcontentloaded');
await page.waitForTimeout(1000);
await page.locator('text=系统管理').waitFor({ state: 'visible', timeout: 5000 });
await page.locator('text=系统管理').click();
await page.waitForTimeout(500);
await page.locator('.el-menu-item:has-text("文件管理")').waitFor({ state: 'visible', timeout: 5000 });
await page.locator('.el-menu-item:has-text("文件管理")').click();
await page.waitForLoadState('networkidle');
await page.waitForLoadState('domcontentloaded');
await page.waitForTimeout(1000);
await expect(page.locator('.el-table')).toBeVisible({ timeout: 10000 });
@@ -48,7 +51,6 @@ test.describe('文件管理工作流', () => {
const searchInput = page.locator('input[placeholder*="搜索"]');
if (await searchInput.isVisible()) {
await searchInput.fill('test');
await page.locator('button:has-text("搜索")').click();
await page.waitForTimeout(1000);
}
});
@@ -78,7 +80,7 @@ test.describe('文件管理工作流', () => {
});
await test.step('删除文件', async () => {
const deleteButton = page.locator('button:has-text("删除")');
const deleteButton = page.locator('button:has-text("删除")').first();
if (await deleteButton.isVisible()) {
await deleteButton.click();
await page.locator('button:has-text("确定")').click();