Open History to see the last commit
1import { test, expect } from '../fixtures'
2import {
3 selectScenario,
4 runTest,
5 waitForApproval,
6 waitForPendingApprovals,
7 waitForTestComplete,
8 getMetadata,
9 getEventLog,
10 approveEachItem,
11 approveAll,
12 denyAll,
13 cancelAll,
14 resolveAllMixed,
15} from './helpers'
16
17/**
18 * Batch interrupt resolution — several approvals raised at once, resolved via
19 * the root helpers (`resolveInterrupts(true|false)`, `cancelInterrupts()`, and
20 * the resolver form) as well as per-item within the batch.
21 */
22test.describe('Batch interrupt resolution', () => {
23 test('batch - approve all (root, boolean)', async ({
24 page,
25 testId,
26 aimockPort,
27 }) => {
28 await selectScenario(page, 'batch', testId, aimockPort)
29 await runTest(page)
30 await waitForApproval(page)
31 await waitForPendingApprovals(page, 3)
32
33 await approveAll(page)
34 await waitForTestComplete(page)
35
36 const meta = await getMetadata(page)
37 expect(meta.hasError).toBe('false')
38 expect(meta.testComplete).toBe('true')
39 expect(parseInt(meta.completeToolCount)).toBe(3)
40 })
41
42 test('batch - deny all (root, boolean)', async ({
43 page,
44 testId,
45 aimockPort,
46 }) => {
47 await selectScenario(page, 'batch', testId, aimockPort)
48 await runTest(page)
49 await waitForApproval(page)
50 await waitForPendingApprovals(page, 3)
51 await denyAll(page)
52 await waitForTestComplete(page)
53
54 const meta = await getMetadata(page)
55 expect(meta.hasError).toBe('false')
56 expect(meta.testComplete).toBe('true')
57 expect(parseInt(meta.approvalDeniedCount)).toBe(1)
58 })
59
60 test('batch - cancel all (root)', async ({ page, testId, aimockPort }) => {
61 await selectScenario(page, 'batch', testId, aimockPort)
62 await runTest(page)
63 await waitForApproval(page)
64 await waitForPendingApprovals(page, 3)
65 await cancelAll(page)
66 await page.waitForTimeout(500)
67
68 const meta = await getMetadata(page)
69 expect(meta.hasError).toBe('false')
70 expect(parseInt(meta.approvalCancelledCount)).toBe(1)
71 })
72
73 test('batch - approve each item', async ({ page, testId, aimockPort }) => {
74 await selectScenario(page, 'batch', testId, aimockPort)
75 await runTest(page)
76 await waitForApproval(page)
77 await waitForPendingApprovals(page, 3)
78
79 const clicked = await approveEachItem(page)
80 expect(clicked).toBe(3)
81
82 await waitForTestComplete(page)
83 const meta = await getMetadata(page)
84 expect(meta.hasError).toBe('false')
85 expect(parseInt(meta.completeToolCount)).toBe(3)
86 })
87
88 test('batch-mixed - resolve all (root, resolver form)', async ({
89 page,
90 testId,
91 aimockPort,
92 }) => {
93 await selectScenario(page, 'batch-mixed', testId, aimockPort)
94 await runTest(page)
95 await waitForApproval(page)
96 await waitForPendingApprovals(page, 3)
97
98 await resolveAllMixed(page)
99 await waitForTestComplete(page)
100
101 const meta = await getMetadata(page)
102 expect(meta.hasError).toBe('false')
103 expect(meta.testComplete).toBe('true')
104 expect(parseInt(meta.completeToolCount)).toBe(3)
105
106 // The client tool in the mixed batch must have executed.
107 const events = await getEventLog(page)
108 expect(
109 events.some(
110 (e) =>
111 e.type === 'execution-complete' && e.toolName === 'printIntakeTag',
112 ),
113 ).toBe(true)
114 })
115
116 test.afterEach(async ({ page }, testInfo) => {
117 if (testInfo.status !== testInfo.expectedStatus) {
118 console.log('Metadata:', await getMetadata(page))
119 console.log('Events:', await getEventLog(page))
120 }
121 })
122})