From 6bc4a22338354cab00cdb54ee01f83be37cfe5b5 Mon Sep 17 00:00:00 2001 From: BOHA Date: Sat, 6 Jun 2026 19:23:23 +0200 Subject: [PATCH] fix(mui): type theme.colorSchemes access in theme.test.ts (tsc -b clean) Define a minimal local interface for colorSchemes light/dark palettes and assert the imported theme once via `as unknown as ThemeWithColorSchemes`, replacing the 6 raw accesses that TypeScript rejected under tsc -b. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/admin/theme.test.ts | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/admin/theme.test.ts b/src/admin/theme.test.ts index a0b32c7..7b7f6cc 100644 --- a/src/admin/theme.test.ts +++ b/src/admin/theme.test.ts @@ -1,6 +1,23 @@ import { describe, it, expect } from "vitest"; import { theme } from "./theme"; +/** Minimal palette shape used by the colorSchemes assertions below. */ +interface SchemesPalette { + primary: { main: string }; + background: { default: string; paper: string }; + error: { main: string }; + success: { main: string }; +} +interface ColorScheme { + palette: SchemesPalette; +} +interface ThemeWithColorSchemes { + colorSchemes: { light: ColorScheme; dark: ColorScheme }; +} + +/** Single typed assertion so every `colorSchemes.*` access below is checked. */ +const themedSchemes = (theme as unknown as ThemeWithColorSchemes).colorSchemes; + describe("MUI theme", () => { it("uses the brand fonts", () => { expect(theme.typography.fontFamily).toContain("Plus Jakarta Sans"); @@ -8,18 +25,18 @@ describe("MUI theme", () => { }); it("maps the brand red per color scheme", () => { - expect(theme.colorSchemes.light.palette.primary.main).toBe("#c73030"); - expect(theme.colorSchemes.dark.palette.primary.main).toBe("#d63031"); + expect(themedSchemes.light.palette.primary.main).toBe("#c73030"); + expect(themedSchemes.dark.palette.primary.main).toBe("#d63031"); }); it("maps the refreshed light canvas + paper", () => { - expect(theme.colorSchemes.light.palette.background.default).toBe("#f4f3f1"); - expect(theme.colorSchemes.light.palette.background.paper).toBe("#ffffff"); + expect(themedSchemes.light.palette.background.default).toBe("#f4f3f1"); + expect(themedSchemes.light.palette.background.paper).toBe("#ffffff"); }); it("maps semantic colors per scheme", () => { - expect(theme.colorSchemes.light.palette.error.main).toBe("#b91c1c"); - expect(theme.colorSchemes.dark.palette.success.main).toBe("#22c55e"); + expect(themedSchemes.light.palette.error.main).toBe("#b91c1c"); + expect(themedSchemes.dark.palette.success.main).toBe("#22c55e"); }); it("uses the base radius of 10", () => {