mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-11-07 06:19:43 -10:00
test(cli): pin same-turn shell notification delivery (#16176)
* test(cli): pin same-turn shell notification delivery Co-authored-by: Qwen-Coder <[email protected]> * style(cli): format the same-turn shell delivery test Lint & Static failed on this head inside the incremental prettier step, naming only Session.test.ts. Reflow the new `notifyShell` cast with the repository's own prettier (3.6.1, matching the ^3.5.3 pin); the hunk is whitespace only, ten lines re-wrapped, no assertion or call changed. Co-authored-by: Qwen-Coder <[email protected]> * test(cli): assert same-turn shell active-work hold Shell holds are reported by category rather than by shell id. Move the check ahead of the delivery assertions so removing the consumed notification leaves the worker active and fails at the assertion meant to witness it. Co-authored-by: Qwen-Coder <[email protected]> --------- Co-authored-by: Qwen-Coder <[email protected]>
This commit is contained in:
1 parent
68c9fa27fb
commit
31f64eb2e9
1 file changed
+42
@@ -18347,6 +18347,48 @@ describe('Session', () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('consumes a same-turn shell result without an automatic rerun', async () => {
|
||||
const notifyShell = mockBackgroundShellRegistry.setNotificationCallback
|
||||
.mock.calls[0][0] as (
|
||||
display: string,
|
||||
model: string,
|
||||
meta: {
|
||||
shellId: string;
|
||||
status: string;
|
||||
sourceTurnId?: string;
|
||||
},
|
||||
) => void;
|
||||
mockChat.sendMessageStream = vi
|
||||
.fn()
|
||||
.mockImplementationOnce(async () => {
|
||||
notifyShell('shell complete', 'SAME_TURN_SHELL_RESULT', {
|
||||
shellId: 'same-shell',
|
||||
status: 'completed',
|
||||
sourceTurnId: core.promptIdContext.getStore(),
|
||||
});
|
||||
return completedText('Initial response');
|
||||
})
|
||||
.mockResolvedValue(completedText('Shell result incorporated'));
|
||||
await session.prompt({
|
||||
sessionId: 'test-session-id',
|
||||
prompt: [{ type: 'text', text: 'start' }],
|
||||
});
|
||||
expect(
|
||||
session
|
||||
.collectActiveWorkHolds()
|
||||
.some((hold) => hold.category === 'shell'),
|
||||
).toBe(false);
|
||||
expect(mockChat.sendMessageStream).toHaveBeenCalledTimes(2);
|
||||
expect(
|
||||
vi.mocked(mockChat.sendMessageStream).mock.calls[1][1].message,
|
||||
).toEqual(expect.arrayContaining([{ text: 'SAME_TURN_SHELL_RESULT' }]));
|
||||
expect(
|
||||
vi
|
||||
.mocked(mockClient.extMethod)
|
||||
.mock.calls.some(([method]) => method === '_qwencode/start_turn'),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('leaves an earlier-turn result for a separately admitted automatic execution', async () => {
|
||||
const notify = notification();
|
||||
mockChat.sendMessageStream = vi
|
||||
|
||||
Reference in new issue
Block a user