1
0
Fork 0
mirror of https://github.com/s-frick/effigenix.git synced 2026-03-28 15:29:34 +01:00

init e2e ui tests base skeleton

This commit is contained in:
Janosch 2026-03-27 09:41:35 +01:00
parent 83c7321c8f
commit c84629cc4e
16 changed files with 1219 additions and 0 deletions

View file

@ -0,0 +1,34 @@
import { test as base, expect } from '@playwright/test';
type AuthFixtures = {
adminToken: string;
viewerToken: string;
};
export const test = base.extend<AuthFixtures>({
adminToken: async ({ request }, use) => {
const res = await request.post('/api/auth/login', {
data: {
username: process.env.TEST_USER_ADMIN ?? 'admin',
password: process.env.TEST_USER_ADMIN_PASS ?? 'admin123',
},
});
expect(res.status()).toBe(200);
const { token } = await res.json();
await use(token);
},
viewerToken: async ({ request }, use) => {
const res = await request.post('/api/auth/login', {
data: {
username: process.env.TEST_USER_VIEWER ?? 'viewer',
password: process.env.TEST_USER_VIEWER_PASS ?? 'viewer123',
},
});
expect(res.status()).toBe(200);
const { token } = await res.json();
await use(token);
},
});
export { expect };

View file

@ -0,0 +1,29 @@
import { test as base } from '@playwright/test';
import { ApiClient } from '../helpers/api-client.js';
type SeedFixtures = {
apiClient: ApiClient;
};
/**
* Seed-Fixture: stellt einen authentifizierten ApiClient bereit.
*
* Strategie (zu klären in Phase 1):
* Option A DB-Reset vor jeder Suite via Spring Boot test-Profile + Liquibase
* Option B Test-Daten mit zufälligen Namen (UUID-Suffix) zur Isolation
*
* Aktuell: Option B als pragmatischer Einstieg.
*/
export const test = base.extend<SeedFixtures>({
apiClient: async ({ request }, use) => {
const res = await request.post('/api/auth/login', {
data: {
username: process.env.TEST_USER_ADMIN ?? 'admin',
password: process.env.TEST_USER_ADMIN_PASS ?? 'admin123',
},
});
const { token } = await res.json();
const client = new ApiClient(request, token);
await use(client);
},
});