mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-10-14 21:59:05 +02:00
23 lines
774 B
TypeScript
23 lines
774 B
TypeScript
import { expect, type APIRequestContext } from '@playwright/test';
|
|
|
|
// Overrides application configuration values through the API, keeping every other value unchanged
|
|
// The request context must be authenticated as an admin
|
|
export async function setAppConfigValues(
|
|
request: APIRequestContext,
|
|
values: Record<string, string>
|
|
) {
|
|
const configResponse = await request.get('/api/application-configuration/all');
|
|
expect(configResponse.ok()).toBe(true);
|
|
|
|
const config = Object.fromEntries(
|
|
((await configResponse.json()) as Array<{ key: string; value: string }>).map(
|
|
({ key, value }) => [key, value]
|
|
)
|
|
);
|
|
|
|
const updateResponse = await request.put('/api/application-configuration', {
|
|
data: { ...config, ...values }
|
|
});
|
|
expect(updateResponse.ok()).toBe(true);
|
|
}
|