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:
parent
83c7321c8f
commit
c84629cc4e
16 changed files with 1219 additions and 0 deletions
45
test-automation/web-ui/helpers/api-client.ts
Normal file
45
test-automation/web-ui/helpers/api-client.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue