test(e2e): align web specs with current app routes

This commit is contained in:
Ho Ngoc Hai
2026-05-04 20:11:09 +07:00
parent f112045826
commit 39156fc107
21 changed files with 334 additions and 458 deletions

View File

@@ -1,26 +1,29 @@
import { test, expect } from '@playwright/test';
import { mockAuthenticatedUser } from './support/auth';
const mockUsers = {
data: [
{
id: 'u1', fullName: 'Nguyen Van A', phone: '0912345678', email: 'a@test.com',
role: 'USER', kycStatus: 'VERIFIED', status: 'ACTIVE', createdAt: '2025-12-01T00:00:00Z',
role: 'USER', kycStatus: 'VERIFIED', isActive: true, createdAt: '2025-12-01T00:00:00Z',
},
{
id: 'u2', fullName: 'Tran Thi B', phone: '0987654321', email: 'b@test.com',
role: 'AGENT', kycStatus: 'PENDING', status: 'ACTIVE', createdAt: '2026-01-15T00:00:00Z',
role: 'AGENT', kycStatus: 'PENDING', isActive: true, createdAt: '2026-01-15T00:00:00Z',
},
{
id: 'u3', fullName: 'Le Van C', phone: '0909123456', email: null,
role: 'ADMIN', kycStatus: 'VERIFIED', status: 'LOCKED', createdAt: '2025-11-01T00:00:00Z',
role: 'ADMIN', kycStatus: 'VERIFIED', isActive: false, createdAt: '2025-11-01T00:00:00Z',
},
],
total: 3, page: 1, limit: 20, totalPages: 1,
};
test.describe('Admin Users Management', () => {
test.beforeEach(async ({ page }) => {
await page.route('**/admin/users**', (route) => {
test.beforeEach(async ({ page, context, baseURL }) => {
await mockAuthenticatedUser(page, context, baseURL, { role: 'ADMIN' });
await page.route('**/api/v1/admin/users**', (route) => {
if (route.request().method() === 'GET') {
return route.fulfill({
status: 200,
@@ -53,12 +56,12 @@ test.describe('Admin Users Management', () => {
await page.goto('/admin/users');
// Search input should exist
const searchInput = page.getByPlaceholder(/Tim kiem|Search/i);
const searchInput = page.getByPlaceholder(/Tìm theo tên|Tim kiem|Search/i);
await expect(searchInput).toBeVisible({ timeout: 10000 });
});
test('handles empty user list', async ({ page }) => {
await page.route('**/admin/users**', (route) =>
await page.route('**/api/v1/admin/users**', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',