feat(themes): add built-in holiday theme 🎁 (#14301)

Co-authored-by: jacob314 <jacob314@gmail.com>
This commit is contained in:
Jack Wotherspoon
2025-12-01 14:09:55 -05:00
committed by GitHub
parent 62f890b5aa
commit bde8b78a88
5 changed files with 244 additions and 58 deletions
@@ -4,13 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
import { render } from '../../test-utils/render.js';
import { renderWithProviders } from '../../test-utils/render.js';
import { waitFor } from '../../test-utils/async.js';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { ThemeDialog } from './ThemeDialog.js';
import { LoadedSettings } from '../../config/settings.js';
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';
@@ -76,12 +74,9 @@ describe('ThemeDialog Snapshots', () => {
it('should render correctly in theme selection mode', () => {
const settings = createMockSettings();
const { lastFrame } = render(
<SettingsContext.Provider value={settings}>
<KeypressProvider>
<ThemeDialog {...baseProps} settings={settings} />
</KeypressProvider>
</SettingsContext.Provider>,
const { lastFrame } = renderWithProviders(
<ThemeDialog {...baseProps} settings={settings} />,
{ settings },
);
expect(lastFrame()).toMatchSnapshot();
@@ -89,12 +84,9 @@ describe('ThemeDialog Snapshots', () => {
it('should render correctly in scope selector mode', async () => {
const settings = createMockSettings();
const { lastFrame, stdin } = render(
<SettingsContext.Provider value={settings}>
<KeypressProvider>
<ThemeDialog {...baseProps} settings={settings} />
</KeypressProvider>
</SettingsContext.Provider>,
const { lastFrame, stdin } = renderWithProviders(
<ThemeDialog {...baseProps} settings={settings} />,
{ settings },
);
// Press Tab to switch to scope selector mode
@@ -111,16 +103,13 @@ describe('ThemeDialog Snapshots', () => {
it('should call onCancel when ESC is pressed', async () => {
const mockOnCancel = vi.fn();
const settings = createMockSettings();
const { stdin } = render(
<SettingsContext.Provider value={settings}>
<KeypressProvider>
<ThemeDialog
{...baseProps}
onCancel={mockOnCancel}
settings={settings}
/>
</KeypressProvider>
</SettingsContext.Provider>,
const { stdin } = renderWithProviders(
<ThemeDialog
{...baseProps}
onCancel={mockOnCancel}
settings={settings}
/>,
{ settings },
);
act(() => {
@@ -131,4 +120,26 @@ describe('ThemeDialog Snapshots', () => {
expect(mockOnCancel).toHaveBeenCalled();
});
});
it('should call refreshStatic when a theme is selected', async () => {
const mockRefreshStatic = vi.fn();
const settings = createMockSettings();
const { stdin } = renderWithProviders(
<ThemeDialog {...baseProps} settings={settings} />,
{
settings,
uiActions: { refreshStatic: mockRefreshStatic },
},
);
// Press Enter to select the theme
act(() => {
stdin.write('\r');
});
await waitFor(() => {
expect(mockRefreshStatic).toHaveBeenCalled();
expect(baseProps.onSelect).toHaveBeenCalled();
});
});
});