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

53 lines
1.6 KiB
TypeScript

import { test, expect } from '@playwright/test';
import { createTestUser } from '../fixtures';
test.describe('POST /auth/register', () => {
test('registers a new user and returns token pair', async ({ request }) => {
const user = createTestUser();
const res = await request.post('auth/register', { data: user });
expect(res.status()).toBe(201);
const body = await res.json();
expect(body).toHaveProperty('accessToken');
expect(body).toHaveProperty('refreshToken');
expect(typeof body.accessToken).toBe('string');
expect(typeof body.refreshToken).toBe('string');
});
test('rejects duplicate phone registration', async ({ request }) => {
const user = createTestUser();
// First registration should succeed
const first = await request.post('auth/register', { data: user });
expect(first.ok()).toBeTruthy();
// Second registration with same phone should fail
const second = await request.post('auth/register', { data: user });
expect(second.ok()).toBeFalsy();
expect(second.status()).toBeGreaterThanOrEqual(400);
});
test('rejects registration with missing required fields', async ({ request }) => {
const res = await request.post('auth/register', {
data: { phone: '0912345678' },
});
expect(res.ok()).toBeFalsy();
expect(res.status()).toBe(400);
});
test('rejects registration with short password', async ({ request }) => {
const res = await request.post('auth/register', {
data: {
phone: '0912345678',
password: 'short',
fullName: 'Test',
},
});
expect(res.ok()).toBeFalsy();
expect(res.status()).toBe(400);
});
});