|
| 1 | +import { render } from "@testing-library/react" |
| 2 | +import { describe, expect, test } from "vitest" |
| 3 | +import TopBar from "@/ui/components/TopBar" |
| 4 | +import { UIContext, type UIContextProps } from "@/ui/helpers/UIProviderHelpers" |
| 5 | +import { type AppState, StateContext } from "@/ui/helpers/StateProviderHelpers.ts" |
| 6 | +import { APP_MODES } from "@/systems/AppMode.ts" |
| 7 | + |
| 8 | +const BLOCKED_CONTEXT: UIContextProps = { |
| 9 | + panels: [], |
| 10 | + blockState: { blocked: true, blockMessage: "" }, |
| 11 | + openModal: () => null, |
| 12 | + openPanel: () => null, |
| 13 | + togglePanel: () => null, |
| 14 | + closeModal: () => {}, |
| 15 | + closePanel: () => {}, |
| 16 | + addToast: () => {}, |
| 17 | + configureScreen: () => {}, |
| 18 | +} |
| 19 | + |
| 20 | +describe("top bar blocking", () => { |
| 21 | + test.for(APP_MODES)("interactive elements disabled ($0)", mode => { |
| 22 | + const stateContextValue: AppState = { |
| 23 | + setSelectedScheme: () => {}, |
| 24 | + appMode: mode, |
| 25 | + setAppMode: () => {}, |
| 26 | + } |
| 27 | + |
| 28 | + const { container } = render( |
| 29 | + <UIContext.Provider value={BLOCKED_CONTEXT}> |
| 30 | + <StateContext.Provider value={stateContextValue}> |
| 31 | + <TopBar /> |
| 32 | + </StateContext.Provider> |
| 33 | + </UIContext.Provider> |
| 34 | + ) |
| 35 | + |
| 36 | + const elements = [...container.querySelectorAll("button"), ...container.querySelectorAll("input")] |
| 37 | + expect(elements).not.toHaveLength(0) |
| 38 | + for (const el of elements) { |
| 39 | + expect(el).toBeDisabled() |
| 40 | + } |
| 41 | + }) |
| 42 | +}) |
0 commit comments