Skip to content

Commit 01a894f

Browse files
committed
test(app-shell): pin the approver band fold on both call sites, add changeset
The record page's approver tests read the folded levers from the band's menu; new pins cover the approver, approver+submitter, submitter-only and override-only viewers, the variant-driven split and the request page. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX
1 parent 9fdc30a commit 01a894f

4 files changed

Lines changed: 485 additions & 1 deletion

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(app-shell): a record under approval shows the approver one folded band: a status line, the two decisions as buttons, and one menu for the rest
7+
8+
Clause-②: yes (widening — new @object-ui/i18n en keys only; no metadata/schema accept set)
9+
Metadata-protocol: none
10+
11+
An approver who opens a record under approval used to see every declared decision action as its own button above the page body (Approve, Reject, Reassign, Send back, Request info, Reply, and Recall for an approver who also submitted), beside the record's own action row in the header. The band is now folded for any viewer the server says can act (`viewer.can_act === true`) once more than two of its actions are shown:
12+
13+
- a status line names the task, the step's number on the served route and its label, and the submitter ("You submitted this" for an approver who also submitted);
14+
- the actions whose declared `variant` is `primary` or `danger` (today Approve and Reject) stay buttons; on a phone they share one row at equal width;
15+
- every other action, including one declared with no variant, goes into one neutral "More approval actions" menu. Reply stays in that menu, so it is reachable on every layout.
16+
17+
The business record page and the approval request page draw the same band. Each folded action keeps its own `visible`, `disabled` and permission gates and its own dialog, and sends the same request. Menu actions still count as drawn for `onDrawnActionsChange`. The record's header actions do not move.
18+
19+
Unchanged: the submitter who holds no slot, the override-only administrator (who keeps the existing admin-override fold), a backend that sends no `viewer` block, and any host that does not pass the new `foldDecisions` prop to `DeclaredActionsBar`.
20+
21+
New `@object-ui/i18n` keys, in every pack: `approvalsInbox.awaitingYourDecision`, `approvalsInbox.stepNumber`, `approvalsInbox.submittedByName`, `approvalsInbox.moreDecisionActions`.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* approvalDecisionFold (objectstack#34361) — the three readings the approver
5+
* band makes off metadata and the served request row.
6+
*/
7+
8+
import { describe, it, expect } from 'vitest';
9+
import { currentStepNumber, isActingApprover, isLeadDecision } from './approvalDecisionFold';
10+
11+
describe('isLeadDecision (objectstack#34361)', () => {
12+
it('keeps a primary or danger action out of the fold', () => {
13+
expect(isLeadDecision({ name: 'approval_approve', variant: 'primary' })).toBe(true);
14+
expect(isLeadDecision({ name: 'approval_reject', variant: 'danger' })).toBe(true);
15+
});
16+
17+
it('folds an action that declares no variant, or any other variant', () => {
18+
expect(isLeadDecision({ name: 'approval_reassign' })).toBe(false);
19+
expect(isLeadDecision({ name: 'approval_comment', variant: 'secondary' })).toBe(false);
20+
expect(isLeadDecision({ name: 'x', variant: 'ghost' })).toBe(false);
21+
expect(isLeadDecision(null)).toBe(false);
22+
});
23+
24+
it('reads the variant, not the name', () => {
25+
// A name the shipped set uses for a decision, without the variant, folds.
26+
expect(isLeadDecision({ name: 'approval_approve' })).toBe(false);
27+
// A metadata-only action an author marks primary stays a button.
28+
expect(isLeadDecision({ name: 'approval_escalate', variant: 'primary' })).toBe(true);
29+
});
30+
});
31+
32+
describe('isActingApprover (objectstack#34361)', () => {
33+
it('is true only for an explicit can_act: true', () => {
34+
expect(isActingApprover({ viewer: { can_act: true, is_submitter: true } })).toBe(true);
35+
expect(isActingApprover({ viewer: { can_act: false, can_override: true } })).toBe(false);
36+
expect(isActingApprover({ viewer: { can_act: false, is_submitter: true } })).toBe(false);
37+
});
38+
39+
it('cannot tell without a viewer block, and reads that as no', () => {
40+
expect(isActingApprover({})).toBe(false);
41+
expect(isActingApprover({ viewer: {} })).toBe(false);
42+
expect(isActingApprover({ viewer: { can_act: 'true' } })).toBe(false);
43+
expect(isActingApprover(null)).toBe(false);
44+
});
45+
});
46+
47+
describe('currentStepNumber (objectstack#34361)', () => {
48+
it('numbers the current step on the served route from 1', () => {
49+
const route = {
50+
steps: [
51+
{ id: 'a', label: 'Manager', state: 'done' },
52+
{ id: 'b', label: 'Finance', state: 'current' },
53+
{ id: 'c', label: 'CFO', state: 'upcoming' },
54+
],
55+
ahead: 'end',
56+
};
57+
expect(currentStepNumber({ flow_route: route })).toBe(2);
58+
});
59+
60+
it('says nothing when the route is absent or names no current step', () => {
61+
expect(currentStepNumber({})).toBeUndefined();
62+
expect(currentStepNumber({ flow_route: { steps: [{ id: 'a', state: 'done' }] } })).toBeUndefined();
63+
expect(currentStepNumber({ flow_route: { steps: 'nope' } })).toBeUndefined();
64+
expect(currentStepNumber(undefined)).toBeUndefined();
65+
});
66+
});

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,20 @@ function renderRecordPage() {
361361

362362
const decisionButton = (name: string) => screen.queryByTestId(`declared-action-${name}`);
363363

364+
/**
365+
* objectstack#34361 (ruling A) — the approver's band keeps the two decisions
366+
* as buttons and folds every other lever into one menu, so those levers are
367+
* read from the open menu.
368+
*/
369+
async function openDecisionMenu() {
370+
const trigger = await screen.findByTestId('declared-actions-decision-menu');
371+
fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false, pointerType: 'mouse' });
372+
return screen.findByRole('menu');
373+
}
374+
375+
/** The approver's levers that the band folds behind its menu. */
376+
const APPROVER_FOLDED = ['approval_reassign', 'approval_send_back', 'approval_request_info'];
377+
364378
beforeEach(() => {
365379
cleanup();
366380
authFetchSpy.mockClear();
@@ -377,16 +391,23 @@ describe('record page decision actions — a GROUP approver (objectui#3055)', ()
377391
renderRecordPage();
378392

379393
await waitFor(() => expect(decisionButton('approval_approve')).toBeTruthy());
394+
expect(decisionButton('approval_approve')?.tagName).toBe('BUTTON');
395+
expect(decisionButton('approval_reject')?.tagName).toBe('BUTTON');
396+
await openDecisionMenu();
380397
for (const name of APPROVER_DECISIONS) {
381398
expect(decisionButton(name), `${name} must be offered to a pending approver`).toBeTruthy();
382399
}
400+
for (const name of APPROVER_FOLDED) {
401+
expect(decisionButton(name)?.getAttribute('role'), `${name} sits in the band's menu`).toBe('menuitem');
402+
}
383403
});
384404

385405
it('offers reassign / send back / request info — the three that had NO entry point', async () => {
386406
stubApprovalsApi(pendingRequest({ can_act: true, is_submitter: false, can_override: false }));
387407
renderRecordPage();
388408

389-
await waitFor(() => expect(decisionButton('approval_reassign')).toBeTruthy());
409+
await openDecisionMenu();
410+
expect(decisionButton('approval_reassign')).toBeTruthy();
390411
expect(decisionButton('approval_send_back')).toBeTruthy();
391412
expect(decisionButton('approval_request_info')).toBeTruthy();
392413
});
@@ -416,6 +437,7 @@ describe('record page decision actions — a GROUP approver (objectui#3055)', ()
416437
it('dispatches the decision on the REQUEST, not on the business record it is opened on', async () => {
417438
stubApprovalsApi(pendingRequest({ can_act: true, is_submitter: false, can_override: false }));
418439
renderRecordPage();
440+
await openDecisionMenu();
419441
await waitFor(() => expect(decisionButton('approval_send_back')).toBeTruthy());
420442
authFetchSpy.mockClear();
421443

@@ -437,6 +459,7 @@ describe('record page decision actions — a GROUP approver (objectui#3055)', ()
437459
it('sends a declared decision output as its `outputs.<key>` param, for the door to fold', async () => {
438460
stubApprovalsApi(pendingRequest({ can_act: true, is_submitter: false, can_override: false }));
439461
renderRecordPage();
462+
await openDecisionMenu();
440463
await waitFor(() => expect(decisionButton('approval_send_back')).toBeTruthy());
441464
authFetchSpy.mockClear();
442465

0 commit comments

Comments
 (0)