add website tests

This commit is contained in:
2025-12-28 21:02:32 +01:00
parent 6edf12fda8
commit 2f6657f56d
20 changed files with 1868 additions and 97 deletions

View File

@@ -19,7 +19,12 @@ export class BaseApiClient {
this.logger = logger;
}
protected async request<T>(method: string, path: string, data?: object | FormData): Promise<T> {
protected async request<T>(
method: string,
path: string,
data?: object | FormData,
options?: { allowUnauthenticated?: boolean },
): Promise<T> {
this.logger.info(`${method} ${path}`);
const isFormData = typeof FormData !== 'undefined' && data instanceof FormData;
@@ -43,6 +48,15 @@ export class BaseApiClient {
const response = await fetch(`${this.baseUrl}${path}`, config);
if (!response.ok) {
if (
options?.allowUnauthenticated &&
(response.status === 401 || response.status === 403)
) {
// For "auth probe" endpoints (e.g. session/policy checks), 401/403 is an expected state
// in public context and should not be logged as an application error.
return null as T;
}
let errorData: { message?: string } = { message: response.statusText };
try {
errorData = await response.json();