Files
cms-onpageeditor/test/setup.ts
T
mats bb875a0956 editor: friendlier panels - collapsible rail, remembered state, no more overlap
Rail sections (Outline/Blocks/Nodes) collapse via their headers like
Experiments already did, so long pages stay navigable. Rail open state
and section toggles persist in localStorage across reloads (the QA
preview flow reloads constantly). The assistant panel shifts left while
the dev panel is open instead of stacking exactly underneath it, and
the rail/dev/assistant widths cap at the viewport on small screens.

Tests: rail-sections harness (collapse, reload persistence, shifted
assistant); harness boots with a fresh profile unless keepStorage is
passed; in-memory localStorage shim for the origin-less jsdom.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-07 12:37:09 +01:00

27 lines
1.1 KiB
TypeScript

// jsdom has no layout: give the few APIs the editor touches harmless defaults.
if (!('scrollIntoView' in Element.prototype)) (Element.prototype as any).scrollIntoView = () => {}
// This jsdom runs origin-less, so there is no localStorage: provide an
// in-memory one so UI persistence (rail/panel state) behaves like a browser.
if (typeof (globalThis as any).localStorage === 'undefined') {
const store = new Map<string, string>()
;(globalThis as any).localStorage = {
getItem: (k: string) => (store.has(k) ? store.get(k)! : null),
setItem: (k: string, v: string) => void store.set(k, String(v)),
removeItem: (k: string) => void store.delete(k),
clear: () => store.clear(),
key: (i: number) => [...store.keys()][i] ?? null,
get length() {
return store.size
},
}
}
;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
// Store updates arrive from fetch/timers outside act(); the harness settles them explicitly.
const error = console.error
console.error = (...a: unknown[]) => {
if (typeof a[0] === 'string' && a[0].includes('not wrapped in act')) return
error(...a)
}