Skip to content

Commit a9f755c

Browse files
rekmarksclaude
andauthored
test(kernel-ui): Robustify SendMessageForm tests (#924)
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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: changes are confined to a unit test file and only affect mock reset/cleanup behavior, not production logic. > > **Overview** > Updates `SendMessageForm.test.tsx` to destructure and call `resetMocks()` from `setupOcapKernelMock()` in `afterEach`, ensuring mock validation flags (e.g., `isKRef`) are restored even if a test aborts early. > > Removes the in-test manual re-enabling of `isKRef` in the KRef validation case, relying on centralized teardown for consistent test isolation. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3572568. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9050993 commit a9f755c

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)