From ec6760b5a774066c26a2f4908032d43ed28f4487 Mon Sep 17 00:00:00 2001 From: Yunxiao Xu Date: Tue, 17 Feb 2026 02:19:41 -0800 Subject: [PATCH] test: Fix MainLayout tests by providing ThemeProvider context --- .../src/components/layout/MainLayout.test.tsx | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/layout/MainLayout.test.tsx b/frontend/src/components/layout/MainLayout.test.tsx index ecf3bcc..5a1fe32 100644 --- a/frontend/src/components/layout/MainLayout.test.tsx +++ b/frontend/src/components/layout/MainLayout.test.tsx @@ -1,6 +1,7 @@ import { render, screen } from "@testing-library/react" import { describe, it, expect, vi } from "vitest" import { MainLayout } from "./MainLayout" +import { ThemeProvider } from "../theme-provider" describe("MainLayout", () => { const mockProps = { @@ -14,22 +15,32 @@ describe("MainLayout", () => { it("renders children correctly", () => { render( - -
Test Content
-
+ + +
Test Content
+
+
) expect(screen.getByTestId("test-child")).toBeInTheDocument() expect(screen.getByText("Test Content")).toBeInTheDocument() }) it("renders the sidebar", () => { - render(Content) + render( + + Content + + ) // Sidebar should have some identifying text or role expect(screen.getByRole("complementary")).toBeInTheDocument() }) it("renders the header/navigation", () => { - render(Content) + render( + + Content + + ) expect(screen.getByRole("navigation")).toBeInTheDocument() }) })