test(cli): refactor tests for async render utilities (#23252)

This commit is contained in:
Tommaso Sciortino
2026-03-20 20:08:29 +00:00
committed by GitHub
parent 86a3a913b5
commit 6c78eb7a39
198 changed files with 3592 additions and 4802 deletions
@@ -33,22 +33,25 @@ describe('useTurnActivityMonitor', () => {
vi.useRealTimers();
});
it('should set operationStartTime when entering Responding state', () => {
const { result, rerender } = renderHook(
it('should set operationStartTime when entering Responding state', async () => {
const { result, rerender } = await renderHook(
({ state }) => useTurnActivityMonitor(state, null, []),
{
initialProps: { state: StreamingState.Idle },
},
);
// Reset time to 1000 to counter the 50ms advanced by renderHook's wait
vi.setSystemTime(1000);
expect(result.current.operationStartTime).toBe(0);
rerender({ state: StreamingState.Responding });
expect(result.current.operationStartTime).toBe(1000);
});
it('should reset operationStartTime when PTY ID changes while responding', () => {
const { result, rerender } = renderHook(
it('should reset operationStartTime when PTY ID changes while responding', async () => {
const { result, rerender } = await renderHook(
({ state, ptyId }) => useTurnActivityMonitor(state, ptyId, []),
{
initialProps: {
@@ -65,13 +68,13 @@ describe('useTurnActivityMonitor', () => {
expect(result.current.operationStartTime).toBe(2000);
});
it('should detect redirection from tool calls', () => {
it('should detect redirection from tool calls', async () => {
// Force mock implementation to ensure it's active
vi.mocked(hasRedirection).mockImplementation((q: string) =>
q.includes('>'),
);
const { result, rerender } = renderHook(
const { result, rerender } = await renderHook(
({ state, pendingToolCalls }) =>
useTurnActivityMonitor(state, null, pendingToolCalls),
{
@@ -115,8 +118,8 @@ describe('useTurnActivityMonitor', () => {
expect(result.current.isRedirectionActive).toBe(true);
});
it('should reset everything when idle', () => {
const { result, rerender } = renderHook(
it('should reset everything when idle', async () => {
const { result, rerender } = await renderHook(
({ state }) => useTurnActivityMonitor(state, 'pty-1', []),
{
initialProps: { state: StreamingState.Responding },