229fb77e76
- Fix fillUserForm method to use correct input indices - Add localStorage cleanup in beforeEach hook - Update all tests to use e2e_test_user account - Add debug and simple login tests for troubleshooting Root cause: Phone field was not being filled correctly, causing 400 error from backend with message '手机号不能为空'
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { LoginPage } from './pages/LoginPage';
|
|
import { DashboardPage } from './pages/DashboardPage';
|
|
import { UserManagementPage } from './pages/UserManagementPage';
|
|
|
|
test.describe('简单登录测试', () => {
|
|
let loginPage: LoginPage;
|
|
let dashboardPage: DashboardPage;
|
|
let userManagementPage: UserManagementPage;
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
loginPage = new LoginPage(page);
|
|
dashboardPage = new DashboardPage(page);
|
|
userManagementPage = new UserManagementPage(page);
|
|
|
|
// 清理localStorage
|
|
await page.goto('/');
|
|
await page.evaluate(() => localStorage.clear());
|
|
|
|
// 重新登录
|
|
await loginPage.goto();
|
|
await loginPage.login('e2e_test_user', 'admin123');
|
|
});
|
|
|
|
test('登录后导航到用户管理页面', async ({ page }) => {
|
|
await dashboardPage.navigateToUserManagement();
|
|
await expect(page).toHaveURL(/.*users/);
|
|
|
|
// 验证表格存在
|
|
await expect(userManagementPage.table).toBeVisible();
|
|
|
|
// 验证"新增用户"按钮存在
|
|
await expect(userManagementPage.createUserButton).toBeVisible();
|
|
});
|
|
|
|
test('点击新增用户按钮', async ({ page }) => {
|
|
await dashboardPage.navigateToUserManagement();
|
|
|
|
// 点击新增用户按钮
|
|
await userManagementPage.clickCreateUser();
|
|
|
|
// 验证对话框出现
|
|
const dialog = page.locator('.el-dialog');
|
|
await expect(dialog).toBeVisible();
|
|
|
|
// 验证对话框标题
|
|
const dialogTitle = dialog.locator('.el-dialog__title');
|
|
await expect(dialogTitle).toContainText('新增用户');
|
|
});
|
|
});
|