open-agents/apps/web/lib/github/installations-sync.test.ts
open-agents-bot[bot] 0441f1f49c
feat: add GitHub installation reconnection flow (#692)
* docs: revise plan for live GitHub connection health checks

* feat: add GitHub installation reconnection flow

* feat: improve GitHub auth detection and handle connection loading

---------

Co-authored-by: nicoalbanese <49612682+nicoalbanese@users.noreply.github.com>
2026-04-10 18:23:59 +01:00

43 lines
1.2 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import {
GitHubInstallationsSyncError,
isGitHubInstallationsAuthError,
} from "./installations-sync";
describe("isGitHubInstallationsAuthError", () => {
test("treats 401 responses as auth failures", () => {
expect(
isGitHubInstallationsAuthError(
new GitHubInstallationsSyncError("Unauthorized", {
status: 401,
responseText: '{"message":"Bad credentials"}',
}),
),
).toBe(true);
});
test("treats auth-specific 403 responses as auth failures", () => {
expect(
isGitHubInstallationsAuthError(
new GitHubInstallationsSyncError("Forbidden", {
status: 403,
responseText:
'{"message":"Must grant your OAuth app access to this organization."}',
}),
),
).toBe(true);
});
test("does not treat rate-limited 403 responses as auth failures", () => {
expect(
isGitHubInstallationsAuthError(
new GitHubInstallationsSyncError("Forbidden", {
status: 403,
responseText:
'{"message":"API rate limit exceeded for user ID 123."}',
}),
),
).toBe(false);
});
});