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

31 lines
981 B
TypeScript

import { test, expect } from '../fixtures';
test.describe('GET /auth/profile', () => {
test('returns user profile for authenticated user', async ({ authedRequest, testUser }) => {
const res = await authedRequest.get('auth/profile');
expect(res.status()).toBe(200);
const body = await res.json();
expect(body).toHaveProperty('id');
// API normalises phone to +84 format
expect(body.phone).toContain(testUser.phone.slice(1));
expect(body.fullName).toBe(testUser.fullName);
});
test('rejects unauthenticated requests', async ({ request }) => {
const res = await request.get('auth/profile');
expect(res.ok()).toBeFalsy();
expect(res.status()).toBe(401);
});
test('rejects requests with invalid token', async ({ request }) => {
const res = await request.get('auth/profile', {
headers: { Authorization: 'Bearer invalid.jwt.token' },
});
expect(res.ok()).toBeFalsy();
expect(res.status()).toBe(401);
});
});