Files
hose-use/src/domains/platform/workflow/queries.test.ts
T
gitea c813498da2 fix: 标明工作流扫描与分析证据完整性
保留不完整扫描中的既有告警指纹,并展示分页和分析证据不足。
2026-10-30 17:37:05 +08:00

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();
});