test(native-chat): unmount the cut-turn notice hooks after each test (#27358)

A rendered hook left mounted can commit after happy-dom is torn down, which
fails the shard with "window is not defined" from React's scheduler.

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
OrcaWin
2026-10-10 19:44:23 -07:00
committed by GitHub
co-authored by m4air Claude
parent 24ea55a511
commit cf36928a69
@@ -1,7 +1,7 @@
// @vitest-environment happy-dom
import { renderHook } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import { cleanup, renderHook } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { AgentJournalRenderItem } from '../../../../shared/agent-session-journal-types'
const SCOPE = { kind: 'turn' as const, turnItemId: 'turn-1' }
@@ -74,6 +74,9 @@ vi.mock('./use-structured-agent-session-sends', () => ({
import { useStructuredAgentSession } from './use-structured-agent-session'
describe('useStructuredAgentSession transcript', () => {
// A root left mounted can commit after happy-dom is torn down ("window is not defined").
afterEach(cleanup)
it('shows a cut turn no row explains with its one notice, placed in that turn', () => {
const { result } = renderHook(() =>
useStructuredAgentSession({