Files
goodgo-platform/e2e/web/listing-detail.spec.ts
2026-05-04 20:11:09 +07:00

124 lines
5.5 KiB
TypeScript

import { test, expect } from '@playwright/test';
const seededListingId = 'seed-listing-001';
const listingPath = `/listings/${seededListingId}`;
const listingTitle = /Căn hộ Vinhomes Central Park|Vinhomes Central Park/i;
test.describe('Listing Detail Page', () => {
test('renders listing title and price', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByRole('heading', { name: listingTitle })).toBeVisible({
timeout: 10000,
});
await expect(page.getByText('8.500.000.000 đ').first()).toBeVisible();
});
test('displays breadcrumb navigation', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.locator('#main-content').getByRole('link', { name: /Trang chủ|Trang chu/i })).toBeVisible();
await expect(page.locator('#main-content').getByRole('link', { name: /Tìm kiếm|Tim kiem/i })).toBeVisible();
});
test('shows property badges', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByText(/Bán|Sale/i).first()).toBeVisible();
await expect(page.getByText(/Căn hộ|Apartment/i).first()).toBeVisible();
});
test('displays address information', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByText(/208 Nguyễn Hữu Cảnh/i)).toBeVisible();
await expect(page.getByText(/Phường 22/i)).toBeVisible();
await expect(page.getByText(/Bình Thạnh/i)).toBeVisible();
});
test('shows quick stats bar', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByText('108 m²').first()).toBeVisible();
await expect(page.getByText(/Diện tích|Dien tich/i).first()).toBeVisible();
await expect(page.getByText(/Phòng ngủ|Phong ngu/i).first()).toBeVisible();
await expect(page.getByText(/Phòng tắm|Phong tam/i).first()).toBeVisible();
});
test('displays description section', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByRole('heading', { name: /Mô tả|Mo ta/i })).toBeVisible();
await expect(page.locator('#main-content').getByText(/Căn hộ 3 phòng ngủ tại/i).first()).toBeVisible();
});
test('shows detailed property info grid', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByRole('heading', { name: /Thông tin chi tiết|Thong tin chi tiet/i })).toBeVisible();
await expect(page.locator('#main-content').getByText(/Loại BĐS|Loai BDS|Loại bất động sản/i).first()).toBeVisible();
await expect(page.getByText(/SO_HONG|Sổ hồng|So hong/i).first()).toBeVisible();
await expect(page.getByText(/Vinhomes Central Park/i).first()).toBeVisible();
});
test('displays amenities', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByRole('heading', { name: /Tiện ích|Tien ich/i })).toBeVisible();
await expect(page.getByText(/hồ bơi/i)).toBeVisible();
await expect(page.getByText(/gym/i)).toBeVisible();
});
test('shows seller contact card', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByText(/Liên hệ người đăng|Liên hệ|Lien he/i).first()).toBeVisible();
await expect(page.getByRole('button', { name: /Gọi ngay|Goi ngay/i })).toBeVisible();
await expect(page.getByRole('button', { name: /Nhắn tin|Nhan tin/i })).toBeVisible();
});
test('shows agent info when available', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByText(/Môi giới|Moi gioi|Hoa hồng|Hoa hong/i).first()).toBeVisible();
await expect(page.getByText(/2%|2\.0%/)).toBeVisible();
});
test('displays listing statistics', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await expect(page.getByText(/Lượt xem|Luot xem/i)).toBeVisible();
await expect(page.getByText(/Lượt lưu|Luot luu/i)).toBeVisible();
});
test('shows error state for non-existent listing', async ({ page }) => {
await page.goto('/listings/nonexistent');
await expect(page.getByRole('heading', { name: /Không tìm thấy trang|not found/i })).toBeVisible({ timeout: 10000 });
});
test('renders page after server fetch', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByRole('heading', { name: listingTitle })).toBeVisible({ timeout: 10000 });
});
test('breadcrumb navigates to search page', async ({ page }) => {
await page.goto(listingPath);
await expect(page.getByText(listingTitle).first()).toBeVisible({ timeout: 10000 });
await page.locator('#main-content').getByRole('link', { name: /Tìm kiếm|Tim kiem/i }).click();
await expect(page).toHaveURL(/\/search/);
});
});