Add @trails-cool/jobs package wrapping pg-boss for durable background job execution using the existing PostgreSQL database. Wire up planner session expiry as the first scheduled job (hourly, 7-day TTL) — this was previously dead code that never ran. Add placeholder worker to journal for future Komoot import and federation jobs. Infrastructure: grant grafana_reader access to pgboss schema, add job queue health panels to Service Health dashboard, add failed job alert. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
1 KiB
TypeScript
30 lines
1 KiB
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
|
|
vi.mock("../lib/sessions.ts", () => ({
|
|
expireSessions: vi.fn().mockResolvedValue(5),
|
|
}));
|
|
|
|
vi.mock("../lib/logger.server.ts", () => ({
|
|
logger: { info: vi.fn() },
|
|
}));
|
|
|
|
describe("expireSessionsJob", () => {
|
|
it("calls expireSessions with 7-day TTL and returns count", async () => {
|
|
const { expireSessionsJob } = await import("./expire-sessions.ts");
|
|
const { expireSessions } = await import("../lib/sessions.ts");
|
|
|
|
const result = await expireSessionsJob.handler({ id: "test", name: "expire-sessions", data: {} } as never);
|
|
|
|
expect(expireSessions).toHaveBeenCalledWith(7);
|
|
expect(result).toEqual({ expiredCount: 5 });
|
|
});
|
|
|
|
it("has correct job configuration", async () => {
|
|
const { expireSessionsJob } = await import("./expire-sessions.ts");
|
|
|
|
expect(expireSessionsJob.name).toBe("expire-sessions");
|
|
expect(expireSessionsJob.cron).toBe("0 * * * *");
|
|
expect(expireSessionsJob.retryLimit).toBe(2);
|
|
expect(expireSessionsJob.expireInSeconds).toBe(60);
|
|
});
|
|
});
|