Skip to content

Commit 3572568

Browse files
rekmarksclaude
andcommitted
fix(kernel-ui): reset mock state in afterEach to prevent cascading failures
Use resetMocks() in afterEach instead of manual restoration at the end of the test body, so a mid-test assertion failure cannot leave isKRefMock stuck at false for subsequent tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9050993 commit 3572568

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

packages/kernel-ui/src/components/SendMessageForm.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { useRegistry } from '../hooks/useRegistry.ts';
1717
import type { ObjectRegistry } from '../types.ts';
1818
import { SendMessageForm } from './SendMessageForm.tsx';
1919

20-
const { setMockBehavior } = setupOcapKernelMock();
20+
const { resetMocks, setMockBehavior } = setupOcapKernelMock();
2121

2222
vi.mock('../context/PanelContext.tsx', () => ({
2323
usePanelContext: vi.fn(),
@@ -109,6 +109,7 @@ describe('SendMessageForm Component', () => {
109109

110110
afterEach(() => {
111111
cleanup();
112+
resetMocks();
112113
vi.resetModules();
113114
});
114115

@@ -203,8 +204,6 @@ describe('SendMessageForm Component', () => {
203204
// Target should remain unset, button stays disabled
204205
expect(targetSelect).toHaveValue('');
205206
expect(getByTestId('message-send-button')).toBeDisabled();
206-
207-
setMockBehavior({ isKRef: true });
208207
});
209208

210209
it('calls callKernelMethod with correct parameters when Send button is clicked', async () => {

0 commit comments

Comments
 (0)