helpyourneighbour/backend/tests/auth.spec.js
OpenClaw 50431fa6a2
Some checks are pending
Docker Test / test (push) Waiting to run
test: add auth API integration tests
2026-03-07 02:17:23 +00:00

56 lines
No EOL
1.6 KiB
JavaScript

// Test für Auth-API Endpunkte
import { test, expect } from '@playwright/test';
test.describe('Auth API Tests', () => {
test('should register a new user', async ({ request }) => {
const response = await request.post('/auth/register', {
data: {
email: 'test@example.com',
password: 'password123',
name: 'Test User'
}
});
expect(response.status()).toBe(201);
const responseBody = await response.json();
expect(responseBody).toHaveProperty('userId');
expect(responseBody).toHaveProperty('email', 'test@example.com');
});
test('should login with valid credentials', async ({ request }) => {
const response = await request.post('/auth/login', {
data: {
email: 'test@example.com',
password: 'password123'
}
});
expect(response.status()).toBe(200);
const responseBody = await response.json();
expect(responseBody).toHaveProperty('token');
expect(responseBody).toHaveProperty('userId');
});
test('should not login with invalid credentials', async ({ request }) => {
const response = await request.post('/auth/login', {
data: {
email: 'test@example.com',
password: 'wrongpassword'
}
});
expect(response.status()).toBe(401);
});
test('should not register with existing email', async ({ request }) => {
const response = await request.post('/auth/register', {
data: {
email: 'test@example.com',
password: 'password123',
name: 'Test User'
}
});
expect(response.status()).toBe(409);
});
});