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>
This commit is contained in:
@@ -12,7 +12,7 @@ test.describe('Listings API', () => {
|
||||
test.describe('POST /listings — Create listing', () => {
|
||||
test('creates a listing with valid data', async ({ request }) => {
|
||||
const data = createTestListing();
|
||||
const res = await request.post('/listings', {
|
||||
const res = await request.post('listings', {
|
||||
data,
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
@@ -24,7 +24,7 @@ test.describe('Listings API', () => {
|
||||
});
|
||||
|
||||
test('rejects listing with missing required fields', async ({ request }) => {
|
||||
const res = await request.post('/listings', {
|
||||
const res = await request.post('listings', {
|
||||
data: { title: 'Incomplete' },
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
@@ -35,7 +35,7 @@ test.describe('Listings API', () => {
|
||||
|
||||
test('rejects listing with invalid property type', async ({ request }) => {
|
||||
const data = createTestListing({ propertyType: 'INVALID_TYPE' });
|
||||
const res = await request.post('/listings', {
|
||||
const res = await request.post('listings', {
|
||||
data,
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
@@ -45,7 +45,7 @@ test.describe('Listings API', () => {
|
||||
});
|
||||
|
||||
test('rejects unauthenticated request', async ({ request }) => {
|
||||
const res = await request.post('/listings', {
|
||||
const res = await request.post('listings', {
|
||||
data: createTestListing(),
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ test.describe('Listings API', () => {
|
||||
transactionType: 'RENT',
|
||||
rentPriceMonthly: '15000000',
|
||||
});
|
||||
const res = await request.post('/listings', {
|
||||
const res = await request.post('listings', {
|
||||
data,
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
@@ -71,7 +71,7 @@ test.describe('Listings API', () => {
|
||||
|
||||
test.describe('GET /listings — Search listings', () => {
|
||||
test('returns paginated listing results', async ({ request }) => {
|
||||
const res = await request.get('/listings');
|
||||
const res = await request.get('listings');
|
||||
|
||||
expect(res.ok()).toBeTruthy();
|
||||
const body = await res.json();
|
||||
@@ -81,7 +81,7 @@ test.describe('Listings API', () => {
|
||||
});
|
||||
|
||||
test('filters by property type', async ({ request }) => {
|
||||
const res = await request.get('/listings', {
|
||||
const res = await request.get('listings', {
|
||||
params: { propertyType: 'APARTMENT' },
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ test.describe('Listings API', () => {
|
||||
});
|
||||
|
||||
test('filters by transaction type', async ({ request }) => {
|
||||
const res = await request.get('/listings', {
|
||||
const res = await request.get('listings', {
|
||||
params: { transactionType: 'SALE' },
|
||||
});
|
||||
|
||||
@@ -105,7 +105,7 @@ test.describe('Listings API', () => {
|
||||
});
|
||||
|
||||
test('filters by city', async ({ request }) => {
|
||||
const res = await request.get('/listings', {
|
||||
const res = await request.get('listings', {
|
||||
params: { city: 'Hồ Chí Minh' },
|
||||
});
|
||||
|
||||
@@ -113,7 +113,7 @@ test.describe('Listings API', () => {
|
||||
});
|
||||
|
||||
test('paginates correctly', async ({ request }) => {
|
||||
const res = await request.get('/listings', {
|
||||
const res = await request.get('listings', {
|
||||
params: { page: 1, limit: 2 },
|
||||
});
|
||||
|
||||
@@ -128,7 +128,7 @@ test.describe('Listings API', () => {
|
||||
// First create a listing
|
||||
const { listing } = await createListing(request, accessToken);
|
||||
|
||||
const res = await request.get(`/listings/${listing.listingId}`);
|
||||
const res = await request.get(`listings/${listing.listingId}`);
|
||||
|
||||
expect(res.status()).toBe(200);
|
||||
const body = await res.json();
|
||||
@@ -139,7 +139,7 @@ test.describe('Listings API', () => {
|
||||
});
|
||||
|
||||
test('returns 404 for non-existent listing', async ({ request }) => {
|
||||
const res = await request.get('/listings/non-existent-id-12345');
|
||||
const res = await request.get('listings/non-existent-id-12345');
|
||||
|
||||
expect(res.ok()).toBeFalsy();
|
||||
expect([404, 400]).toContain(res.status());
|
||||
@@ -150,7 +150,7 @@ test.describe('Listings API', () => {
|
||||
test('updates listing status', async ({ request }) => {
|
||||
const { listing } = await createListing(request, accessToken);
|
||||
|
||||
const res = await request.patch(`/listings/${listing.listingId}/status`, {
|
||||
const res = await request.patch(`listings/${listing.listingId}/status`, {
|
||||
data: { status: 'ACTIVE' },
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
@@ -162,7 +162,7 @@ test.describe('Listings API', () => {
|
||||
test('rejects invalid status value', async ({ request }) => {
|
||||
const { listing } = await createListing(request, accessToken);
|
||||
|
||||
const res = await request.patch(`/listings/${listing.listingId}/status`, {
|
||||
const res = await request.patch(`listings/${listing.listingId}/status`, {
|
||||
data: { status: 'INVALID_STATUS' },
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
});
|
||||
@@ -174,7 +174,7 @@ test.describe('Listings API', () => {
|
||||
test('rejects unauthenticated status update', async ({ request }) => {
|
||||
const { listing } = await createListing(request, accessToken);
|
||||
|
||||
const res = await request.patch(`/listings/${listing.listingId}/status`, {
|
||||
const res = await request.patch(`listings/${listing.listingId}/status`, {
|
||||
data: { status: 'ACTIVE' },
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user