diff --git a/src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx b/src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx index 889ea6dd6..6ff94147c 100644 --- a/src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx +++ b/src/components/agents/new-agent-creation/wizard-steps/wizardSteps.test.tsx @@ -1,6 +1,6 @@ import { PassThrough } from 'node:stream' -import { afterEach, beforeEach, expect, mock, test } from 'bun:test' +import { afterAll, afterEach, beforeEach, expect, mock, test } from 'bun:test' import React, { useEffect } from 'react' import stripAnsi from 'strip-ansi' @@ -8,6 +8,15 @@ import { Box, createRoot, Text } from '../../../../ink.js' import { WizardProvider, useWizard } from '../../../wizard/index.js' import type { AgentWizardData } from '../types.js' +// Copy real exports before mock.module can replace live module bindings. +const nonce = `${Date.now()}-${Math.random()}` +const realColorPicker = { + ...await import(`../../ColorPicker.js?real=${nonce}`), +} +const realSelect = { + ...await import(`../../../CustomSelect/select.js?real=${nonce}`), +} + type ColorPickerProps = { onConfirm: (color: string | undefined) => void } @@ -160,6 +169,12 @@ afterEach(() => { } }) +afterAll(() => { + // mock.restore() does not remove Bun module mock registrations. + mock.module('../../ColorPicker.js', () => realColorPicker) + mock.module('../../../CustomSelect/select.js', () => realSelect) +}) + test('ColorStep does not create a final agent when required wizard data is missing', async () => { const { ColorStep } = await importFreshStep('./ColorStep.js')