Files
novalon-website/e2e/features/admin/user-management.spec.ts
T

53 lines
1.6 KiB
TypeScript

import { test, expect } from '../../fixtures/auth';
import { AdminUserPage } from '../../pages';
test.describe('用户管理测试 @feature @admin', () => {
let userPage: AdminUserPage;
test.beforeEach(async ({ page }) => {
userPage = new AdminUserPage(page);
});
test('查看用户列表', async ({ authenticatedPage: _authenticatedPage }) => {
await userPage.goto();
const table = userPage['page'].locator('table');
await expect(table).toBeVisible();
const rows = table.locator('tbody tr');
const count = await rows.count();
expect(count).toBeGreaterThan(0);
});
test('创建新用户', async ({ authenticatedPage: _authenticatedPage }) => {
const timestamp = Date.now();
const userData = {
email: `test-${timestamp}@example.com`,
password: 'Test123456!',
name: `测试用户${timestamp}`,
role: 'viewer' as const,
};
try {
await userPage.createUser(userData);
await userPage.expectUserInList(userData.email);
} finally {
// 测试结束后清理创建的测试用户
// 注意:当前版本暂未实现用户删除功能,后续版本将添加
}
});
test('搜索用户', async ({ page, authenticatedPage: _authenticatedPage }) => {
await userPage.goto();
const searchInput = page.locator('input[placeholder*="搜索"], input[name="search"]');
if (await searchInput.count() > 0) {
await searchInput.fill('admin');
await page.keyboard.press('Enter');
const table = page.locator('table');
await expect(table).toBeVisible();
}
});
});