44215d3b2d
- 更新 Playwright 配置,添加认证状态管理和 setup 项目 - 优化 E2E 测试用例,简化测试流程 - 添加 auth-debug.spec.ts 用于调试认证问题 - 添加 playwright/.auth/user.json 认证状态文件
17 lines
550 B
TypeScript
17 lines
550 B
TypeScript
import { test as setup } from '@playwright/test';
|
|
|
|
const authFile = 'playwright/.auth/user.json';
|
|
|
|
setup('authenticate', async ({ page }) => {
|
|
await page.goto('/login');
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
await page.locator('input[placeholder*="用户名"]').fill('admin');
|
|
await page.locator('input[placeholder*="密码"]').fill('Test@123');
|
|
await page.locator('button:has-text("登录")').click();
|
|
|
|
await page.waitForURL('**/dashboard', { timeout: 30000 });
|
|
|
|
await page.context().storageState({ path: authFile });
|
|
});
|