Files
goodgo-platform/e2e/api/auth-login.spec.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

40 lines
1.2 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { createTestUser, registerUser } from '../fixtures';
test.describe('POST /auth/login', () => {
test('logs in with valid credentials and returns token pair', async ({ request }) => {
const user = createTestUser();
await registerUser(request, user);
const res = await request.post('auth/login', {
data: { phone: user.phone, password: user.password },
});
expect(res.status()).toBe(201);
const body = await res.json();
expect(body).toHaveProperty('accessToken');
expect(body).toHaveProperty('refreshToken');
});
test('rejects login with wrong password', async ({ request }) => {
const user = createTestUser();
await registerUser(request, user);
const res = await request.post('auth/login', {
data: { phone: user.phone, password: 'WrongPassword!1' },
});
expect(res.ok()).toBeFalsy();
expect(res.status()).toBe(401);
});
test('rejects login with non-existent phone', async ({ request }) => {
const res = await request.post('auth/login', {
data: { phone: '0900000001', password: 'Test@1234!' },
});
expect(res.ok()).toBeFalsy();
expect(res.status()).toBe(401);
});
});