22 lines
1.2 KiB
TypeScript
22 lines
1.2 KiB
TypeScript
import { expect, it, spyOn } from "bun:test";
|
|
import * as applications from "../applications/services.js";
|
|
import * as api from "./api.js";
|
|
import { listAllWorkflows } from "./queries.js";
|
|
|
|
it("reports whether cross-application results cover all pages and applications", async () => {
|
|
const platforms = spyOn(applications, "listBasicPlatforms").mockResolvedValue([{ id: "p", active: true }] as any);
|
|
const list = spyOn(api, "listWorkflows").mockResolvedValue({ pipelineList: [], totalPages: 2, totalItems: 21 } as any);
|
|
const clients = { corp: { credentials: { corpId: "corp" } }, ekbClient: {}, easoClient: {} } as any;
|
|
const partial = await listAllWorkflows(clients, { page: 1, pageSize: 20 });
|
|
expect(partial.complete).toBe(false);
|
|
expect(partial.pages?.[0]?.totalPages).toBe(2);
|
|
list.mockResolvedValue({ pipelineList: [], totalPages: 1, totalItems: 0 } as any);
|
|
expect((await listAllWorkflows(clients)).complete).toBe(true);
|
|
list.mockRejectedValue(new Error("unavailable"));
|
|
const failed = await listAllWorkflows(clients);
|
|
expect(failed.complete).toBe(false);
|
|
expect(failed.errors).toHaveLength(1);
|
|
platforms.mockRestore();
|
|
list.mockRestore();
|
|
});
|