diff --git a/app/__tests__/components/install-card.test.ts b/app/__tests__/components/install-card.test.ts
new file mode 100644
index 00000000..2fc6ba03
--- /dev/null
+++ b/app/__tests__/components/install-card.test.ts
@@ -0,0 +1,26 @@
+/**
+ * The site's install card stays off an open world view: the view's root says it is there (data-world-view), the card
+ * carries data-install-card, and one plain rule in globals.css hides the card while the page holds a world view. Nothing
+ * else decides the card (its visit count, its dismissal and its timer stay), so leaving the view shows it again.
+ */
+import fs from 'fs';
+import path from 'path';
+
+const IP = fs.readFileSync(path.join(__dirname, '../../src/components/pwa/InstallPrompt.tsx'), 'utf8');
+const CSS = fs.readFileSync(path.join(__dirname, '../../src/app/globals.css'), 'utf8');
+
+describe('the install card', () => {
+ it('the install card hides while a world view is open', () => {
+ expect(IP).toContain(
+ '
',
+ );
+ expect(CSS).toMatch(/body:has\(\[data-world-view\]\) \[data-install-card\] \{\s*display: none;\s*\}/);
+ });
+
+ it('nothing else decides the card', () => {
+ expect(IP).toContain('if (getVisitCount() < 2) return;');
+ expect(IP).toContain('if (isInstallDismissed()) return;');
+ expect(IP.split('setTimeout(() => setVisible(true), 2000)').length).toBe(3);
+ expect(IP).not.toContain('usePathname');
+ });
+});
diff --git a/app/__tests__/components/world-corners.test.ts b/app/__tests__/components/world-corners.test.ts
index 46b24715..9548902f 100644
--- a/app/__tests__/components/world-corners.test.ts
+++ b/app/__tests__/components/world-corners.test.ts
@@ -102,8 +102,7 @@ describe('the corners of the world view', () => {
for (const s of [
"inert={panelSize === 'hidden'}",
'ref={panelRef}',
- 'ref={panelHideRef}',
- 'aria-label="Hide block panel"',
+ 'hideRef={panelHideRef}',
'panelTabRef.current?.focus()',
'panelHideRef.current?.focus()',
'if (lastPanel.current === panelSize) return;',
@@ -158,8 +157,6 @@ describe('the corners of the world view', () => {
expect(PV).toContain(
"{viewMode !== 'standard' && scene === 'ok' &&
",
);
- expect(PV).toContain("const PANEL_SHEET_BELOW_MD = 'max-md:absolute ");
- expect(PV).toContain(": 'max-md:hidden'}");
expect(PV).not.toContain('md:min-w-0');
});
});
diff --git a/app/__tests__/components/world-panel-frame.test.tsx b/app/__tests__/components/world-panel-frame.test.tsx
new file mode 100644
index 00000000..39949972
--- /dev/null
+++ b/app/__tests__/components/world-panel-frame.test.tsx
@@ -0,0 +1,127 @@
+/** @jest-environment jsdom */
+/**
+ * The block panel's frame, pressed: an open panel is the side column from md up and the bottom sheet below it, the hide
+ * button hides it, the width buttons and the tabs do what they say, and below md the hide button shares the tab row.
+ * The view (ParcelView) keeps the state and wires these two modules as the harness component below does.
+ */
+import * as React from 'react';
+import { fireEvent, render, screen } from '@testing-library/react';
+import PanelBar from '@/components/nexus/world/PanelBar';
+import { panelRootClass, type PanelSize, type RightTab } from '@/components/nexus/world/panel-frame';
+
+const TABS = [{ key: 'properties' as RightTab, label: 'PROPERTIES' }, { key: 'chat' as RightTab, label: 'CHAT' }];
+const OPEN: PanelSize[] = ['compact', 'quarter', 'third', 'half'];
+const SHEET = ['max-md:absolute', 'max-md:inset-x-0', 'max-md:bottom-[calc(72px+env(safe-area-inset-bottom))]',
+ 'max-md:z-30', 'max-md:!w-full', 'max-md:h-[calc(45vh-72px)]', 'max-md:landscape:min-h-[min(224px,calc(100%-136px))]',
+ 'max-md:rounded-t-2xl', 'max-md:border-t', 'max-md:border-line-2'];
+function Panel({ initial }: { initial: PanelSize }) {
+ const [size, setSize] = React.useState(initial);
+ const [tab, setTab] = React.useState('properties');
+ const hide = React.useRef(null);
+ return (
+
+
+
+ );
+}
+const classes = () => screen.getByTestId('root').className.split(/\s+/);
+const split = (el: Element) => (el.getAttribute('class') || '').split(/\s+/);
+const noop = () => undefined;
+
+describe("the block panel's frame", () => {
+ it('an open panel is the sheet below md and never hidden there; a hidden one leaves the flow below md', () => {
+ const widths: Record = { compact: 'w-80', quarter: 'w-96', third: 'w-[33vw]', half: 'w-[50vw]' };
+ for (const s of OPEN) {
+ const c = panelRootClass(s).split(' ');
+ for (const k of [...SHEET, 'md:border-l', 'md:border-line-2', 'bp-dark', 'bg-bg-primary', 'flex-shrink-0', 'flex',
+ 'flex-col', 'overflow-hidden', 'transition-all', 'duration-300', 'motion-reduce:transition-none', widths[s]]) {
+ expect(c).toContain(k);
+ }
+ for (const k of ['max-md:hidden', 'max-md:bottom-0', 'max-md:h-[45vh]']) expect(c).not.toContain(k);
+ expect(c.some((k) => k.includes('100dvh'))).toBe(false);
+ }
+ const h = panelRootClass('hidden').split(' ');
+ for (const k of ['max-md:hidden', 'w-0', 'bp-dark', 'flex-shrink-0', 'motion-reduce:transition-none']) expect(h).toContain(k);
+ for (const k of ['max-md:absolute', 'md:border-l']) expect(h).not.toContain(k);
+ });
+
+ it('the hide button hides the panel, and the tab and the widths reopen and size it', () => {
+ render();
+ expect(classes()).toContain('w-96');
+ expect(classes()).toContain('max-md:absolute');
+ fireEvent.click(screen.getByRole('button', { name: 'Hide block panel' }));
+ expect(screen.getByTestId('root').dataset.size).toBe('hidden');
+ expect(classes()).toContain('w-0');
+ expect(classes()).toContain('max-md:hidden');
+ expect(classes()).not.toContain('max-md:absolute');
+ fireEvent.click(screen.getByRole('button', { name: 'XL' }));
+ expect(screen.getByTestId('root').dataset.size).toBe('half');
+ expect(classes()).toContain('w-[50vw]');
+ expect(screen.getByRole('button', { name: 'XL' }).getAttribute('aria-pressed')).toBe('true');
+ expect(screen.getByRole('button', { name: 'M' }).getAttribute('aria-pressed')).toBe('false');
+ for (const [label, size] of [['S', 'compact'], ['L', 'third'], ['M', 'quarter']]) {
+ fireEvent.click(screen.getByRole('button', { name: label }));
+ expect(screen.getByTestId('root').dataset.size).toBe(size);
+ }
+ });
+
+ it('the widths are a named group of four lettered buttons, each with its plain title', () => {
+ render();
+ const group = screen.getByRole('group', { name: 'Panel width' });
+ const buttons = Array.from(group.querySelectorAll('button'));
+ expect(buttons.map((b) => b.textContent)).toEqual(['S', 'M', 'L', 'XL']);
+ expect(buttons.map((b) => b.getAttribute('title'))).toEqual(['Narrow', 'Default', 'One third', 'Half']);
+ for (const b of buttons) {
+ expect(b.hasAttribute('aria-label')).toBe(false);
+ for (const k of ['min-h-[44px]', 'min-w-[44px]', 'focus-visible:outline-2']) expect(split(b)).toContain(k);
+ }
+ const pressed = buttons.filter((b) => b.getAttribute('aria-pressed') === 'true');
+ expect(pressed).toHaveLength(1);
+ expect(split(pressed[0])).toContain('bg-surface-3');
+ expect(split(group)).toContain('hidden');
+ expect(split(group)).toContain('md:flex');
+ });
+
+ it('the hide button is 44 px, ringed, an icon with a label, and the ref the view focuses', () => {
+ const ref = React.createRef();
+ render();
+ const hide = screen.getByRole('button', { name: 'Hide block panel' });
+ expect(ref.current).toBe(hide);
+ expect(hide.getAttribute('title')).toBe('Hide panel');
+ for (const k of ['min-h-[44px]', 'min-w-[44px]', 'focus-visible:outline-2', 'order-2', 'mr-2']) expect(split(hide)).toContain(k);
+ expect(hide.textContent).toBe('');
+ const svgs = hide.querySelectorAll('svg');
+ expect(svgs).toHaveLength(1);
+ expect(svgs[0].getAttribute('aria-hidden')).toBe('true');
+ expect(svgs[0].getAttribute('width')).toBe('18');
+ });
+
+ it('the tabs press, say which is shown, and sit left of the hide button below md', () => {
+ const { container } = render();
+ fireEvent.click(screen.getByRole('button', { name: 'CHAT' }));
+ const chat = screen.getByRole('button', { name: 'CHAT' });
+ const props = screen.getByRole('button', { name: 'PROPERTIES' });
+ expect(chat.getAttribute('aria-pressed')).toBe('true');
+ expect(split(chat)).toContain('border-text-1');
+ expect(split(chat)).toContain('text-text-1');
+ expect(props.getAttribute('aria-pressed')).toBe('false');
+ expect(split(props)).toContain('border-transparent');
+ for (const b of [chat, props]) {
+ expect(split(b)).toContain('min-h-[44px]');
+ expect(split(b)).toContain('focus-visible:outline-2');
+ }
+ const bar = container.querySelector('[data-world-panel-head]') as HTMLElement;
+ expect(bar).not.toBeNull();
+ for (const k of ['flex-wrap', 'border-b', 'border-line-2', 'max-md:pt-1']) expect(split(bar)).toContain(k);
+ const kids = Array.from(bar.children);
+ const group = screen.getByRole('group', { name: 'Panel width' });
+ const hide = screen.getByRole('button', { name: 'Hide block panel' });
+ const tabs = bar.querySelector('[data-world-panel-tabs]') as HTMLElement;
+ expect(tabs).not.toBeNull();
+ expect(kids).toEqual([group, hide, tabs]);
+ for (const k of ['order-1', 'flex-1', 'min-w-0', 'md:order-3', 'md:basis-full', 'md:border-t']) expect(split(tabs)).toContain(k);
+ for (const k of ['md:order-1', 'md:flex-1', 'md:pl-2', 'md:py-1.5']) expect(split(group)).toContain(k);
+ expect(split(group)).not.toContain('md:px-2');
+ for (const el of [bar, ...Array.from(bar.querySelectorAll('*'))]) expect(el.hasAttribute('style')).toBe(false);
+ });
+});
diff --git a/app/__tests__/components/world-panel.test.ts b/app/__tests__/components/world-panel.test.ts
index c5e8a870..cdb998f7 100644
--- a/app/__tests__/components/world-panel.test.ts
+++ b/app/__tests__/components/world-panel.test.ts
@@ -2,6 +2,7 @@
* The block panel as a visitor meets it: an opaque panel on the site's tokens, a phone sheet that ends above the back
* link and keeps a floor on a phone on its side, 44 px controls with the shared ring, and only what a visitor without a
* wallet can read or use. Source is read here (no layout in jsdom); the browser probe measures the boxes.
+ * The frame's behaviour is pressed in world-panel-frame.test.tsx; this file pins how the view wires it.
*/
import fs from 'fs';
import path from 'path';
@@ -12,51 +13,23 @@ const between = (a: string, b: string) => { const i = PV.indexOf(a); const j = P
const PICT = /\p{Extended_Pictographic}/u; const LIT = /#[0-9a-fA-F]{3,8}\b|rgba?\(/;
describe('the block panel', () => {
- it('the panel root is opaque, on tokens, and leaves the flow below md when hidden', () => {
+ it('the panel root is opaque and takes its classes from the frame', () => {
const r = between('{/* ═══ Right Panel ═══ */}', '{/* Panel resize controls */}');
- for (const s of ['bp-dark', 'bg-bg-primary', '${PANEL_SHEET_BELOW_MD}', '${PANEL_EDGE_MD}', "'max-md:hidden'",
- 'flex-shrink-0', 'ref={panelRef}', "inert={panelSize === 'hidden'}", 'data-world-panel']) {
+ for (const s of ['className={panelRootClass(panelSize)}', 'ref={panelRef}', "inert={panelSize === 'hidden'}", 'data-world-panel']) {
expect(r).toContain(s);
}
expect(r).not.toContain('style=');
expect(r).not.toMatch(LIT);
});
- it("the sheet ends above the back link's row and keeps a floor on a phone on its side", () => {
- const s = between("const PANEL_SHEET_BELOW_MD = '", "';");
- for (const c of ['max-md:absolute', 'max-md:inset-x-0', 'max-md:bottom-[calc(72px+env(safe-area-inset-bottom))]',
- 'max-md:z-30', 'max-md:!w-full', 'max-md:h-[calc(45vh-72px)]', 'max-md:landscape:min-h-[min(224px,calc(100%-136px))]',
- 'max-md:rounded-t-2xl', 'max-md:border-t', 'max-md:border-line-2']) {
- expect(s).toContain(c);
- }
- for (const c of ['max-md:bottom-0', 'max-md:h-[45vh]', '100dvh']) expect(s).not.toContain(c);
- const e = between("const PANEL_EDGE_MD = '", "';");
- expect(e).toMatch(/md:border-l[ ']/);
- expect(e).toContain('md:border-line-2');
- });
-
- it('the header has a 44 px hide button with the shared ring and named size buttons from md up', () => {
- const h = between('{/* Panel resize controls */}', '{/* Tabs */}');
- for (const s of ['data-world-panel-head', 'aria-pressed={panelSize === s.size}', 'role="group" aria-label="Panel width"', 'title={s.name}',
- 'title="Hide panel"', 'aria-label="Hide block panel"', 'ref={panelHideRef}', ' {
+ const h = between('{/* Panel resize controls */}', "{rightTab === 'properties' ? (");
+ for (const s of [' {
- const t = between('{/* Tabs */}', "{rightTab === 'properties' ? (");
- for (const s of ['border-b border-line-2', 'aria-pressed={rightTab === tab.key}', 'min-h-[44px]', 'border-text-1 text-text-1',
- '${worldRing}']) {
- expect(t).toContain(s);
- }
- expect(t).not.toContain('style=');
- expect(t).not.toContain('#f7931a');
+ expect(h).not.toContain('