test(e2e): align web specs with current app routes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { mockAuthenticatedUser } from './support/auth';
|
||||
|
||||
const mockValuationResult = {
|
||||
id: 'val-e2e-1',
|
||||
@@ -40,17 +41,10 @@ const mockValuationResult = {
|
||||
const mockHistory = { data: [], total: 0, page: 1, totalPages: 1, limit: 10 };
|
||||
|
||||
async function setupMocks(page: import('@playwright/test').Page) {
|
||||
await page.route('**/auth/me', (route) =>
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ id: 'u1', email: 'e2e@test.vn', fullName: 'E2E User', role: 'USER' }),
|
||||
}),
|
||||
);
|
||||
await page.route('**/analytics/valuation/history**', (route) =>
|
||||
await page.route('**/api/v1/analytics/valuation/user-history**', (route) =>
|
||||
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockHistory) }),
|
||||
);
|
||||
await page.route('**/analytics/valuation', (route) => {
|
||||
await page.route('**/api/v1/analytics/valuation', (route) => {
|
||||
if (route.request().method() === 'POST') {
|
||||
return route.fulfill({
|
||||
status: 200,
|
||||
@@ -63,7 +57,8 @@ async function setupMocks(page: import('@playwright/test').Page) {
|
||||
}
|
||||
|
||||
test.describe('AVM v2 Valuation Page', () => {
|
||||
test('submit form -> render result card with confidence + price range', async ({ page }) => {
|
||||
test('submit form -> render result card with confidence + price range', async ({ page, context, baseURL }) => {
|
||||
await mockAuthenticatedUser(page, context, baseURL, { role: 'AGENT' });
|
||||
await setupMocks(page);
|
||||
await page.goto('/vi/dashboard/valuation');
|
||||
|
||||
@@ -75,23 +70,17 @@ test.describe('AVM v2 Valuation Page', () => {
|
||||
|
||||
const results = page.locator('#valuation-results');
|
||||
await expect(results).toBeVisible();
|
||||
await expect(results).toContainText('5.500.000.000');
|
||||
await expect(results).toContainText('5.5 tỷ VNĐ');
|
||||
await expect(results).toContainText('Độ tin cậy cao');
|
||||
await expect(results).toContainText('avm-v2.0');
|
||||
await expect(results).toContainText('Khoảng giá');
|
||||
});
|
||||
|
||||
test('renders rate-limit error state on HTTP 429', async ({ page }) => {
|
||||
await page.route('**/auth/me', (route) =>
|
||||
route.fulfill({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
body: JSON.stringify({ id: 'u1', email: 'e2e@test.vn', fullName: 'E2E User', role: 'USER' }),
|
||||
}),
|
||||
);
|
||||
await page.route('**/analytics/valuation/history**', (route) =>
|
||||
test('renders rate-limit error state on HTTP 429', async ({ page, context, baseURL }) => {
|
||||
await mockAuthenticatedUser(page, context, baseURL, { role: 'AGENT' });
|
||||
await page.route('**/api/v1/analytics/valuation/user-history**', (route) =>
|
||||
route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(mockHistory) }),
|
||||
);
|
||||
await page.route('**/analytics/valuation', (route) => {
|
||||
await page.route('**/api/v1/analytics/valuation', (route) => {
|
||||
if (route.request().method() === 'POST') {
|
||||
return route.fulfill({
|
||||
status: 429,
|
||||
@@ -113,7 +102,8 @@ test.describe('AVM v2 Valuation Page', () => {
|
||||
await expect(alert).toContainText('Quá nhiều yêu cầu');
|
||||
});
|
||||
|
||||
test('export PDF button is visible after a successful valuation', async ({ page }) => {
|
||||
test('export PDF button is visible after a successful valuation', async ({ page, context, baseURL }) => {
|
||||
await mockAuthenticatedUser(page, context, baseURL, { role: 'AGENT' });
|
||||
await setupMocks(page);
|
||||
await page.goto('/vi/dashboard/valuation');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user