fix(ui): escaping theme dialog no longer resets theme to default (#11323)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
Pyush Sinha
2025-10-20 10:50:09 -07:00
committed by GitHub
parent d0ab6e9982
commit 397e52dac7
6 changed files with 51 additions and 14 deletions
@@ -12,6 +12,7 @@ import { KeypressProvider } from '../contexts/KeypressContext.js';
import { SettingsContext } from '../contexts/SettingsContext.js';
import { DEFAULT_THEME, themeManager } from '../themes/theme-manager.js';
import { act } from 'react';
import { waitFor } from '@testing-library/react';
const createMockSettings = (
userSettings = {},
@@ -58,6 +59,7 @@ const createMockSettings = (
describe('ThemeDialog Snapshots', () => {
const baseProps = {
onSelect: vi.fn(),
onCancel: vi.fn(),
onHighlight: vi.fn(),
availableTerminalHeight: 40,
terminalWidth: 120,
@@ -105,4 +107,28 @@ describe('ThemeDialog Snapshots', () => {
expect(lastFrame()).toMatchSnapshot();
});
it('should call onCancel when ESC is pressed', async () => {
const mockOnCancel = vi.fn();
const settings = createMockSettings();
const { stdin } = render(
<SettingsContext.Provider value={settings}>
<KeypressProvider kittyProtocolEnabled={false}>
<ThemeDialog
{...baseProps}
onCancel={mockOnCancel}
settings={settings}
/>
</KeypressProvider>
</SettingsContext.Provider>,
);
act(() => {
stdin.write('\x1b');
});
await waitFor(() => {
expect(mockOnCancel).toHaveBeenCalled();
});
});
});