/** * Panel-host parenting tests — the layering half of a real defect: on DSH * Desktop's framed modes the shell tags the upstream `#root` with * `data-dsh-desktop-content-viewport` and gives it `isolation: isolate`, a * stacking context around the whole app INCLUDING the shell's overlay layer * (`.dshDesktopOverlay`, z-index 1000 — where a plugin's modal renders, e.g. * the community market's). A host parented to `document.body` sits outside * that context, so the panel layer's documented 25 outranked every overlay * inside it and covered host modals. * * jsdom: the resolution is a DOM query, so the stub-globals spec style used * by desktop-env.spec.ts cannot exercise it. */ // @vitest-environment jsdom import { beforeEach, describe, expect, it } from 'vitest' import { panelHostParent } from '../src/client/desktop-env.ts' beforeEach(() => { document.body.innerHTML = '' }) describe('panelHostParent', () => { it('falls back to the body when the shell framed no content viewport', () => { document.body.innerHTML = '
' expect(panelHostParent(document)).toBe(document.body) }) it('falls back to the body when there is no root at all (plain web)', () => { expect(panelHostParent(document)).toBe(document.body) }) it('resolves the framed content viewport when the shell stamped one', () => { document.body.innerHTML = '
' const root = document.getElementById('root') expect(panelHostParent(document)).toBe(root) // The host lands INSIDE the shell's stacking context — beside the overlay // layer the shell renders there, and never as a body-level sibling. const host = document.createElement('div') panelHostParent(document).appendChild(host) expect(root?.contains(host)).toBe(true) expect(document.body.lastElementChild).toBe(root) }) })