Add Playwright tests for contacts API and cleanup duplicate config files
This commit is contained in:
parent
1e91647618
commit
5d5b2460b5
4 changed files with 52 additions and 29 deletions
28
backend/tests/contacts.spec.js
Normal file
28
backend/tests/contacts.spec.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue