From 6c61790063eb365d12b38373db215c4d3d02ac4f Mon Sep 17 00:00:00 2001 From: Kevin Codex Date: Mon, 6 Apr 2026 18:10:02 +0800 Subject: [PATCH] test: fix leaked ink mocks in full suite (#424) --- .../PromptInputFooterSuggestions.tsx | 22 ++++----- src/components/ThemePicker.test.tsx | 46 +------------------ 2 files changed, 9 insertions(+), 59 deletions(-) diff --git a/src/components/PromptInput/PromptInputFooterSuggestions.tsx b/src/components/PromptInput/PromptInputFooterSuggestions.tsx index 3307e4ce..4589ef1d 100644 --- a/src/components/PromptInput/PromptInputFooterSuggestions.tsx +++ b/src/components/PromptInput/PromptInputFooterSuggestions.tsx @@ -123,8 +123,6 @@ const SuggestionItemRow = memo(function SuggestionItemRow({ maxColumnWidth ?? stringWidth(item.displayText) + 5, maxNameWidth, ) - const displayTextColor = isSelected ? 'inverseText' : item.color - const shouldDim = !isSelected let displayText = item.displayText if (stringWidth(displayText) > displayTextWidth - 2) { @@ -144,21 +142,17 @@ const SuggestionItemRow = memo(function SuggestionItemRow({ const truncatedDescription = item.description ? truncateToWidth(item.description.replace(/\s+/g, ' '), descriptionWidth) : '' + const lineContent = `${paddedDisplayText}${tagText}${truncatedDescription}` return ( - - - {paddedDisplayText} - - {tagText ? ( - - {tagText} - - ) : null} - - {truncatedDescription} - + + {lineContent} ) diff --git a/src/components/ThemePicker.test.tsx b/src/components/ThemePicker.test.tsx index 6e4acc1f..6981214c 100644 --- a/src/components/ThemePicker.test.tsx +++ b/src/components/ThemePicker.test.tsx @@ -1,48 +1,4 @@ -import { describe, expect, it, mock, beforeEach } from 'bun:test' -import { renderToString } from '../utils/staticRender.js' - -// Mock modules before importing ThemePicker -mock.module('../ink.js', () => ({ - useTheme: () => ['dark', () => {}], - useThemeSetting: () => 'dark', - usePreviewTheme: () => ({ - setPreviewTheme: mock(), - savePreview: mock(), - cancelPreview: mock(), - }), - useTerminalSize: () => ({ columns: 80, rows: 24 }), - Box: 'Box', - Text: 'Text', -})) - -mock.module('../hooks/useExitOnCtrlCDWithKeybindings.js', () => ({ - useExitOnCtrlCDWithKeybindings: () => ({ pending: false, keyName: 'Ctrl+C' }), -})) - -mock.module('../keybindings/KeybindingContext.js', () => ({ - useRegisterKeybindingContext: mock(), -})) - -mock.module('../keybindings/useKeybinding.js', () => ({ - useKeybinding: mock(), -})) - -mock.module('../keybindings/useShortcutDisplay.js', () => ({ - useShortcutDisplay: () => 'Ctrl+T', -})) - -mock.module('../state/AppState.js', () => ({ - useAppState: () => ({ settings: { syntaxHighlightingDisabled: false } }), - useSetAppState: () => mock(), -})) - -mock.module('../utils/gracefulShutdown.js', () => ({ - gracefulShutdown: mock(), -})) - -mock.module('../utils/settings/settings.js', () => ({ - updateSettingsForSource: mock(), -})) +import { describe, expect, it, mock } from 'bun:test' // We can't fully render ThemePicker due to complex dependencies // But we can test the theme options generation logic