From 2cef95bd59c29be94d15abeee5f2bbc1cde38be0 Mon Sep 17 00:00:00 2001 From: ghost <49853598+JSONbored@users.noreply.github.com> Date: Sat, 13 Jun 2026 23:28:10 -0700 Subject: [PATCH] fix(ui): hoist vitest mock state --- .../src/components/site/app-panels/ai-review-settings.test.tsx | 2 +- .../src/components/site/app-panels/maintainer-panel.test.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/gittensory-ui/src/components/site/app-panels/ai-review-settings.test.tsx b/apps/gittensory-ui/src/components/site/app-panels/ai-review-settings.test.tsx index 244fbef767..7083bcbb89 100644 --- a/apps/gittensory-ui/src/components/site/app-panels/ai-review-settings.test.tsx +++ b/apps/gittensory-ui/src/components/site/app-panels/ai-review-settings.test.tsx @@ -2,7 +2,7 @@ import { render, screen, fireEvent, waitFor } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; // Mock the API layer so the component never touches the network. -const apiFetch = vi.fn(); +const { apiFetch } = vi.hoisted(() => ({ apiFetch: vi.fn() })); vi.mock("@/lib/api/request", () => ({ apiFetch: (...args: unknown[]) => apiFetch(...args) })); vi.mock("@/lib/api/origin", () => ({ getApiOrigin: () => "https://api.test" })); diff --git a/apps/gittensory-ui/src/components/site/app-panels/maintainer-panel.test.tsx b/apps/gittensory-ui/src/components/site/app-panels/maintainer-panel.test.tsx index d6d0db3d40..16328457b9 100644 --- a/apps/gittensory-ui/src/components/site/app-panels/maintainer-panel.test.tsx +++ b/apps/gittensory-ui/src/components/site/app-panels/maintainer-panel.test.tsx @@ -2,7 +2,7 @@ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; // Control the session role + stub the data hook so the dashboard branch never hits the network. -const useSession = vi.fn(); +const { useSession } = vi.hoisted(() => ({ useSession: vi.fn() })); vi.mock("@/lib/api/session", () => ({ useSession: () => useSession() })); vi.mock("@/lib/api/use-api-resource", () => ({ useApiResource: () => ({ status: "loading", data: null, reload: () => {}, error: null }),