- Fix DI issues: circular MCP module dependency, EventBus type import, SearchModule provider, CacheService metric counters placement - Fix Express 5 readonly req.query in SanitizeInputMiddleware - Fix Typesense client lazy initialization (getter instead of constructor) - Fix MinIO bucket init error handling (non-fatal on 403) - Fix missing class-validator decorators on bigint DTO fields (priceVND, amountVND) - Fix subscription plan 404 (was returning 500 for invalid tier) - Disable CSRF and raise rate limits in test environment - Update E2E tests to match actual API response shapes - Update CI workflow with Redis, Typesense, MinIO services and env vars All 101 API E2E tests now pass against Docker dev environment. Co-Authored-By: Paperclip <noreply@paperclip.ing>
31 lines
984 B
TypeScript
31 lines
984 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);
|
|
});
|
|
});
|