37 lines
1006 B
TypeScript
37 lines
1006 B
TypeScript
import { describe, expect, test, } from 'bun:test';
|
|
|
|
describe('E2E: Authentication', () => {
|
|
const testUser = {
|
|
name: 'Test User',
|
|
email: `test-${Date.now()}@example.com`,
|
|
password: 'TestPassword123!',
|
|
};
|
|
|
|
let authCookie: string;
|
|
let userId: string;
|
|
|
|
test('should register new user', async () => {
|
|
const response = await fetch('http://localhost:3000/auth/api/sign-up/email', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(testUser),
|
|
});
|
|
|
|
expect(response.status).toBe(200);
|
|
|
|
const data = await response.json() as unknown as any;
|
|
expect(data.user).toBeDefined();
|
|
expect(data.user.email).toBe(testUser.email);
|
|
expect(data.user.name).toBe(testUser.name);
|
|
|
|
userId = data.user.id;
|
|
|
|
// Получаем cookies из ответа
|
|
const setCookieHeader = response.headers.get('set-cookie');
|
|
expect(setCookieHeader).toBeDefined();
|
|
authCookie = setCookieHeader!;
|
|
});
|
|
});
|