Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+53
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { runAllTenantKwpProjectMaintenance } from "./kwp-project-maintenance.js";
|
||||
|
||||
describe("KWP project maintenance", () => {
|
||||
it("only schedules targeted provider work with stable cadence ids", async () => {
|
||||
const add = vi.fn(async (_name: string, _payload: unknown, _options?: { jobId?: string }) => ({ id: "job" }));
|
||||
const queue = { add, close: vi.fn(async () => undefined) };
|
||||
const prisma = {
|
||||
tenant: {
|
||||
findMany: vi.fn(async (args: { cursor?: { id: string } }) =>
|
||||
args.cursor ? [] : [{ id: "tenant_1" }],
|
||||
),
|
||||
},
|
||||
appEntityBinding: {
|
||||
findMany: vi.fn(async () => [{ id: "binding_1", dataConnectionId: "connection_1" }]),
|
||||
},
|
||||
dataConnection: {
|
||||
findMany: vi.fn(async () => [{ id: "connection_1" }]),
|
||||
},
|
||||
};
|
||||
|
||||
const result = await runAllTenantKwpProjectMaintenance({
|
||||
prisma,
|
||||
queue,
|
||||
now: new Date("2026-07-23T12:00:00.000Z"),
|
||||
});
|
||||
|
||||
expect(result).toEqual({ inspectedTenants: 1, projectJobs: 1, catalogJobs: 1, contractJobs: 1, failures: 0 });
|
||||
expect(add).toHaveBeenCalledTimes(3);
|
||||
expect(add.mock.calls.map(([jobName]) => jobName)).toEqual([
|
||||
"run-kwp-import",
|
||||
"run-kwp-import",
|
||||
"run-kwp-import",
|
||||
]);
|
||||
expect(add.mock.calls[0]?.[1]).toMatchObject({
|
||||
kind: "kwp.project-sync",
|
||||
tenantId: "tenant_1",
|
||||
bindingId: "binding_1",
|
||||
});
|
||||
expect(add.mock.calls[1]?.[1]).toMatchObject({
|
||||
kind: "kwp.project-catalog-sync",
|
||||
tenantId: "tenant_1",
|
||||
dataConnectionId: "connection_1",
|
||||
});
|
||||
expect(add.mock.calls[2]?.[1]).toMatchObject({
|
||||
kind: "kwp.contract-sentinel",
|
||||
tenantId: "tenant_1",
|
||||
dataConnectionId: "connection_1",
|
||||
});
|
||||
expect(add.mock.calls[0]?.[2]?.jobId).toContain("kwp-project-sync%3Atenant_1%3Abinding_1%3A");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user