Skip to content

Commit 36f0388

Browse files
committed
test(plugin-approvals): four messaging tests read only what their step sends after the opening
Claude-Session: https://claude.ai/code/session_013j5gkUCpqQiti4GgPqqmnt Co-authored-by: Claude <noreply@anthropic.com>
1 parent 284271c commit 36f0388

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎packages/plugins/plugin-approvals/src/approval-service.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,10 @@ describe('ApprovalService (node era)', () => {
13821382
const emitted: any[] = [];
13831383
svc.attachMessaging({ async emit(input) { emitted.push(input); } });
13841384
const req = await svc.openNodeRequest(openInput(['u9']), CTX);
1385+
// The opening tells its approver first (`approval.requested`, pinned in
1386+
// approval-requested-notification.integration.test.ts); this test reads
1387+
// only what the step under test sends after it.
1388+
expect(emitted.splice(0).map(e => e.topic)).toEqual(['approval.requested']);
13851389
await svc.reassign(req.id, { actorId: 'u9', to: 'u7' }, asUser('u9'));
13861390
expect(emitted).toHaveLength(1);
13871391
expect(emitted[0]).toMatchObject({ topic: 'approval.reassigned', audience: ['u7'] });
@@ -1439,6 +1443,10 @@ describe('ApprovalService (node era)', () => {
14391443
const emitted: any[] = [];
14401444
svc.attachMessaging({ async emit(input) { emitted.push(input); } });
14411445
const req = await svc.openNodeRequest(openInput(['u9']), CTX);
1446+
// The opening tells its approver first (`approval.requested`, pinned in
1447+
// approval-requested-notification.integration.test.ts); this test reads
1448+
// only what the step under test sends after it.
1449+
expect(emitted.splice(0).map(e => e.topic)).toEqual(['approval.requested']);
14421450
const out = await svc.requestInfo(req.id, { actorId: 'u9', comment: 'Need the Q3 numbers' }, asUser('u9'));
14431451
expect(out.request.status).toBe('pending');
14441452
expect(out.request.pending_approvers).toEqual(['u9']);
@@ -1700,6 +1708,10 @@ describe('ApprovalService (node era)', () => {
17001708
const req = await svc.openNodeRequest(
17011709
openInput(['u9'], {}, { escalation: { timeoutHours: 2, action: 'notify', escalateTo: 'boss', notifySubmitter: true } }), CTX,
17021710
);
1711+
// The opening tells its approver first (`approval.requested`, pinned in
1712+
// approval-requested-notification.integration.test.ts); this test reads
1713+
// only what the step under test sends after it.
1714+
expect(emitted.splice(0).map(e => e.topic)).toEqual(['approval.requested']);
17031715
makeOverdue(req.id);
17041716
const first = await svc.runEscalations();
17051717
expect(first.escalated).toBe(1);
@@ -1787,6 +1799,10 @@ describe('ApprovalService (node era)', () => {
17871799
const req = await svc.openNodeRequest(
17881800
openInput(['u9'], {}, { escalation: { timeoutHours: 2, action: 'notify', escalateTo: 'approvals_supervisor', notifySubmitter: false } }), CTX,
17891801
);
1802+
// The opening tells its approver first (`approval.requested`, pinned in
1803+
// approval-requested-notification.integration.test.ts); this test reads
1804+
// only what the step under test sends after it.
1805+
expect(emitted.splice(0).map(e => e.topic)).toEqual(['approval.requested']);
17901806
makeOverdue(req.id);
17911807
await svc.runEscalations();
17921808
expect(emitted).toHaveLength(1);

0 commit comments

Comments
 (0)