1
0
Fork 0
mirror of https://github.com/s-frick/effigenix.git synced 2026-03-28 17:49:57 +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,45 @@
import type { APIRequestContext, APIResponse } from '@playwright/test';
/**
* Typisierter API-Wrapper für Playwright-Tests.
* Ergänzt den raw request-Context um Auth-Header und JSON-Defaults.
*/
export class ApiClient {
constructor(
private readonly request: APIRequestContext,
private readonly token: string,
) {}
private get authHeaders() {
return { Authorization: `Bearer ${this.token}` };
}
async get(path: string): Promise<APIResponse> {
return this.request.get(path, { headers: this.authHeaders });
}
async post(path: string, body: unknown): Promise<APIResponse> {
return this.request.post(path, {
data: body,
headers: this.authHeaders,
});
}
async put(path: string, body: unknown): Promise<APIResponse> {
return this.request.put(path, {
data: body,
headers: this.authHeaders,
});
}
async patch(path: string, body: unknown): Promise<APIResponse> {
return this.request.patch(path, {
data: body,
headers: this.authHeaders,
});
}
async delete(path: string): Promise<APIResponse> {
return this.request.delete(path, { headers: this.authHeaders });
}
}