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:
39
e2e/api/auth-login.spec.ts
Normal file
39
e2e/api/auth-login.spec.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user