Skip to content

Commit 0d07de2

Browse files
objectstack-fleet[bot]hotlongclaude
authored
feat(plugin-detail,app-shell): the default record page is one page at two widths — resident columns on a wide page, the tabs in a drawer (#26758)
Fixes #26678 Clause-②: no Metadata-protocol: none Part of the record-page-v2 epic #26676 (child 2 of 4). The drawer top bar and in-place navigation (#26679) and the open-mode metadata (#26677) are not addressed here. ## What this does The maintainer's ruling 1 on the epic, verbatim: 「抽屉和整页是同一张页在两个宽度。」 The synthesized default record page (no authored page, or a slotted page that keeps the default tab strip) is now laid out by the width of the view it occupies, never the viewport: | Container width | Layout | |---|---| | 1280 px and up | Three resident columns, no tab strip: details · timeline (discussion composer on top, then Activity, History) · related (each related list as a card, then the opt-in reference rail and `rightRail` slot, Approvals, Attachments, the created / updated footer) | | 1024 – 1279 px | Details · timeline; the related column folds into a rail opened from a **Related (N)** toggle above the columns (closed, its lists read nothing) | | below 1024 px, and always when embedded (drawer / split pane) | The tab strip, exactly as before | One header (title, actions, highlights, stage path) serves every tier. `?tab=` keeps working in the tabbed tier and is ignored by the columns. An authored record page (`kind: 'full'`) and an authored `slots.tabs` strip are drawn as authored at every width. ## Design: the columns are derived, never authored No metadata key, page template or node type is added, and `packages/spec` is untouched. The page description stays the tabbed one `buildDefaultPageSchema` writes, which is also what Studio's page-create seeds and what a slotted page fills. A columns node would have been a new type inside the spec's closed `record:` / `page:` namespaces: refused at Studio's save, and a type an author or an AI could write that the spec could not judge. So the column layout is read off the synthesized page by each tab's stable `value` (`details` → details; `activity`, `history` → timeline after the discussion footer; every related tab, `approvals`, `attachments` → related; the `aside` region folds into the related column, one rail, not two). A strip the partition cannot read (an unknown value, a `visibleWhen` item) answers `null` and keeps its tabs. A test enumerates every value `buildDefaultTabs` emits under all three `relatedLayout`s, so a new synthesized tab without a column goes red there. `showReferenceRail` / `hideReferenceRail` are `BuildPageOptions` (TypeScript options of the synthesizer), not spec keys, and their meaning is unchanged: in the tabbed tier the rail is today's `hidden xl:flex` aside; in the column tiers the same aside content sits in the related column. ## Files - `ui/packages/plugin-detail/src/synth/recordPageColumns.ts` (new): `recordPageTierFor`, `recordPageColumnOfTab`, `buildDefaultPageColumns`, the 1280 / 1024 floors. - `ui/packages/plugin-detail/src/useRecordPageTier.ts` (new): measures the container (layout effect plus `ResizeObserver`), re-renders only on a tier flip, answers `null` until the first reading so the host never mounts the tab tree only to replace it. - `ui/packages/plugin-detail/src/RecordPageColumns.tsx` (new): the column tiers; frame mirrors the tabbed page frame so the header does not move between tiers; the two-column rail toggle (`aria-expanded`, `aria-controls`, Escape closes back to the toggle); folded empty related lists collapse out of the column's gap. - `ui/packages/plugin-detail/src/relatedListCompact.ts` (new) + `RelatedList.tsx`: inside the related column a list keeps its identity column only and lets its header wrap. Without it the 20rem column cut each table off at its edge and truncated titles to one letter. Anywhere else a related list is unchanged. - `ui/packages/app-shell/src/views/RecordDetailView.tsx`: measures its own root, renders `RecordPageColumns` in the column tiers (tabbed path untouched), moves the provenance footer into the columns there, and treats History and the feed as on screen at open in a column tier (the audit read no longer waits for a tab click that cannot happen). - `ui/packages/plugin-detail/src/index.tsx`, `useDetailTranslation.ts` (`detail.related` default, byte-identical to the `en` pack). - Docs: `ui/packages/plugin-detail/README.md` (new section, reference-rail condition 3 note), `ui/content/docs/guide/slotted-pages.md`. - `ui/e2e/live/detail-related-list.spec.ts`, `ui/e2e/live/record-history-display.spec.ts`: both click a tab on a full record page under Desktop Chrome's 1280 px viewport, which leaves the record view at the two-column floor once the console sidebar takes its share; each now pins a 1200 px viewport to stay in the tabbed tier they test. - `.changeset/26678-record-page-two-widths.md` (patch, `Metadata-protocol: none`). ## Screenshots HotCRM (`1f3f8880`, platform 18.2.0 backend) with this branch's console on a Vite dev server. **Premise correction:** a HotCRM lead renders its authored `lead_detail` page (`kind: 'full'`, `isDefault: true`), which the ruling leaves untouched, so it cannot show the tiers. The shots use a contact and a task, objects with no authored record page. Container width = the record view's measured width; the console sidebar takes 256 px of the viewport. | | | |---|---| | Contact, container 1440 px: three columns | ![three columns](https://github.com/objectstack-ai/objectstack/blob/5c2f4343db70bd213abef0895804cb66f02df5d5/record-page-two-widths-26678/page-crm_contact-1696.png?raw=true) | | Contact, container 1100 px: two columns | ![two columns](https://github.com/objectstack-ai/objectstack/blob/5c2f4343db70bd213abef0895804cb66f02df5d5/record-page-two-widths-26678/page-crm_contact-1356.png?raw=true) | | Contact, container 1100 px: related rail open | ![rail open](https://github.com/objectstack-ai/objectstack/blob/5c2f4343db70bd213abef0895804cb66f02df5d5/record-page-two-widths-26678/page-crm_contact-1356-rail-open.png?raw=true) | | Contact, container 844 px: tabs | ![tabs](https://github.com/objectstack-ai/objectstack/blob/5c2f4343db70bd213abef0895804cb66f02df5d5/record-page-two-widths-26678/page-crm_contact-1100.png?raw=true) | | Task in the drawer (Task Board, embedded): tabbed tier | ![drawer](https://github.com/objectstack-ai/objectstack/blob/5c2f4343db70bd213abef0895804cb66f02df5d5/record-page-two-widths-26678/drawer-crm_task-1440.png?raw=true) | | The same task as a full page, container 1440 px: same header, same sections | ![task page](https://github.com/objectstack-ai/objectstack/blob/5c2f4343db70bd213abef0895804cb66f02df5d5/record-page-two-widths-26678/page-crm_task-1696.png?raw=true) | Evidence branch `claude/issue-26678-evidence-20261027` at `5c2f4343db70bd213abef0895804cb66f02df5d5` (never merged). **Reading worth a look:** with the console sidebar open, a 1440 px screen gives the record view 1184 px, so it lands in the two-column tier. Three columns need about 1536 px of screen with the sidebar open, or a collapsed sidebar. The floors are the card's (1280 / 1024 of container). ## Tests Readings at `177cf60f6f` (branch head after merging `origin/main` `4373103165`, an unrelated auth change); the README snippet fix `ecfa2c5574` re-ran `pnpm --dir ui run check:doc-snippets` (803 of 803 blocks judged, 0 failed), the derived 33 families (all exit 0) and `check:new-line-citations` (0 new) at `ecfa2c5574` — this line edited by the seat on the dev's report, the body is otherwise the dev's: - `pnpm --dir ui exec vitest run packages/plugin-detail/src/synth/__tests__/recordPageColumns.test.ts packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx packages/plugin-detail/src/__tests__/RelatedList.compactColumn-26678.test.tsx packages/app-shell/src/views/RecordDetailView.recordPageTiers-26678.test.tsx`: 4 files, 25 tests passed. - `RecordDetailView.recordPageTiers-26678`: 1440 px is three columns, no tablist, related lists in the related column, the `sys_audit_log` read at open; 1100 px is two columns, the toggle, lists mounted only on open; 900 px and embedded at 1440 px are the tab strip, with no audit read at 900; `?tab=related` selects the tab at 900 and is ignored at 1440. - Full `packages/plugin-detail/`: 316 files passed, 1 skipped; 2917 tests passed, 18 skipped. - `packages/app-shell/src/views/RecordDetailView.*` (72 files, 489 tests) plus the 121 other app-shell test files that import the record view, `plugin-detail` or `DETAIL_DEFAULT_TRANSLATIONS` (1312 tests): all passed. Declared narrowing: the remaining app-shell files are CI's `Test UI`. - `pnpm --filter @object-ui/plugin-detail run type-check`, `pnpm --filter @object-ui/app-shell run type-check`: exit 0 (on the pre-merge head; the merge touched only `ui/packages/auth`). - Existing tab tests (`?tab=`, related-tab order, `hideRelatedTab`, `referenceRailRoute-9816`) pass unchanged: jsdom measures 0 px, which is the tabbed tier. Ablations (one-shot, through `scripts/ablation-replace.mjs`, restore proven by blob equal to `HEAD` and empty `git diff HEAD`; the tests resolve `@object-ui/*` to source through `ui/vitest.config.mts`, so no `dist` was involved): 1. `recordPageTierFor` answering `tabs` at 1280 px and up: 3 tests red (the tier boundary, the 1440 px mount, the `?tab=` case). Restored. 2. The column-tier clause of the History read gate removed: the 1440 px "History is read at open" test red. Restored. Local gate subset (derived by `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` over this branch's 17 changed paths): all 33 node / `pnpm check:*` families exit 0. `pnpm check:new-line-citations` (ui): 0 new citations. ESLint on every changed ui file: 0 errors. The 34th family, `pnpm --dir ui exec vitest run scripts/`, exits 1 here for two host reasons, neither a reading of this change, so it is NOT MEASURED locally and CI's run is the reading: `select-affected-tests-wiring` (2 tests) runs a `bash` script using `mapfile`, which macOS's stock `bash` 3.2 lacks (exit 127); `check-i18n-dead-keys` (2 tests: "POSITIVE: every property-access-read key names LoadingScreen.tsx as a hit", "keeps every key it makes reachable OUT of both tiers") timed out at the 15 s budget scanning the real tree on this machine (16 s and 656 s). The other 176 files and 5062 tests pass. `detail.related`, the one key this change reads anew, was already read by the tab strip's label map. Verification ran in **declared unlocked mode**: `os-verify-lock: VERDICT command-exit 0 · UNLOCKED (declared) · no usable flock on this host, so the shared verify lock was NEVER taken and NOTHING was serialized`. ## Acceptance notes - The two-column toggle sits on its own row, right-aligned directly under the record header, not inside the `page:header` action row: putting it there would need a host slot in `@object-ui/components`' header. - Whether the rail is open is ephemeral view state (closed on every open), not a stored preference. - The related card's footer link reads "View All" (existing `detail.viewAll` text), not 「查看全部 N 条 →」; the count is in the card header. - At 20rem the compact card's row-actions column header is clipped at the card edge (the data-table's own minimum widths). Cosmetic, left as is. - In the three-column tier every related list is mounted at open, so each issues its read at open (the tab strip deferred them to the tab click). The two-column rail keeps them deferred until opened. - The two live specs above were not run (no showcase backend in this container). NOT MEASURED: live e2e, reason: no running showcase backend. - `DetailTabs.tsx` (named in the card) draws the legacy `DetailView` strip; the synthesized page's strip is `page:tabs` (`PageTabsRenderer` in `@object-ui/components`), so it is not part of this change. --- _Generated by [Claude Code](https://claude.ai/code/session_cdb7a717-def7-4e71-9988-f089fbaa18ff)_ --------- Co-authored-by: Jack Zhuang <50353452+hotlong@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1f1eda4 commit 0d07de2

17 files changed

Lines changed: 1302 additions & 16 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/plugin-detail': patch
3+
'@object-ui/app-shell': patch
4+
---
5+
6+
feat(plugin-detail,app-shell): the default record page is one page at two widths — resident columns on a wide page, the tabs in a drawer
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The synthesized default record page (no authored page, or a slotted page that keeps the default tab strip) used to be tabbed at every width: on a wide screen the details took the whole width while the timeline, the related lists and the comments each sat behind a tab click. It is now laid out by the width of the view it occupies — never the viewport, so the same page in a drawer stays narrow:
12+
13+
- **1280 px and up:** three resident columns — details · timeline (the discussion composer on top, then Activity and History) · related (each related list as a card naming its first rows, then the opt-in reference rail and `rightRail` slot, Approvals, Attachments and the created / updated line). No tab strip.
14+
- **1024 – 1279 px:** details · timeline; the related column folds into a rail opened from a **Related (N)** toggle above the columns. Closed, its lists read nothing.
15+
- **Below 1024 px, and whenever the view is embedded (drawer / split pane):** the tab strip, exactly as before.
16+
17+
One header (title, actions, highlights, stage path) serves every tier. No metadata key, page template or node type is added: the page description stays the tabbed one Studio seeds, and the columns are read off it by each tab's stable `value`. `?tab=` keeps selecting a tab in the tabbed tier and is ignored by the columns. An authored record page (`kind: 'full'`) and an authored `slots.tabs` strip are drawn as authored at every width. In a column tier History is resident, so its audit read goes out when the page opens instead of when its tab is clicked.
18+
19+
New `@object-ui/plugin-detail` exports for a host wiring the same layout: `useRecordPageTier(element, { embedded, enabled })`, `recordPageTierFor(width)`, `buildDefaultPageColumns(page)`, `recordPageColumnOfTab(value)`, `RecordPageColumns`, the `RECORD_PAGE_THREE_COLUMN_MIN_WIDTH` / `RECORD_PAGE_TWO_COLUMN_MIN_WIDTH` floors and their types. Additive: nothing existing changes shape.

‎ui/content/docs/guide/slotted-pages.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ its own tab is a one-word change on the relationship, not a page-authoring task.
126126
`relatedLayout: 'tabs' | 'stack'` remains an app-level override (force
127127
all-own-tabs / all-stacked).
128128

129+
That strip is the page at its narrow width. The console lays the same page
130+
out by the width of the view it occupies (the drawer, the split pane or the
131+
full page), never by the viewport: from **1280 px** the tabs become three
132+
resident columns — details · timeline (the discussion composer on top, then
133+
Activity and History) · related (each related list as a card, then Approvals,
134+
Attachments and the record's created/updated line); from **1024 px** the
135+
related column folds into a rail behind a **Related (N)** toggle; below
136+
1024 px, and always in a drawer or split pane, the strip as described above.
137+
One header serves every width, and a slotted `details` body fills the details
138+
column. A slotted `tabs` strip is your own strip, so it stays a strip at every
139+
width; `?tab=` selects a tab in the strip and is ignored by the columns.
140+
129141
Related lists are additionally gated on the current user's **object-level
130142
read permission** for the child object: a relationship whose child the user
131143
cannot read produces no section and no tab (and the `record:related_list`

‎ui/e2e/live/detail-related-list.spec.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ import { test, expect } from '@playwright/test';
1111
* the relationship. We open an Account record and assert the Projects related
1212
* list is present.
1313
*/
14+
/**
15+
* The synthesized record page lays itself out by the width of the view it
16+
* occupies (objectstack#26678): the tab strip this spec opens exists only
17+
* below the two-column floor (`RECORD_PAGE_TWO_COLUMN_MIN_WIDTH` in
18+
* `@object-ui/plugin-detail`). The Desktop Chrome viewport leaves the record
19+
* view right at that floor once the console sidebar takes its share, so the
20+
* spec pins a viewport that keeps the page in its tabbed tier.
21+
*/
22+
test.use({ viewport: { width: 1200, height: 800 } });
23+
1424
test('Account detail page auto-renders a relationship-derived Projects related list', async ({ page }) => {
1525
// 1) Open the Accounts list and drill into Northwind, a seeded account that
1626
// owns projects (the status assertion below needs rows to read).

‎ui/e2e/live/record-history-display.spec.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ async function seededUsers(request: APIRequestContext): Promise<{ actor: SysUser
3636
return { actor: actor!, other: other! };
3737
}
3838

39+
/**
40+
* The synthesized record page lays itself out by the width of the view it
41+
* occupies (objectstack#26678): the tab strip this spec opens exists only
42+
* below the two-column floor (`RECORD_PAGE_TWO_COLUMN_MIN_WIDTH` in
43+
* `@object-ui/plugin-detail`). The Desktop Chrome viewport leaves the record
44+
* view right at that floor once the console sidebar takes its share, so the
45+
* spec pins a viewport that keeps the page in its tabbed tier.
46+
*/
47+
test.use({ viewport: { width: 1200, height: 800 } });
48+
3949
test('History tab shows display values (localized dates, option labels, resolved lookups, real actor) instead of raw audit payloads', async ({ page, request }) => {
4050
const { actor, other } = await seededUsers(request);
4151

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* objectstack#26678 — the synthesized record page is one page at two widths.
11+
*
12+
* Measured from a real `RecordDetailView` mount (the `relatedListTitlePlural`
13+
* harness). The page takes its tier from the width of the container it
14+
* occupies — this view's root — and never from the viewport, so the root's
15+
* measured width is the one input varied here: every other element measures
16+
* as the test environment measures it.
17+
*
18+
* - 1440 px: three resident columns, no tab strip; the related lists sit in
19+
* the related column, and History is resident, so its read goes out at open.
20+
* - 1100 px: two columns and the related toggle; the related lists are not
21+
* mounted until the rail opens.
22+
* - 900 px, and an embedded view at any width: the tab strip as before.
23+
* - `?tab=` addresses the strip, so a column tier ignores it.
24+
*/
25+
26+
import * as React from 'react';
27+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
28+
import { render, screen, cleanup, fireEvent, waitFor } from '@testing-library/react';
29+
import { MemoryRouter } from 'react-router-dom';
30+
import { MetadataCtx } from '@object-ui/react';
31+
import { RelatedCountStore } from '@object-ui/components';
32+
33+
vi.mock('@object-ui/auth', async (importOriginal) => ({
34+
...(await importOriginal<Record<string, unknown>>()),
35+
useAuth: () => ({ user: { id: 'u1', name: 'Ada', image: null }, activeOrganization: null }),
36+
createAuthenticatedFetch: () => vi.fn(),
37+
}));
38+
39+
vi.mock('@object-ui/collaboration', async (importOriginal) => ({
40+
...(await importOriginal<Record<string, unknown>>()),
41+
useRecordPresence: () => [],
42+
PresenceAvatars: () => null,
43+
}));
44+
45+
vi.mock('sonner', () => ({
46+
toast: Object.assign(vi.fn(), {
47+
success: vi.fn(),
48+
error: vi.fn(),
49+
info: vi.fn(),
50+
warning: vi.fn(),
51+
loading: vi.fn(),
52+
dismiss: vi.fn(),
53+
}),
54+
}));
55+
56+
// Orthogonal chrome — stubbed so the only asynchrony here is the page's own.
57+
vi.mock('./ActionConfirmDialog', () => ({ ActionConfirmDialog: () => null }));
58+
vi.mock('./ActionParamDialog', () => ({ ActionParamDialog: () => null }));
59+
vi.mock('./ActionResultDialog', () => ({ ActionResultDialog: () => null }));
60+
vi.mock('./FlowRunner', () => ({ FlowRunner: () => null }));
61+
vi.mock('./MetadataInspector', () => ({
62+
MetadataPanel: () => null,
63+
useMetadataInspector: () => ({ showDebug: false, toggle: () => {} }),
64+
}));
65+
66+
import { RecordDetailView } from './RecordDetailView';
67+
68+
const PARENT = 'showcase_project';
69+
const RECORD_ID = 'p-1';
70+
71+
const BASE_FIELDS = {
72+
id: { type: 'text', label: 'Id' },
73+
name: { type: 'text', label: 'Name' },
74+
};
75+
76+
const OBJECTS = [
77+
{
78+
name: PARENT,
79+
label: 'Project',
80+
pluralLabel: 'Projects',
81+
managedBy: 'platform',
82+
// History is on for this object, so the synthesized page carries it.
83+
enable: { trackHistory: true },
84+
fields: BASE_FIELDS,
85+
},
86+
{
87+
name: 'showcase_task',
88+
label: 'Task',
89+
pluralLabel: 'Tasks',
90+
managedBy: 'platform',
91+
fields: { ...BASE_FIELDS, project: { type: 'master_detail', reference: PARENT, label: 'Project' } },
92+
},
93+
{
94+
name: 'showcase_note',
95+
label: 'Note',
96+
pluralLabel: 'Notes',
97+
managedBy: 'platform',
98+
fields: { ...BASE_FIELDS, project: { type: 'lookup', reference: PARENT, label: 'Project' } },
99+
},
100+
{ name: 'sys_audit_log', label: 'Audit log', managedBy: 'platform', fields: BASE_FIELDS },
101+
];
102+
103+
/** The width this view's root measures; every other element measures as the environment does. */
104+
let rootWidth = 0;
105+
let dataSource: { find: ReturnType<typeof vi.fn> } & Record<string, unknown>;
106+
107+
function makeDataSource() {
108+
return {
109+
find: vi.fn(async () => ({ data: [], total: 0 })),
110+
create: vi.fn(async (_o: string, row: unknown) => row),
111+
findOne: vi.fn(async (_o: string, recordId: string) => ({ id: recordId, name: `Project ${recordId}` })),
112+
update: vi.fn(async () => ({})),
113+
delete: vi.fn(async () => ({})),
114+
};
115+
}
116+
117+
function renderPage({ width, embedded = false, search = '' }: { width: number; embedded?: boolean; search?: string }) {
118+
rootWidth = width;
119+
dataSource = makeDataSource();
120+
const metadata = {
121+
objects: OBJECTS,
122+
pages: [],
123+
loading: false,
124+
error: null,
125+
refresh: async () => {},
126+
invalidate: () => {},
127+
ensureType: async () => [],
128+
getItem: async () => null,
129+
getItemsByType: () => [],
130+
} as never;
131+
return render(
132+
<MemoryRouter initialEntries={[`/app/demo/${PARENT}/${RECORD_ID}${search}`]}>
133+
<MetadataCtx.Provider value={metadata}>
134+
<RecordDetailView
135+
dataSource={dataSource as never}
136+
objects={OBJECTS}
137+
onEdit={() => {}}
138+
objectNameOverride={PARENT}
139+
recordIdOverride={RECORD_ID}
140+
embedded={embedded}
141+
/>
142+
</MetadataCtx.Provider>
143+
</MemoryRouter>,
144+
);
145+
}
146+
147+
const tierOf = (container: HTMLElement) =>
148+
container.querySelector('[data-record-page-tier]')?.getAttribute('data-record-page-tier') ?? null;
149+
const column = (container: HTMLElement, name: string) =>
150+
container.querySelector(`[data-record-column="${name}"]`) as HTMLElement | null;
151+
const auditReads = () => dataSource.find.mock.calls.filter((call) => call[0] === 'sys_audit_log').length;
152+
153+
beforeEach(() => {
154+
cleanup();
155+
RelatedCountStore._reset();
156+
vi.stubGlobal(
157+
'fetch',
158+
vi.fn(async () =>
159+
new Response(JSON.stringify({ data: [] }), {
160+
status: 200,
161+
headers: { 'content-type': 'application/json' },
162+
}),
163+
),
164+
);
165+
const measure = HTMLElement.prototype.getBoundingClientRect;
166+
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) {
167+
if (!this.hasAttribute('data-record-page-root')) return measure.call(this);
168+
return { x: 0, y: 0, top: 0, left: 0, right: rootWidth, bottom: 800, width: rootWidth, height: 800, toJSON: () => ({}) } as DOMRect;
169+
});
170+
});
171+
172+
afterEach(() => {
173+
vi.unstubAllGlobals();
174+
vi.restoreAllMocks();
175+
});
176+
177+
describe('RecordDetailView — one record page at two widths (objectstack#26678)', () => {
178+
it('1440 px: three resident columns and no tab strip; History is read at open', async () => {
179+
const { container } = renderPage({ width: 1440 });
180+
await screen.findAllByText('Tasks', undefined, { timeout: 5000 });
181+
expect(tierOf(container)).toBe('three-column');
182+
expect(screen.queryByRole('tablist')).toBeNull();
183+
expect(column(container, 'details')).not.toBeNull();
184+
expect(column(container, 'timeline')).not.toBeNull();
185+
const related = column(container, 'related')!;
186+
expect(related.textContent).toContain('Tasks');
187+
expect(related.textContent).toContain('Notes');
188+
// The header is drawn once.
189+
expect(container.querySelectorAll('h1')).toHaveLength(1);
190+
await waitFor(() => expect(auditReads()).toBeGreaterThan(0));
191+
});
192+
193+
it('1100 px: two columns and the related toggle; the lists mount when the rail opens', async () => {
194+
const { container } = renderPage({ width: 1100 });
195+
const toggle = await screen.findByRole('button', { name: /Related/ }, { timeout: 5000 });
196+
expect(tierOf(container)).toBe('two-column');
197+
expect(screen.queryByRole('tablist')).toBeNull();
198+
expect(column(container, 'details')).not.toBeNull();
199+
expect(column(container, 'timeline')).not.toBeNull();
200+
expect(column(container, 'related')).toBeNull();
201+
expect(screen.queryByText('Tasks')).toBeNull();
202+
fireEvent.click(toggle);
203+
expect(await screen.findAllByText('Tasks', undefined, { timeout: 5000 })).not.toHaveLength(0);
204+
expect(column(container, 'related')!.textContent).toContain('Notes');
205+
});
206+
207+
it('900 px: the tab strip, as before; History waits for its tab', async () => {
208+
const { container } = renderPage({ width: 900 });
209+
expect(await screen.findByRole('tablist', undefined, { timeout: 5000 })).toBeTruthy();
210+
expect(screen.getByRole('tab', { name: /^Details/ })).toBeTruthy();
211+
expect(screen.getByRole('tab', { name: /^Related/ })).toBeTruthy();
212+
expect(tierOf(container)).toBeNull();
213+
expect(auditReads()).toBe(0);
214+
});
215+
216+
it('embedded (drawer / split pane): the tab strip at any width', async () => {
217+
const { container } = renderPage({ width: 1440, embedded: true });
218+
expect(await screen.findByRole('tablist', undefined, { timeout: 5000 })).toBeTruthy();
219+
expect(tierOf(container)).toBeNull();
220+
});
221+
222+
it('`?tab=` keeps working in the tabbed tier and is ignored in the column tiers', async () => {
223+
const tabbed = renderPage({ width: 900, search: '?tab=related' });
224+
const relatedTab = await screen.findByRole('tab', { name: /^Related/ }, { timeout: 5000 });
225+
expect(relatedTab.getAttribute('aria-selected')).toBe('true');
226+
tabbed.unmount();
227+
228+
const { container } = renderPage({ width: 1440, search: '?tab=related' });
229+
await screen.findAllByText('Tasks', undefined, { timeout: 5000 });
230+
expect(tierOf(container)).toBe('three-column');
231+
expect(screen.queryByRole('tablist')).toBeNull();
232+
expect(column(container, 'details')).not.toBeNull();
233+
});
234+
});

0 commit comments

Comments
 (0)