Skip to content

Commit 46ad134

Browse files
fix(plugin-detail): a laid-out record page whose first details block draws no body keeps its approval band (#36287)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XTRdLmK9YYgMSCJ7NH2PuUY)_ Fixes #35483 repo:objectstack#4 · os-project-manager · session_01FEkQ5oLLK7uoxp33riiBJL Clause-②: no Metadata-protocol: none This PR also carries the folded card #35484 (authored page with two details nodes), closed into this one by the fold ruling on the card. ## 维护者速读 - 用户能看到什么变化:记录被审批锁定时,「替换详情区」的记录页如果第一个详情区对当前用户隐藏(无权限)或自带标题,原来整页一个锁定标识都不显示,现在由下一个详情区显示一次;其他记录页不变。 - 为什么做:记录页「审批锁定标识每页只显示一次」的收尾,同时核实了自定义页面和页签回退两种情形已经只显示一次。 - 出错会怎样:只影响锁定标识显示在哪个详情区、显示几次,锁定规则本身不变;可以直接撤回。 - 要你做什么:无。 ## What changes Measured first on `origin/main` a5a5312, as the card asks. Three readings, each a rendered test on an approval-locked record through the real `record:details` / `page:tabs` renderers: | Row | Page | Bands drawn | |:---|:---|:---| | (a) | synthesized page falling back to its `page:tabs` strip, two details parts, inside the host's `ApprovalBandOnceScope` | 1 (2 marks); 2 without the scope | | (b) | authored page, two `record:details` nodes | 1 (already pinned at host level by the PR that closed the approvals-tab card) | | (c1) | laid-out synthesized page split around a body table, first part with every section empty | 1 | | (c2) | laid-out slotted page, `details` slot, first `record:details` withheld by `requiredPermissions` | **0** | | (c3) | laid-out slotted page, `details` slot, first `record:details` with `showHeader: true` | **0** | | (c4) | laid-out slotted page, two plain `record:details` | 1 | Rows (a) and (b) were already fixed on `main` by the approvals-tab rework: the host wraps every page drawn as written in `ApprovalBandOnceScope`. The one reachable route to (a) is a slotted page that places a `page:tabs` node in a strip slot (`highlights`, `header`, `actions`, `alerts`): two strips, which `buildDefaultPageColumns` cannot partition. A page the synthesizer writes on its own always lays out. What still failed is the case both cards name ("without dropping the band from a page whose first details node ... draws no body"): on the LAID-OUT page, `RecordPageColumns` gave the band to the first `record:details` node and set `ApprovalBandContext` false on every later one, so a first node that draws no band took it off the page. The fix gives the laid-out details column the same rule as a page drawn as written: - `RecordPageColumns` wraps its details column in `ApprovalBandOnceScope`: the first details body that reaches the band's place draws it. - `ApprovalBandContext` is removed: the per-part suppression was its only provider, and `DetailView` no longer reads it. It was module-internal (not in the barrel, not a prop, not a schema key), so no public face moves. - `resolveApprovalLock` and the lock rule are untouched; a `lockRecord: false` approval still reads `In approval · editable`, once. All edits are under `ui/packages/plugin-detail/**`; `RecordDetailView.tsx` and `RelatedList.tsx` are not touched. Read first, by risk: 1. `ui/packages/plugin-detail/src/RecordPageColumns.tsx` `drawDetailsNodes`: the scope replaces the per-part context; the band still sits above a body table on the split page. 2. `ui/packages/plugin-detail/src/DetailView.tsx`: the band now gates on the scope alone. 3. `ui/packages/plugin-detail/src/defaultRecordPage.ts`: the context and its doc, merged into the scope's doc. ## Tests - `RecordPageColumns.test.tsx`: a new top-level describe (the shared harness file) pins a first part withheld by `requiredPermissions` and a first part with `showHeader: true` (band once, on the second part), a `lockRecord: false` approval behind a withheld first part (editable once, never locked), and CONTROLs for two drawing parts (band on the first), a single part, and a single withheld part (no band, notice shown). The harness's `record:details` stub now hands its node to the body it mounts. - `DetailView.approvalBandOnce-35484.test.tsx`: a new top-level describe draws the synthesized page's `page:tabs` fallback through the real renderers: the page cannot be laid out and its overview holds two details parts; one band under the scope; CONTROL two bands without it; CONTROL one part draws its one band. The file header's pointer to the host pin now names the file that holds it. Reverse verification (one-off, fix committed first): the three `src` files restored to a5a5312, the two test files kept: 3 failed, 39 passed (the two first-part cases and the `lockRecord: false` case: no band found). Restored with `git checkout HEAD`, `git diff HEAD` empty. ## Acceptance notes - Overlap: `overlap-check` reports PR #36234 (seat 1, the field-list card) sharing the four plugin-detail files, with a textual conflict in `RecordPageColumns.test.tsx` (both append to it). Whichever lands second takes a mechanical merge of that test file. - (a) is reachable only through a slotted page with a `page:tabs` node in a strip slot; whether that shape should be authorable at all is not this card's question (noted, not filed). ## Verification Two-minute check: `pnpm --dir ui exec vitest run packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx packages/plugin-detail/src/__tests__/DetailView.approvalBandOnce-35484.test.tsx` — expect 42 passed. <details><summary>Readings at head 02f7053 (local, under the shared verify lock; shared-box wall times)</summary> - Measurement (scratch file, deleted), real renderers at a5a5312: `(a) scoped marks 2 bands 1` · `(a) unscoped bands 2` · `(c1) bands 1` · `(c2) refusal 1 bands 0` · `(c3) bands 0` · `(c4) bands 1`; slotted `highlights` slot with `page:tabs` gives `buildDefaultPageColumns` null. - Two pinned files after the fix: `Test Files 2 passed (2)`, `Tests 42 passed (42)`, `VERDICT command-exit 0`. - Reverse verification (src at a5a5312, tests kept): `Tests 3 failed | 39 passed (42)`, `VERDICT command-exit 1`; restored, `git diff HEAD` empty. - Whole `@object-ui/plugin-detail` suite: `Test Files 403 passed | 1 skipped (404)`, `Tests 3737 passed | 18 skipped (3755)`, `VERDICT command-exit 0`. - `pnpm --filter @object-ui/plugin-detail type-check` (both programs, `tsc --noEmit && tsc -p tsconfig.test.json`): `VERDICT command-exit 0`. - `dispatch-gates --commands` derived 38 families; 37 run locally, each exit 0; `pnpm --dir ui exec vitest run scripts/` is reported separately in the dispatch report. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5oLLK7uoxp33riiBJL)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8bc3c13 commit 46ad134

6 files changed

Lines changed: 228 additions & 67 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/plugin-detail': patch
3+
---
4+
5+
fix(plugin-detail): a laid-out record page whose first details block draws no body still shows the approval band
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The laid-out record page draws the record's approval band ("Locked for approval" / "In approval · editable", with its recall lever and tally) once per page. It used to give the band to the first `record:details` node of the details column and tell every later one not to draw it, so on a slotted page whose `details` slot puts first a `record:details` the reader may not see (its `requiredPermissions` withheld) or one that draws its own header (`showHeader: true`), a locked record showed no band at all. The details column now draws the band by the first details body that reaches its place, the rule a page drawn as written already follows: the next part draws it. Every other page reads as before, the band stays above a body table, and whether the band reads locked or editable (a `lockRecord: false` approval node) is unchanged.

‎ui/packages/plugin-detail/src/DetailView.tsx‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
} from 'lucide-react';
3838
import { DetailSection } from './DetailSection';
3939
import { EmptySectionsFold, EmptySectionsLine } from './EmptySectionsFold';
40-
import { ApprovalBandContext, EmptySectionsLineContext, useApprovalBandOnce, useDefaultRecordPage } from './defaultRecordPage';
40+
import { EmptySectionsLineContext, useApprovalBandOnce, useDefaultRecordPage } from './defaultRecordPage';
4141
import { DetailTabs } from './DetailTabs';
4242
import { SectionGroup } from './SectionGroup';
4343
import { HeaderHighlight } from './HeaderHighlight';
@@ -328,11 +328,9 @@ export const DetailView: React.FC<DetailViewProps> = ({
328328
// approval band below is live, per-viewer workflow state, not document
329329
// content, so it does not print.
330330
const isPrintPage = usePrintPage() !== null;
331-
// objectstack#35253 — `false` on every details part of a split default page
332-
// but the first: the approval band is the record's, drawn once per page.
333-
// objectstack#35483 / objectstack#35484 — and on a page drawn as written,
334-
// the first body to reach the band's place draws it (`ApprovalBandOnceScope`).
335-
const drawsApprovalBand = React.useContext(ApprovalBandContext);
331+
// objectstack#35253, objectstack#35483, objectstack#35484 — the approval
332+
// band is the record's, drawn once per page: under a page's
333+
// `ApprovalBandOnceScope` the first body to reach the band's place draws it.
336334
const approvalBandOnce = useApprovalBandOnce();
337335
// objectstack#27055, objectstack#35019 — a record page's details body folds
338336
// its entirely empty sections into one line (`EmptySectionsLine`): every
@@ -1772,12 +1770,11 @@ export const DetailView: React.FC<DetailViewProps> = ({
17721770
status field through `record:details`, the way `record:path` leaves
17731771
the current stage to it.
17741772
1775-
objectstack#35253 — and once per page: a default page split around a
1776-
body table draws it on its first details part only
1777-
(`ApprovalBandContext`), and on a page drawn as written by its
1778-
first details body (`ApprovalBandOnceScope`). */}
1779-
{inlineEdit && schema.showHeader === false && !isPrintPage && drawsApprovalBand && approvalBandOnce.mark}
1780-
{inlineEdit && schema.showHeader === false && !isPrintPage && drawsApprovalBand && approvalBandOnce.draws && (() => {
1773+
objectstack#35253 — and once per page: under the page's
1774+
`ApprovalBandOnceScope`, by the first details body that reaches
1775+
this place (objectstack#35483, objectstack#35484). */}
1776+
{inlineEdit && schema.showHeader === false && !isPrintPage && approvalBandOnce.mark}
1777+
{inlineEdit && schema.showHeader === false && !isPrintPage && approvalBandOnce.draws && (() => {
17811778
// Two independent facts, not one (objectui#2902):
17821779
//
17831780
// isPending — an approval is running on this record.

‎ui/packages/plugin-detail/src/RecordPageColumns.tsx‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from './synth/recordPageColumns';
2424
import { useDetailTranslation } from './useDetailTranslation';
2525
import { RecordBodyTablesContext, RelatedEnlargeContext, RelatedListEnlargedContext } from './relatedListCompact';
26-
import { ApprovalBandContext, DefaultRecordPageContext, DetailsColumnCapContext } from './defaultRecordPage';
26+
import { ApprovalBandOnceScope, DefaultRecordPageContext, DetailsColumnCapContext } from './defaultRecordPage';
2727
import { RECORD_TAB_OVERVIEW, RecordTabRow, type RecordTab, type RecordTabArrangeEdit } from './RecordTabRow';
2828
import {
2929
RECORD_TAB_APPROVALS,
@@ -245,22 +245,16 @@ function drawNodes(nodes: any[]): React.ReactNode {
245245
/**
246246
* The details column's nodes (objectstack#35253): the synthesized page splits
247247
* its details around a body table, one `record:details` per run of sections,
248-
* and the record's approval band is drawn by the FIRST part alone — above the
249-
* table — so the page shows one band, not one per part. A context provider
250-
* adds no DOM, so the column's siblings stay siblings (`drawNodes`).
248+
* and the record's approval band is drawn once per page — by the first details
249+
* body that reaches the band's place (`ApprovalBandOnceScope`), above the
250+
* table. objectstack#35483 / objectstack#35484 — the same rule as a page drawn
251+
* as written: a first `record:details` that draws no body (withheld by its
252+
* `requiredPermissions`, or drawing its own header) leaves the band to the next
253+
* part instead of taking it off the page. A context provider adds no DOM, so
254+
* the column's siblings stay siblings (`drawNodes`).
251255
*/
252256
function drawDetailsNodes(nodes: any[]): React.ReactNode {
253-
const firstDetails = nodes.findIndex((node) => node?.type === 'record:details');
254-
return nodes.map((node, index) => {
255-
const key = (node && typeof node === 'object' && node.id) || index;
256-
const drawn = <SchemaRenderer key={key} schema={toRenderableSchema(node)} />;
257-
if (node?.type !== 'record:details' || index === firstDetails) return drawn;
258-
return (
259-
<ApprovalBandContext.Provider key={key} value={false}>
260-
{drawn}
261-
</ApprovalBandContext.Provider>
262-
);
263-
});
257+
return <ApprovalBandOnceScope>{drawNodes(nodes)}</ApprovalBandOnceScope>;
264258
}
265259

266260
const LINE_BUTTON =

‎ui/packages/plugin-detail/src/__tests__/DetailView.approvalBandOnce-35484.test.tsx‎

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,24 @@
1616
* still reads editable, and a first node that draws no band leaves the band
1717
* to the next. Measured on the body the `record:details` block mounts
1818
* (`showHeader: false`, inline edit on); the host wiring is pinned in
19-
* `app-shell/src/views/RecordDetailView.approvalBandOnce-35484.test.tsx`.
19+
* `app-shell/src/views/RecordDetailView.recordOpenRequests-12701.test.tsx`
20+
* (an authored page, drawn by the same host branch as the tabs fallback).
21+
* The second describe draws the synthesized page's `page:tabs` fallback
22+
* through the real renderers (objectstack#35483).
2023
*/
2124

2225
import * as React from 'react';
23-
import { describe, it, expect, afterEach } from 'vitest';
24-
import { render, screen, cleanup } from '@testing-library/react';
25-
import { InlineEditProvider } from '@object-ui/react';
26+
import { describe, it, expect, afterEach, vi } from 'vitest';
27+
import { render, screen, cleanup, waitFor } from '@testing-library/react';
28+
import { InlineEditProvider, RecordContextProvider, SchemaRenderer } from '@object-ui/react';
29+
import '../index';
2630
import { DetailView } from '../DetailView';
2731
import { ApprovalBandOnceScope } from '../defaultRecordPage';
32+
import { buildDefaultPageColumns } from '../synth/recordPageColumns';
33+
import { buildDefaultPageSchema } from '../synth/buildDefaultPageSchema';
34+
35+
/** `useRecordEditable`'s explain probe, answered with its fail-open 501 (the binding suites do the same). */
36+
vi.stubGlobal('fetch', (async () => new Response(null, { status: 501 })) as unknown as typeof globalThis.fetch);
2837

2938
afterEach(cleanup);
3039

@@ -97,3 +106,74 @@ describe('one approval band on a page drawn as written (objectstack#35484, objec
97106
expect(container.querySelectorAll('[data-approval-band-mark]').length).toBe(2);
98107
});
99108
});
109+
110+
/**
111+
* objectstack#35483 — the synthesized page that falls back to its `page:tabs`
112+
* strip. `buildDefaultPageColumns` lays out every page the synthesizer writes
113+
* on its own; a slotted page that places a `page:tabs` node in a strip slot
114+
* (`highlights` here) carries two strips, which the partition cannot read, so
115+
* the host draws the page as written, inside `ApprovalBandOnceScope`. Split
116+
* around a body table, its 概览 tab holds two `record:details` parts: drawn by
117+
* the real `record:details` and `page:tabs` renderers, the band is drawn once.
118+
*/
119+
describe('one approval band on the synthesized page\'s page:tabs fallback (objectstack#35483)', () => {
120+
const quote = {
121+
name: 'quote',
122+
fields: {
123+
name: { type: 'text', label: 'Name', group: 'basic' },
124+
terms: { type: 'textarea', label: 'Terms', group: 'terms' },
125+
},
126+
fieldGroups: [{ key: 'basic' }, { key: 'lines', relatedList: 'quote_line_item' }, { key: 'terms' }],
127+
};
128+
const SECTIONS = [
129+
{ name: 'basic', label: 'Basic', fields: ['name'] },
130+
{ name: 'terms', label: 'Terms', fields: ['terms'] },
131+
];
132+
const LINES = { objectName: 'quote_line_item', relationshipField: 'quote', title: 'Lines', isPrimary: true };
133+
const STRIP_TABS = { type: 'page:tabs', properties: { items: [{ label: 'Extra', value: 'extra', children: [] }] } };
134+
const fallback = (related: unknown[]) =>
135+
buildDefaultPageSchema(quote as any, { sections: SECTIONS as any, related: related as any, slots: { highlights: [STRIP_TABS] } as any });
136+
const overviewOf = (page: any) => page.regions[0].components.filter((n: any) => n.type === 'page:tabs').at(-1).properties.items[0].children;
137+
const DATA = { id: 'Q1', name: 'Q-1', terms: 'net 30' };
138+
const drawLocked = (page: unknown, scoped = true) =>
139+
render(
140+
<InlineEditProvider canEdit={false} locked>
141+
<RecordContextProvider
142+
objectName="quote"
143+
recordId="Q1"
144+
data={DATA}
145+
objectSchema={quote as any}
146+
dataSource={{ find: async () => [], findOne: async () => DATA } as any}
147+
>
148+
{scoped ? <ApprovalBandOnceScope><SchemaRenderer schema={page as any} /></ApprovalBandOnceScope> : <SchemaRenderer schema={page as any} />}
149+
</RecordContextProvider>
150+
</InlineEditProvider>,
151+
);
152+
const marks = () => document.querySelectorAll('[data-approval-band-mark]');
153+
154+
it('the page cannot be laid out, and its overview holds two details parts around the body table', () => {
155+
const page = fallback([LINES]);
156+
expect(buildDefaultPageColumns(page)).toBeNull();
157+
expect(overviewOf(page).map((n: any) => n.type)).toEqual(['record:details', 'record:related_list', 'record:details']);
158+
});
159+
160+
it('two details parts under the host scope: "Locked for approval" once', async () => {
161+
drawLocked(fallback([LINES]));
162+
await waitFor(() => expect(marks()).toHaveLength(2));
163+
expect(screen.getAllByText('Locked for approval')).toHaveLength(1);
164+
});
165+
166+
it('CONTROL: the same page outside the scope draws it on each part (what the scope holds)', async () => {
167+
drawLocked(fallback([LINES]), false);
168+
await waitFor(() => expect(screen.getAllByText('Locked for approval')).toHaveLength(2));
169+
});
170+
171+
it('CONTROL: one details part on the fallback page draws its one band', async () => {
172+
const page = fallback([]);
173+
expect(buildDefaultPageColumns(page)).toBeNull();
174+
expect(overviewOf(page).map((n: any) => n.type)).toEqual(['record:details']);
175+
drawLocked(page);
176+
await waitFor(() => expect(marks()).toHaveLength(1));
177+
expect(screen.getAllByText('Locked for approval')).toHaveLength(1);
178+
});
179+
});

‎ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx‎

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
* column beside the other tabs on a wide full page (objectstack#35890), and
1616
* that no width draws the right rail of summary cards any more.
1717
*
18-
* One describe (objectstack#35253) opts each `record:details` stub into
19-
* mounting the `DetailView` the real block mounts (`showHeader: false`,
20-
* inline edit on), so the approval band it draws is measured on the laid-out
21-
* page; every other describe keeps the bare stub.
18+
* Two describes (objectstack#35253, objectstack#35483) opt each
19+
* `record:details` stub into mounting the `DetailView` the real block mounts
20+
* (`showHeader: false`, inline edit on), so the approval band it draws is
21+
* measured on the laid-out page; every other describe keeps the bare stub.
2222
*/
2323

2424
import * as React from 'react';
@@ -30,7 +30,7 @@ import { RecordContextProvider } from '@object-ui/react';
3030
const harness = vi.hoisted(() => ({
3131
/** Set by the objectstack#35253 describe: a `record:details` stub mounts `body`. */
3232
detailBodies: false,
33-
body: null as React.ComponentType | null,
33+
body: null as React.ComponentType<{ schema: any }> | null,
3434
/** The content width every element reports (jsdom lays nothing out). */
3535
width: 0,
3636
}));
@@ -42,7 +42,7 @@ vi.mock('@object-ui/react', async (importOriginal) => {
4242
return (
4343
<div data-node={schema?.type} data-cap={React.useContext(DetailsColumnCapContext)}>
4444
{schema?.properties?.objectName ?? schema?.type}
45-
{Body && <Body />}
45+
{Body && <Body schema={schema} />}
4646
</div>
4747
);
4848
};
@@ -430,6 +430,101 @@ describe('RecordPageColumns — the approval band is drawn once per page (object
430430
});
431431
});
432432

433+
/**
434+
* objectstack#35483 / objectstack#35484 — the band is not dropped when the
435+
* FIRST details part draws no body. A slotted page's `details` slot places the
436+
* author's own `record:details` nodes in the laid-out details column; the first
437+
* may draw no band of its own: its `requiredPermissions` withheld (the real
438+
* block draws its insufficient-permissions notice in place of the body,
439+
* `record-blocks.requiredPermissions-gate.test.tsx`) or `showHeader: true`
440+
* (the body draws its own header, and no band). The column draws the band once
441+
* by the first body that reaches its place (`ApprovalBandOnceScope`), so the
442+
* next part draws it. Before, every part after the first was told not to draw
443+
* it and such a page showed no band at all, on a locked record.
444+
*/
445+
describe('RecordPageColumns — a first details part that draws no band leaves it to the next (objectstack#35483, objectstack#35484)', () => {
446+
/** What `record:details` mounts for its node: the notice when withheld, else its body. */
447+
const PartBody = ({ schema }: { schema: any }) => {
448+
const p = { ...schema, ...(schema?.properties ?? {}) };
449+
if (Array.isArray(p.requiredPermissions) && p.requiredPermissions.length > 0) {
450+
return <p role="status">Insufficient permissions to view details.</p>;
451+
}
452+
return (
453+
<DetailView
454+
schema={{ type: 'detail-view', objectName: 'quote', showHeader: p.showHeader ?? false, data: { id: 'Q1', name: 'Q-1' }, sections: [] } as any}
455+
inlineEdit
456+
recordFromHost
457+
/>
458+
);
459+
};
460+
beforeEach(() => {
461+
harness.detailBodies = true;
462+
harness.body = PartBody;
463+
});
464+
afterEach(() => {
465+
harness.detailBodies = false;
466+
harness.body = null;
467+
});
468+
469+
const quote = { name: 'quote', fields: { name: { type: 'text', label: 'Name' }, terms: { type: 'textarea', label: 'Terms' } } };
470+
const part = (id: string, props: Record<string, unknown> = {}) => ({
471+
type: 'record:details',
472+
id,
473+
properties: { sections: [{ name: id, label: id, fields: [id === 'first' ? 'name' : 'terms'] }], ...props },
474+
});
475+
const slotted = (details: any[]) => buildDefaultPageColumns(buildDefaultPageSchema(quote, { slots: { details } } as any))!;
476+
const drawPage = (columns: ReturnType<typeof slotted>, approval: { locked?: boolean; approvalPending?: boolean; canEdit?: boolean }) =>
477+
render(
478+
<InlineEditProvider canEdit={approval.canEdit ?? false} locked={approval.locked} approvalPending={approval.approvalPending}>
479+
<RecordPageColumns tier="wide" columns={columns} />
480+
</InlineEditProvider>,
481+
);
482+
/** The details parts (by node id) whose subtree shows `text`. */
483+
const partsShowing = (container: HTMLElement, text: string) =>
484+
Array.from(column(container, 'details')!.querySelectorAll('[data-node="record:details"]'))
485+
.map((node, index) => ({ node, index }))
486+
.filter(({ node }) => node.textContent?.includes(text))
487+
.map(({ index }) => index);
488+
489+
it('the slotted page lays its two details nodes out in the details column', () => {
490+
expect(slotted([part('first'), part('second')]).details.map((n: any) => n.id)).toEqual(['first', 'second']);
491+
});
492+
493+
for (const [why, props] of [
494+
['withheld by its requiredPermissions', { requiredPermissions: ['quote.audit'] }],
495+
['drawing its own header', { showHeader: true }],
496+
] as const) {
497+
it(`a first part ${why}: "Locked for approval" once, on the second part`, () => {
498+
const { container } = drawPage(slotted([part('first', props), part('second')]), { locked: true });
499+
expect(screen.getAllByText('Locked for approval')).toHaveLength(1);
500+
expect(partsShowing(container, 'Locked for approval')).toEqual([1]);
501+
});
502+
}
503+
504+
it('a `lockRecord: false` approval behind a withheld first part reads editable, once — never locked', () => {
505+
drawPage(slotted([part('first', { requiredPermissions: ['quote.audit'] }), part('second')]), { approvalPending: true, locked: false, canEdit: true });
506+
expect(screen.queryByText('Locked for approval')).toBeNull();
507+
expect(screen.getAllByText('In approval · editable')).toHaveLength(1);
508+
});
509+
510+
it('CONTROL: two drawing parts keep the band on the first, once', () => {
511+
const { container } = drawPage(slotted([part('first'), part('second')]), { locked: true });
512+
expect(screen.getAllByText('Locked for approval')).toHaveLength(1);
513+
expect(partsShowing(container, 'Locked for approval')).toEqual([0]);
514+
});
515+
516+
it('CONTROL: a single slotted details part draws its one band', () => {
517+
drawPage(slotted([part('first')]), { locked: true });
518+
expect(screen.getAllByText('Locked for approval')).toHaveLength(1);
519+
});
520+
521+
it('CONTROL: a single withheld part draws no band and no body (nothing on the page reaches its place)', () => {
522+
drawPage(slotted([part('first', { requiredPermissions: ['quote.audit'] })]), { locked: true });
523+
expect(screen.queryByText('Locked for approval')).toBeNull();
524+
expect(screen.getByText('Insufficient permissions to view details.')).toBeTruthy();
525+
});
526+
});
527+
433528
/**
434529
* objectstack#36147 — the field area is one list wherever it sits beside other
435530
* tabs or is one of them: the drawer, the phone, the narrow page and the

0 commit comments

Comments
 (0)