feat(e2e): add Playwright E2E testing infrastructure and critical path tests
Set up Playwright with dual-project config (API + Web), auth test fixtures, 16 E2E tests covering registration, login, profile, token refresh, and homepage rendering. Added GitHub Actions CI workflow for automated E2E runs. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
29
e2e/api/auth-profile.spec.ts
Normal file
29
e2e/api/auth-profile.spec.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
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');
|
||||
expect(body.phone).toBe(testUser.phone);
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user