feat(sabnzbd): add archived history options to the Downloads widget (#6515)
This commit is contained in:
1 parent
4dbe4343e5
commit
67196975f3
13 files changed
+428
-7
No files matched your search
@@ -7,7 +7,11 @@ import { createIntegrationRequestHandler } from "./lib/integration-request-handl
|
||||
export const downloadClientRequestHandler = createIntegrationRequestHandler<
|
||||
DownloadClientJobsAndStatus,
|
||||
IntegrationKindByCategory<"downloadClient">,
|
||||
{ limit: number }
|
||||
{
|
||||
limit: number;
|
||||
includeArchivedHistory: boolean;
|
||||
historyWindowDays: number;
|
||||
}
|
||||
>({
|
||||
cacheNamespace: "downloads:jobs-and-status",
|
||||
cacheTtlMs: 10 * 1000,
|
||||
|
||||
@@ -322,6 +322,30 @@ describe("createRequestHandler", () => {
|
||||
});
|
||||
|
||||
describe("createIntegrationRequestHandler", () => {
|
||||
it("keeps SABnzbd history windows and archive modes in separate cache entries", async () => {
|
||||
let calls = 0;
|
||||
const handler = createIntegrationRequestHandler<
|
||||
number,
|
||||
"sabNzbd",
|
||||
{ limit: number; includeArchivedHistory: boolean; historyWindowDays: number }
|
||||
>({ requestAsync: async () => ++calls });
|
||||
const integration = { ...createIntegration("test-secret"), kind: "sabNzbd" as const };
|
||||
const input = { limit: 50, includeArchivedHistory: true, historyWindowDays: 7 };
|
||||
|
||||
await expect(handler.handler(integration, input).getDataAsync()).resolves.toMatchObject({ data: 1 });
|
||||
await expect(handler.handler(integration, input).getDataAsync()).resolves.toMatchObject({ data: 1 });
|
||||
await expect(
|
||||
handler.handler(integration, { ...input, historyWindowDays: 14 }).getDataAsync(),
|
||||
).resolves.toMatchObject({ data: 2 });
|
||||
await expect(
|
||||
handler.handler(integration, { ...input, includeArchivedHistory: false }).getDataAsync(),
|
||||
).resolves.toMatchObject({ data: 3 });
|
||||
await expect(
|
||||
handler.handler(integration, { ...input, historyWindowDays: 14 }).getDataAsync(),
|
||||
).resolves.toMatchObject({ data: 2 });
|
||||
expect(calls).toBe(3);
|
||||
});
|
||||
|
||||
it("does not deduplicate requests across rotated integration secrets", async () => {
|
||||
let calls = 0;
|
||||
const request = deferred<string>();
|
||||
|
||||
Reference in new issue
Block a user