Add getAppSettings API function
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
import { getAppSettings } from "./appSettings.js";
|
||||
import type { ApiClient } from "./client.js";
|
||||
|
||||
describe("getAppSettings", () => {
|
||||
it("calls /appSettings endpoint", async () => {
|
||||
const mockResponse = {
|
||||
uiOptions: {
|
||||
filter: {
|
||||
onlineboard: { searchFrom: "2d", searchTo: "14d" },
|
||||
schedule: { searchFrom: "30d", searchTo: "30d" },
|
||||
},
|
||||
},
|
||||
};
|
||||
const client = {
|
||||
get: vi.fn().mockResolvedValue(mockResponse),
|
||||
} as unknown as ApiClient;
|
||||
|
||||
const result = await getAppSettings(client);
|
||||
|
||||
expect(client.get).toHaveBeenCalledWith("/appSettings");
|
||||
expect(result).toEqual(mockResponse);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import type { ApiClient } from "./client.js";
|
||||
|
||||
export interface AppSettingsFilterOptions {
|
||||
searchFrom?: string;
|
||||
searchTo?: string;
|
||||
timeStep?: string;
|
||||
}
|
||||
|
||||
export interface AppSettingsResponse {
|
||||
showDebugVersion?: string;
|
||||
uiOptions?: {
|
||||
isTestVersion?: string;
|
||||
filter?: {
|
||||
onlineboard?: AppSettingsFilterOptions;
|
||||
schedule?: AppSettingsFilterOptions;
|
||||
};
|
||||
buttons?: Record<string, unknown>;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the global UI configuration from the backend. Includes date range
|
||||
* limits for online-board and schedule searches.
|
||||
*/
|
||||
export async function getAppSettings(client: ApiClient): Promise<AppSettingsResponse> {
|
||||
return client.get<AppSettingsResponse>("/appSettings");
|
||||
}
|
||||
Reference in New Issue
Block a user