From 8524903a5bd23b5cf9cf9060521e64c5c3b79cb6 Mon Sep 17 00:00:00 2001 From: Thomas Durieux <5577568+tdurieux@users.noreply.github.com> Date: Sun, 29 Nov 2026 11:55:04 +0000 Subject: [PATCH] test(repo-list): cover the stale resync and blocking before picker writes Co-Authored-By: Claude Opus 5.5 --- test/github-app.test.js | 10 ++++++++++ test/user-repository-list.test.js | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/test/github-app.test.js b/test/github-app.test.js index d984da1..d48ca4e 100644 --- a/test/github-app.test.js +++ b/test/github-app.test.js @@ -797,6 +797,16 @@ describeMongo("GitHub App credential and repository integration", function () { expect((await Installations.findOne({ installationId: 4 })).blocked).to.equal(false); }); + it("blocks a deleted installation even when the picker list update fails", async () => { + const UserRepositories = require("../src/core/model/user-repositories").UserRepositoryModel; + const original = UserRepositories.deleteMany; + UserRepositories.deleteMany = async () => { throw new Error("picker write failed"); }; + try { + expect((await webhook("installation", { action: "deleted", installation: { id: 4, app_id: 123 } })).status).to.equal(503); + } finally { UserRepositories.deleteMany = original; } + expect((await Installations.findOne({ installationId: 4 })).blocked).to.equal(true); + }); + it("does not let an in-flight installation check undo a deletion", async () => { await Installations.create({ appId: "123", installationId: 4, revision: "old", blocked: true, reconciliationPending: true }); mock(async () => { diff --git a/test/user-repository-list.test.js b/test/user-repository-list.test.js index 24783ff..147d29d 100644 --- a/test/user-repository-list.test.js +++ b/test/user-repository-list.test.js @@ -186,6 +186,21 @@ describeMongo("stored repository picker list", function () { expect(stored).to.have.length(250); }); + it("resyncs a list older than 12 hours in the background", async () => { + await setCredential(owner.id, "oauth-token"); + await picker(); + await list.settleRepositorySyncs(); + calls = []; + await Syncs.updateOne({ ownerId: owner.id }, { $set: { syncedAt: new Date(Date.now() - 11 * 3600_000) } }); + await picker(); + await list.settleRepositorySyncs(); + expect(calls).to.deep.equal([]); + await Syncs.updateOne({ ownerId: owner.id }, { $set: { syncedAt: new Date(Date.now() - 13 * 3600_000) } }); + expect((await picker()).status).to.equal(200); + await list.settleRepositorySyncs(); + expect(calls).to.deep.equal([1, 2, 3]); + }); + it("pauses after a rate limit instead of retrying on every load", async () => { await setCredential(owner.id, "oauth-token"); github.octokit = () => ({ request: async () => {