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,4 +1,5 @@
import { test, expect } from '@playwright/test';
import { mockAuthenticatedUser } from './support/auth';
const mockDashboardStats = {
totalUsers: 1250,
@@ -6,29 +7,29 @@ const mockDashboardStats = {
totalListings: 3400,
newListingsLast30Days: 320,
activeListings: 2800,
pendingModeration: 45,
pendingModerationCount: 45,
totalAgents: 180,
verifiedAgents: 120,
totalTransactions: 560,
};
const mockRevenue = {
data: [
{ period: '2025-10', totalRevenue: 150000000, subscriptionRevenue: 100000000, transactionRevenue: 50000000 },
{ period: '2025-11', totalRevenue: 180000000, subscriptionRevenue: 120000000, transactionRevenue: 60000000 },
{ period: '2025-12', totalRevenue: 200000000, subscriptionRevenue: 130000000, transactionRevenue: 70000000 },
{ period: '2026-01', totalRevenue: 220000000, subscriptionRevenue: 140000000, transactionRevenue: 80000000 },
{ period: '2026-02', totalRevenue: 250000000, subscriptionRevenue: 160000000, transactionRevenue: 90000000 },
{ period: '2026-03', totalRevenue: 280000000, subscriptionRevenue: 180000000, transactionRevenue: 100000000 },
],
};
const mockRevenue = [
{ period: '2025-10', totalRevenue: 150000000, subscriptionRevenue: 100000000, listingFeeRevenue: 30000000, featuredListingRevenue: 20000000, transactionCount: 12 },
{ period: '2025-11', totalRevenue: 180000000, subscriptionRevenue: 120000000, listingFeeRevenue: 35000000, featuredListingRevenue: 25000000, transactionCount: 14 },
{ period: '2025-12', totalRevenue: 200000000, subscriptionRevenue: 130000000, listingFeeRevenue: 40000000, featuredListingRevenue: 30000000, transactionCount: 15 },
{ period: '2026-01', totalRevenue: 220000000, subscriptionRevenue: 140000000, listingFeeRevenue: 50000000, featuredListingRevenue: 30000000, transactionCount: 16 },
{ period: '2026-02', totalRevenue: 250000000, subscriptionRevenue: 160000000, listingFeeRevenue: 55000000, featuredListingRevenue: 35000000, transactionCount: 18 },
{ period: '2026-03', totalRevenue: 280000000, subscriptionRevenue: 180000000, listingFeeRevenue: 60000000, featuredListingRevenue: 40000000, transactionCount: 20 },
];
test.describe('Admin Dashboard', () => {
test.beforeEach(async ({ page }) => {
await page.route('**/admin/dashboard**', (route) =>
test.beforeEach(async ({ page, context, baseURL }) => {
await mockAuthenticatedUser(page, context, baseURL, { role: 'ADMIN' });
await page.route('**/api/v1/admin/dashboard**', (route) =>
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockDashboardStats) }),
);
await page.route('**/admin/revenue**', (route) =>
await page.route('**/api/v1/admin/revenue**', (route) =>
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockRevenue) }),
);
});
@@ -49,7 +50,7 @@ test.describe('Admin Dashboard', () => {
});
test('handles API failure gracefully', async ({ page }) => {
await page.route('**/admin/dashboard**', (route) =>
await page.route('**/api/v1/admin/dashboard**', (route) =>
route.fulfill({ status: 500, body: 'Error' }),
);