Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

fix: CI system vitest failures: No "AuthProvider" export is defined

Mike Pawlowskibd3fdd216d23
diff --git a/frontend/components/task-error-content.test.tsx b/frontend/components/task-error-content.test.tsx
index 788c29622..0fa5b136c 100644
--- a/frontend/components/task-error-content.test.tsx
+++ b/frontend/components/task-error-content.test.tsx
@@ -13,13 +13,19 @@ import { TaskErrorContent } from "./task-error-content";
* TaskErrorContent depends on useTask (for openTaskDialog) and useIsCloudBrand.
* Both are mocked at the module level — the context providers are not needed
* because we are testing component logic, not the context wiring.
+ *
+ * Each mock spreads the real module: `@/test-utils/render` imports every
+ * `*Provider` from these contexts, and vitest throws at import time if a
+ * factory mock drops an export it needs.
*/
-vi.mock("@/contexts/task-context", () => ({
+vi.mock("@/contexts/task-context", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@/contexts/task-context")>()),
useTask: () => ({ openTaskDialog: vi.fn() }),
}));
-vi.mock("@/contexts/brand-context", () => ({
+vi.mock("@/contexts/brand-context", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@/contexts/brand-context")>()),
useIsCloudBrand: () => false,
}));
diff --git a/frontend/components/task-notification-menu.test.tsx b/frontend/components/task-notification-menu.test.tsx
index db1e30f9c..8da13ff3b 100644
--- a/frontend/components/task-notification-menu.test.tsx
+++ b/frontend/components/task-notification-menu.test.tsx
@@ -18,9 +18,14 @@ const cancelTask = vi.fn().mockResolvedValue(undefined);
const openTaskDialog = vi.fn();
const closeMenu = vi.fn();
+// Each mock spreads the real module: `@/test-utils/render` imports every
+// `*Provider` from these contexts, and vitest throws at import time if a
+// factory mock drops an export it needs.
+
// Shared task context mock — individual tests mutate `mockTasks`.
let mockTasks: Task[] = [];
-vi.mock("@/contexts/task-context", () => ({
+vi.mock("@/contexts/task-context", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@/contexts/task-context")>()),
useTask: () => ({
tasks: mockTasks,
isFetching: false,
@@ -34,11 +39,15 @@ vi.mock("@/contexts/task-context", () => ({
}),
}));
-vi.mock("@/contexts/brand-context", () => ({
+vi.mock("@/contexts/brand-context", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@/contexts/brand-context")>()),
useIsCloudBrand: () => false,
}));
-vi.mock("@/contexts/console-status-context", () => ({
+vi.mock("@/contexts/console-status-context", async (importOriginal) => ({
+ ...(await importOriginal<
+ typeof import("@/contexts/console-status-context")
+ >()),
useConsoleStatus: () => ({ problems: [], open: vi.fn() }),
}));
diff --git a/frontend/contexts/task-context.test.tsx b/frontend/contexts/task-context.test.tsx
index f1dc0b30e..52f0ab187 100644
--- a/frontend/contexts/task-context.test.tsx
+++ b/frontend/contexts/task-context.test.tsx
@@ -24,7 +24,10 @@ import { TaskProvider, useTask } from "./task-context";
* the test does not spin up the full auth flow.
*/
-vi.mock("@/contexts/auth-context", () => ({
+// Spreads the real module: `@/test-utils/render` imports `AuthProvider` from
+// it, and vitest throws at import time if a factory mock drops that export.
+vi.mock("@/contexts/auth-context", async (importOriginal) => ({
+ ...(await importOriginal<typeof import("@/contexts/auth-context")>()),
useAuth: () => ({ isAuthenticated: true, isNoAuthMode: false }),
}));