test: restore real ColorPicker and CustomSelect exports after wizard step tests (TA-001 round 2) (#2340)

This commit is contained in:
JATMN
2026-10-22 12:55:21 -07:00
committed by GitHub
parent 90b34cbd9b
commit 56da2c4b40
@@ -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<typeof import('./ColorStep.js')>('./ColorStep.js')