test(e2e): add comprehensive E2E tests for listings, search, payments, subscriptions, admin
Expand Playwright E2E test coverage from 17 to 86 tests covering: - Listings CRUD (create, search, filter, detail, status update) - Search (text search, geo search, validation, Typesense fallback) - Payments (create, list transactions, auth guards) - Subscriptions (plans, create, quota, billing, usage metering) - Admin authorization guards (all endpoints reject non-admin users) Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export { test, expect } from './auth.fixture';
|
||||
export { createTestUser, registerUser, loginUser } from './auth.fixture';
|
||||
export type { TokenPair } from './auth.fixture';
|
||||
export { createTestListing, createListing } from './listings.fixture';
|
||||
|
||||
43
e2e/fixtures/listings.fixture.ts
Normal file
43
e2e/fixtures/listings.fixture.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
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 id + full response. */
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user