Files
nat-as-server/e2e/api/auth.spec.ts
tom.hempel 06fc134299
Some checks failed
Tests / test (push) Has been cancelled
just testing the environment
2026-05-20 07:10:08 +02:00

26 lines
863 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
});
});