From 8b6f31c68bdae1d02b8a27cc8637b939b02a7d03 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Wed, 21 Oct 2026 22:24:05 -0700 Subject: [PATCH] Stabilize pending admission refusal option retry test (#31840) --- .../native-chat/use-structured-agent-session.test.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/native-chat/use-structured-agent-session.test.tsx b/src/renderer/src/components/native-chat/use-structured-agent-session.test.tsx index ed8eb30ceac..db4d2324b59 100644 --- a/src/renderer/src/components/native-chat/use-structured-agent-session.test.tsx +++ b/src/renderer/src/components/native-chat/use-structured-agent-session.test.tsx @@ -317,8 +317,12 @@ describe('useStructuredAgentSession options', () => { }) it('sends the pick again as a new operation after a pending admission refusal', async () => { + const refreshedOptions = Promise.withResolvers() let attempts = 0 mocks.call.mockImplementation((_target, method) => { + if (method === 'agentSession.options' && fence === 4) { + return refreshedOptions.promise + } if (method !== 'agentSession.setOption') { // The hook also holds the session while it is mounted; only option writes are attempts. return Promise.resolve(method === 'agentSession.options' ? OPTIONS : null) @@ -360,7 +364,8 @@ describe('useStructuredAgentSession options', () => { }) fence = 4 rerender() - await waitFor(() => expect(result.current.optionSnapshot).toHaveLength(2)) + expect(result.current.optionSnapshot.every((entry) => !entry.settable)).toBe(true) + await act(async () => refreshedOptions.resolve(OPTIONS)) await act(async () => { expect(await result.current.setStructuredOption('model', 'gpt-fast')).toBe(true) })