Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -88,6 +88,47 @@ describe("startMetricsScheduler", () => {
scheduler.stop();
});
it("coalesces overlapping metric refreshes instead of piling up polls", async () => {
let resolveQueueDepth: ((samples: readonly []) => void) | undefined;
let resolveBusiness: ((sample: { activeTenants: number; activeUsers24h: number; subscriptionActiveByPlanId: {} }) => void) | undefined;
const fetchQueueDepth = vi.fn(
() =>
new Promise<readonly []>((resolve) => {
resolveQueueDepth = resolve;
})
);
const fetchBusinessGauges = vi.fn(
() =>
new Promise<{ activeTenants: number; activeUsers24h: number; subscriptionActiveByPlanId: {} }>((resolve) => {
resolveBusiness = resolve;
})
);
const scheduler = startMetricsScheduler({
metrics,
fetchQueueDepth,
fetchBusinessGauges,
setInterval: () => undefined,
clearInterval: () => undefined,
});
const queueRefreshes = [scheduler.refreshQueueDepth(), scheduler.refreshQueueDepth()];
const businessRefreshes = [scheduler.refreshBusinessGauges(), scheduler.refreshBusinessGauges()];
expect(fetchQueueDepth).toHaveBeenCalledTimes(1);
expect(fetchBusinessGauges).toHaveBeenCalledTimes(1);
resolveQueueDepth?.([]);
resolveBusiness?.({ activeTenants: 0, activeUsers24h: 0, subscriptionActiveByPlanId: {} });
await Promise.all([...queueRefreshes, ...businessRefreshes]);
void scheduler.refreshQueueDepth();
void scheduler.refreshBusinessGauges();
expect(fetchQueueDepth).toHaveBeenCalledTimes(2);
expect(fetchBusinessGauges).toHaveBeenCalledTimes(2);
resolveQueueDepth?.([]);
resolveBusiness?.({ activeTenants: 0, activeUsers24h: 0, subscriptionActiveByPlanId: {} });
scheduler.stop();
});
it("stop() is idempotent and clears both timers", () => {
const clears: unknown[] = [];
const scheduler = startMetricsScheduler({