helpyourneighbour/backend/tests/contacts.spec.js

28 lines
743 B
JavaScript
Raw Normal View History

import { test, expect } from '@playwright/test';
test.describe('Contacts API', () => {
test('should get contacts (unauthenticated)', async ({ request }) => {
const response = await request.get('/contacts');
// Should return 401 for unauthorized access
expect(response.status()).toBe(401);
});
test('should validate contact data on creation', async ({ request }) => {
const invalidContact = {
name: '',
email: 'invalid-email',
phone: ''
};
const response = await request.post('/contacts', {
headers: {
'Content-Type': 'application/json'
},
data: invalidContact
});
// Should return 400 for invalid data
expect(response.status()).toBe(400);
});
});