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,17 +1,19 @@
import { test, expect } from '@playwright/test';
import { mockAuthenticatedUser } from './support/auth';
test.describe('Create Listing Page (Multi-step Form)', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/listings/new');
test.beforeEach(async ({ page, context, baseURL }) => {
await mockAuthenticatedUser(page, context, baseURL, { role: 'AGENT' });
await page.goto('/my-listings/new');
});
test('renders step 1 - basic info form', async ({ page }) => {
// Step indicators should be visible
await expect(page.getByText('Thông tin')).toBeVisible();
await expect(page.getByText('Vị trí')).toBeVisible();
await expect(page.getByText('Chi tiết')).toBeVisible();
await expect(page.getByText('Giá cả')).toBeVisible();
await expect(page.getByText('Hình ảnh')).toBeVisible();
await expect(page.getByText('Thông tin', { exact: true })).toBeVisible();
await expect(page.getByText('Vị trí', { exact: true })).toBeVisible();
await expect(page.getByText('Chi tiết', { exact: true })).toBeVisible();
await expect(page.getByText('Giá cả', { exact: true })).toBeVisible();
await expect(page.getByText('Hình ảnh', { exact: true })).toBeVisible();
});
test('shows validation errors when advancing without filling required fields', async ({ page }) => {
@@ -33,7 +35,7 @@ test.describe('Create Listing Page (Multi-step Form)', () => {
});
test('shows error alert on submission failure', async ({ page }) => {
await page.route('**/listings', (route) => {
await page.route('**/api/v1/listings', (route) => {
if (route.request().method() === 'POST') {
return route.fulfill({
status: 400,
@@ -45,6 +47,6 @@ test.describe('Create Listing Page (Multi-step Form)', () => {
});
// Page should render without errors
await expect(page.getByText('Thông tin')).toBeVisible();
await expect(page.getByText('Thông tin', { exact: true })).toBeVisible();
});
});