fix: prevent GitHub settings refresh flash (#2118)

This commit is contained in:
Carlos Florêncio
2026-07-31 23:24:46 +01:00
committed by GitHub
parent c5056f562e
commit 4fe358423b
9 changed files with 332 additions and 9 deletions
@@ -4,12 +4,24 @@ import { ToastProvider } from "@/components/toast-provider";
import type { GitHubStatus } from "@/lib/types/github";
import { GitHubPersonalSettings } from "./github-status";
const mocks = vi.hoisted(() => ({ status: null as GitHubStatus | null }));
const mocks = vi.hoisted(() => ({
status: null as GitHubStatus | null,
loading: false,
}));
vi.mock("@/hooks/domains/github/use-github-status", () => ({
useGitHubStatus: () => ({ status: mocks.status, loaded: true, loading: false, refresh: vi.fn() }),
useGitHubStatus: () => ({
status: mocks.status,
loaded: true,
loading: mocks.loading,
refresh: vi.fn(),
}),
}));
afterEach(() => cleanup());
afterEach(() => {
cleanup();
mocks.status = null;
mocks.loading = false;
});
function renderPersonal() {
return render(
@@ -61,4 +73,13 @@ describe("GitHubPersonalSettings", () => {
expect(screen.getByRole("button", { name: /Connect identity/ })).toBeTruthy();
expect(screen.getByText(/never given to managed agents/)).toBeTruthy();
});
it("keeps the current identity visible while refreshing", () => {
mocks.status = status("github_app_installation");
mocks.loading = true;
renderPersonal();
expect(screen.getByTestId("github-personal-identity")).toBeTruthy();
expect(screen.getByText("octocat", { exact: true })).toBeTruthy();
});
});