26 lines
863 B
TypeScript
26 lines
863 B
TypeScript
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);
|
||
});
|
||
});
|