- Fix DI issues: circular MCP module dependency, EventBus type import, SearchModule provider, CacheService metric counters placement - Fix Express 5 readonly req.query in SanitizeInputMiddleware - Fix Typesense client lazy initialization (getter instead of constructor) - Fix MinIO bucket init error handling (non-fatal on 403) - Fix missing class-validator decorators on bigint DTO fields (priceVND, amountVND) - Fix subscription plan 404 (was returning 500 for invalid tier) - Disable CSRF and raise rate limits in test environment - Update E2E tests to match actual API response shapes - Update CI workflow with Redis, Typesense, MinIO services and env vars All 101 API E2E tests now pass against Docker dev environment. Co-Authored-By: Paperclip <noreply@paperclip.ing>
44 lines
1.2 KiB
TypeScript
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 };
|
|
}
|