fix(e2e): 修复测试失败问题
数据库修复: - 添加测试用户 'user'(密码:admin123) 测试代码优化: - 添加页面加载等待逻辑(waitForLoadState) - 添加元素可见性等待(waitFor visible) - 修复用户密码错误(user123 -> admin123) - 改进错误处理和稳定性
This commit is contained in:
@@ -14,13 +14,26 @@ test.describe('管理员完整工作流', () => {
|
||||
await expect(page).toHaveTitle(/登录/);
|
||||
});
|
||||
|
||||
await test.step('等待页面加载完成', async () => {
|
||||
await page.waitForLoadState('networkidle');
|
||||
await expect(page.locator('input[placeholder*="用户名"]')).toBeVisible({ timeout: 10000 });
|
||||
});
|
||||
|
||||
await test.step('输入管理员凭证', async () => {
|
||||
await page.locator('input[placeholder*="用户名"]').fill('admin');
|
||||
await page.locator('input[placeholder*="密码"]').fill('admin123');
|
||||
const usernameInput = page.locator('input[placeholder*="用户名"]');
|
||||
const passwordInput = page.locator('input[placeholder*="密码"]');
|
||||
|
||||
await usernameInput.waitFor({ state: 'visible' });
|
||||
await usernameInput.fill('admin');
|
||||
|
||||
await passwordInput.waitFor({ state: 'visible' });
|
||||
await passwordInput.fill('admin123');
|
||||
});
|
||||
|
||||
await test.step('点击登录按钮', async () => {
|
||||
await page.locator('button:has-text("登录")').click();
|
||||
const loginButton = page.locator('button:has-text("登录")');
|
||||
await loginButton.waitFor({ state: 'visible' });
|
||||
await loginButton.click();
|
||||
});
|
||||
|
||||
await test.step('验证登录成功', async () => {
|
||||
|
||||
Reference in New Issue
Block a user