|
1 | 1 | import { describe, expect, test } from "bun:test" |
2 | 2 | import { createRoot, createSignal } from "solid-js" |
3 | | -import { createSessionKeyReader, ensureSessionKey, pruneSessionKeys } from "./layout-helpers" |
| 3 | +import { |
| 4 | + createSessionKeyReader, |
| 5 | + ensureSessionKey, |
| 6 | + isPanelOpen, |
| 7 | + pruneSessionKeys, |
| 8 | + toggledPanelMode, |
| 9 | +} from "./layout-helpers" |
| 10 | + |
| 11 | +describe("right-side-panel mode reducer", () => { |
| 12 | + // Regression guard for the IM panel "进去出不来" bug: opening a panel must be |
| 13 | + // reversible. These exercise the exact reducer the LayoutProvider's |
| 14 | + // rightPanel.open/close/toggle delegate to. |
| 15 | + test("opening a mode from closed sets that mode", () => { |
| 16 | + expect(toggledPanelMode(undefined, "im")).toBe("im") |
| 17 | + }) |
| 18 | + |
| 19 | + test("toggling the active mode closes the panel", () => { |
| 20 | + // open IM, then toggle IM again → closed. This is the click-to-open, |
| 21 | + // click-to-close contract the IM tab relies on. |
| 22 | + const opened = toggledPanelMode(undefined, "im") |
| 23 | + expect(opened).toBe("im") |
| 24 | + expect(toggledPanelMode(opened, "im")).toBeUndefined() |
| 25 | + }) |
| 26 | + |
| 27 | + test("toggling a different mode switches instead of closing", () => { |
| 28 | + expect(toggledPanelMode("review", "im")).toBe("im") |
| 29 | + }) |
| 30 | + |
| 31 | + test("isPanelOpen reflects presence of a mode", () => { |
| 32 | + expect(isPanelOpen(undefined)).toBe(false) |
| 33 | + expect(isPanelOpen("im")).toBe(true) |
| 34 | + expect(isPanelOpen("review")).toBe(true) |
| 35 | + }) |
| 36 | +}) |
4 | 37 |
|
5 | 38 | describe("layout session-key helpers", () => { |
6 | 39 | test("couples touch and scroll seed in order", () => { |
|
0 commit comments