Files
goodgo-platform/e2e/fixtures/listings.fixture.ts
Ho Ngoc Hai da10ac64c6 test(e2e): update all E2E specs for latest API and fixtures
Update 17 E2E test files including admin, auth, inquiries, listings,
payments, search, subscriptions, and MCP specs. Update listings fixture
and global setup to align with latest schema changes.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-11 01:40:45 +07:00

44 lines
1.2 KiB
TypeScript

import { type APIRequestContext } from '@playwright/test';
/** Creates a valid listing payload for E2E tests. */
export function createTestListing(overrides: Record<string, unknown> = {}) {
const suffix = Date.now();
return {
transactionType: 'SALE',
propertyType: 'APARTMENT',
title: `Test Listing ${suffix}`,
description: `E2E test listing description for automated testing ${suffix}`,
address: '123 Nguyễn Huệ',
ward: 'Bến Nghé',
district: 'Quận 1',
city: 'Hồ Chí Minh',
latitude: 10.7769,
longitude: 106.7009,
areaM2: 75,
priceVND: '5000000000',
bedrooms: 2,
bathrooms: 2,
floors: 1,
direction: 'SOUTH',
...overrides,
};
}
/** Creates a listing via the API and returns its response + original data. */
export async function createListing(
request: APIRequestContext,
accessToken: string,
overrides: Record<string, unknown> = {},
) {
const data = createTestListing(overrides);
const res = await request.post('listings', {
data,
headers: { Authorization: `Bearer ${accessToken}` },
});
if (!res.ok()) {
const body = await res.text();
throw new Error(`Create listing failed (${res.status()}): ${body}`);
}
return { listing: await res.json(), data };
}