Skip to content

Commit 9166fa4

Browse files
committed
test(app-shell): pin the record page's Edit on a hand-locked document with inline lines
Claude-Session: https://claude.ai/code/session_017xRBcSAaBEfQpU2yJexSJ8 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 81f9ef2 commit 9166fa4

1 file changed

Lines changed: 47 additions & 2 deletions

File tree

‎ui/packages/app-shell/src/views/RecordDetailView.editLockedByState-32756.test.tsx‎

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ function stateLockBadge(): HTMLElement | null {
133133
}
134134

135135
/** Mount the console record page and wait for the record read and the header. */
136-
async function mountRecordPage(record: Record<string, unknown>, fields: Record<string, unknown>) {
137-
const objects = [objectDef(fields)];
136+
async function mountRecordPage(record: Record<string, unknown>, fields: Record<string, unknown>, served?: any[]) {
137+
const objects = served ?? [objectDef(fields)];
138138
const dataSource = makeDataSource(record);
139139
render(
140140
<MemoryRouter initialEntries={[`/apps/fin/${OBJECT_NAME}/${RECORD_ID}`]}>
@@ -245,3 +245,48 @@ describe('console record header — a record whose state locks every edit-form f
245245
expect(stateLockBadge()).toBeNull();
246246
});
247247
});
248+
249+
/**
250+
* objectstack#38249 — an object whose whole-record hand lock (`uiReadonlyWhen`)
251+
* holds locks its inline lines in the edit form too, so the record page greys
252+
* Edit even though its field groups place a child collection — unless a child
253+
* field owns a hand lock that could open a line cell.
254+
*/
255+
describe('console record header — a hand-locked document with inline lines (objectstack#38249)', () => {
256+
const LINE_OBJECT = 'ebqu_claim_line';
257+
const parent = {
258+
...objectDef({
259+
id: { type: 'text', label: 'Id' },
260+
name: { type: 'text', label: 'Title' },
261+
status: { type: 'text', label: 'Status' },
262+
}),
263+
uiReadonlyWhen: "record.status == 'approved'",
264+
groupSubforms: [{ childObject: LINE_OBJECT, relationshipField: 'claim' }],
265+
};
266+
const line = (amount: Record<string, unknown> = {}) => ({
267+
name: LINE_OBJECT,
268+
label: 'Claim line',
269+
fields: {
270+
claim: { type: 'master_detail', label: 'Claim', reference: OBJECT_NAME },
271+
amount: { type: 'currency', label: 'Amount', ...amount },
272+
},
273+
});
274+
275+
it('draws Edit disabled when the object lock holds and no line cell can open', async () => {
276+
await mountRecordPage(APPROVED, {}, [parent, line()]);
277+
await waitFor(() => expect(headerEditButton()).toBeDisabled());
278+
expect(stateLockBadge()).toBeInTheDocument();
279+
});
280+
281+
it("CONTROL: a child field whose own uiReadonlyWhen is 'false' keeps Edit enabled", async () => {
282+
await mountRecordPage(APPROVED, {}, [parent, line({ uiReadonlyWhen: 'false' })]);
283+
expect(headerEditButton()).not.toBeDisabled();
284+
expect(stateLockBadge()).toBeNull();
285+
});
286+
287+
it('CONTROL: a state the object lock does not hold keeps Edit enabled', async () => {
288+
await mountRecordPage(DRAFT, {}, [parent, line()]);
289+
expect(headerEditButton()).not.toBeDisabled();
290+
expect(stateLockBadge()).toBeNull();
291+
});
292+
});

0 commit comments

Comments
 (0)