Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions apps/server/test/services/plugins/plugin-update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,41 @@ async function commitPlugin(
return git(repo, ["rev-parse", "HEAD"]);
}

describe("plugin update scheduling", () => {
it("waits one full interval when no plugins are eligible for update checks", async () => {
const HOUR = 60 * 60 * 1_000;
const emptyDb = createConnection(":memory:");
migrate(emptyDb);
const scheduled: number[] = [];
const emptyService = createPluginService({
aiServices: createAiServiceRegistry(),
telemetry: createNoopTelemetryService(),
db: emptyDb,
hub: {
getDaemonSessionIdForHost: () => null,
notifyPluginSignal: () => 0,
notifySystem: () => {},
},
logger,
dataDir: join(tmpdir(), "bb-plugin-update-empty-test"),
appVersion: "1.0.0",
stabilizationWindowMs: 0,
scheduleUpdateCheck: (delayMs) => {
scheduled.push(delayMs);
return () => {};
},
});

try {
emptyService.startPeriodicUpdateChecks();
expect(scheduled).toEqual([6 * HOUR]);
} finally {
await emptyService.stop();
emptyDb.$client.close();
}
});
});

describe("plugin update service and routes", () => {
let db: DbConnection;
let workDir: string;
Expand Down Expand Up @@ -782,16 +817,6 @@ describe("plugin update service and routes", () => {
return scheduled;
}

it("waits one full interval when no plugins are eligible for update checks", async () => {
const HOUR = 60 * 60 * 1_000;
await service.remove("updater");
const scheduled = await restartWithScheduler(Date.now);

service.startPeriodicUpdateChecks();

expect(scheduled.map((entry) => entry.delayMs)).toEqual([6 * HOUR]);
});

it("sweeps on start when a plugin was never checked, then waits out the interval across restarts", async () => {
const HOUR = 60 * 60 * 1_000;
let clock = Date.now();
Expand Down
Loading