Skip to content

Commit 73b4151

Browse files
committed
test: await recorded permission responses
1 parent 9cb14de commit 73b4151

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/zcode-client.test.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ test('send waits only for matching-session completion and answers permission req
6767
assert.match(sent.inputId, /^[0-9a-f-]{36}$/); assert.equal(sent.stateRevision, 1);
6868
await client.waitForCompletion(sessionId);
6969
assert.deepEqual(permissions, ['write']);
70-
const calls = (await readFile(record, 'utf8')).trim().split('\n').map(JSON.parse);
71-
assert.ok(calls.some((entry) => entry.id === 9000 && entry.result?.decision === 'allow'));
70+
let permissionResponse;
71+
for (let attempt = 0; attempt < 100 && !permissionResponse; attempt += 1) {
72+
const calls = (await readFile(record, 'utf8')).trim().split('\n').filter(Boolean).map(JSON.parse);
73+
permissionResponse = calls.find((entry) => entry.id === 9000 && entry.result?.decision === 'allow');
74+
if (!permissionResponse) await new Promise((resolve) => setTimeout(resolve, 5));
75+
}
76+
assert.ok(permissionResponse);
7277
}, { FAKE_ZCODE_PERMISSION: '1' });
7378
});
7479

0 commit comments

Comments
 (0)