This commit is contained in:
25
e2e/api/auth.spec.ts
Normal file
25
e2e/api/auth.spec.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
const API = '/api';
|
||||
|
||||
test.describe('Android API – auth', () => {
|
||||
test('login returns token', async ({ request }) => {
|
||||
const res = await request.post(`${API}/auth/login`, {
|
||||
data: { username: 'testadmin', password: 'testpass123' },
|
||||
});
|
||||
expect(res.ok()).toBeTruthy();
|
||||
const json = await res.json();
|
||||
expect(json.ok).toBe(true);
|
||||
expect(json.data.token).toBeTruthy();
|
||||
expect(json.data.role).toBe('admin');
|
||||
});
|
||||
|
||||
test('bad password returns error', async ({ request }) => {
|
||||
const res = await request.post(`${API}/auth/login`, {
|
||||
data: { username: 'testadmin', password: 'wrong' },
|
||||
});
|
||||
expect(res.status()).toBe(401);
|
||||
const json = await res.json();
|
||||
expect(json.ok).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user