mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-31 14:16:39 +01:00
test(server): verify real health scheduling producers
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
6742665ecf
commit
c23fd46f10
6 files changed
+141
-10
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { startToolHealthWorker } from "./helpers/tool-health-worker.js";
|
||||
import { resolveExternalTestDatabaseUrl } from "./helpers/external-test-database.js";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
@@ -253,6 +254,7 @@ describeEmbeddedPostgres("GitHub connection event delivery", () => {
|
||||
credentialPolicy: "per_user",
|
||||
status: "active",
|
||||
enabled: true,
|
||||
healthCheckedAt: new Date("2026-09-04T11:59:05.000Z"),
|
||||
config: { sourceTemplateKey: "github", oauth: { connectorProfile: "github.code" } },
|
||||
transportConfig: {},
|
||||
});
|
||||
@@ -318,11 +320,18 @@ describeEmbeddedPostgres("GitHub connection event delivery", () => {
|
||||
let currentTime = new Date("2026-09-04T12:00:05.000Z");
|
||||
const service = githubConnectionEventService(db, { connector, now: () => currentTime });
|
||||
|
||||
const unsubscribe = subscribeCompanyLiveEvents(companyId, () => {
|
||||
throw new Error("fixture live subscriber failed");
|
||||
});
|
||||
await expect(service.pollOnce()).resolves.toMatchObject({ processed: 1, duplicate: 0, failed: 0 });
|
||||
unsubscribe();
|
||||
const health = await startToolHealthWorker(db, companyId, currentTime);
|
||||
try {
|
||||
await health.expectDeadline(new Date("2026-09-04T12:14:05.000Z").getTime());
|
||||
const unsubscribe = subscribeCompanyLiveEvents(companyId, () => {
|
||||
throw new Error("fixture live subscriber failed");
|
||||
});
|
||||
try {
|
||||
await expect(service.pollOnce()).resolves.toMatchObject({ processed: 1, duplicate: 0, failed: 0 });
|
||||
} finally { unsubscribe(); }
|
||||
await health.expectDeadline(currentTime.getTime() + 900_000 - (refreshed ? 60_000 : 0));
|
||||
await health.expectQuiet();
|
||||
} finally { await health.stop(); }
|
||||
let [grant] = await db.select().from(connectionGrants).where(eq(connectionGrants.id, grantId));
|
||||
expect(grant?.providerTenant?.github).toMatchObject({ repositoryCount: refreshed ? 3 : 4, webhookHealth: "healthy" });
|
||||
if (refreshed) {
|
||||
|
||||
Reference in new issue
Block a user