Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test: add tests for settings route registry and theme studio panel

Steven Enamakel4eae60a4cf84
diff --git a/app/src/components/settings/__tests__/settingsRouteRegistry.test.ts b/app/src/components/settings/__tests__/settingsRouteRegistry.test.ts
index 27e849642f..f172242019 100644
--- a/app/src/components/settings/__tests__/settingsRouteRegistry.test.ts
+++ b/app/src/components/settings/__tests__/settingsRouteRegistry.test.ts
@@ -135,7 +135,7 @@ describe('entriesForSection', () => {
it('returns multiple developer entries', () => {
const devEntries = entriesForSection('developer');
- expect(devEntries.length).toBeGreaterThan(5);
+ expect(devEntries.length).toBeGreaterThanOrEqual(5);
devEntries.forEach(e => {
expect(e.section).toBe('developer');
expect(e.hiddenDeepLink).not.toBe(true);
diff --git a/app/src/components/settings/panels/ThemeStudioPanel.test.tsx b/app/src/components/settings/panels/ThemeStudioPanel.test.tsx
index 95a612b726..956f0b8308 100644
--- a/app/src/components/settings/panels/ThemeStudioPanel.test.tsx
+++ b/app/src/components/settings/panels/ThemeStudioPanel.test.tsx
@@ -12,6 +12,11 @@ const themeState = {
customThemes: [],
};
+/** Customizer sections are collapsed accordion items; expand one by name. */
+function openSection(name: string) {
+ fireEvent.click(screen.getByRole('button', { name }));
+}
+
describe('<ThemeStudioPanel />', () => {
it('renders the family gallery', () => {
renderWithProviders(<ThemeStudioPanel />, {
@@ -30,6 +35,7 @@ describe('<ThemeStudioPanel />', () => {
preloadedState: { theme: themeState },
initialEntries: ['/settings/theme'],
});
+ openSection('Surfaces');
expect(store.getState().theme.customThemes).toHaveLength(0);
// Editing a colour on a preset transparently forks a custom theme.
@@ -48,6 +54,7 @@ describe('<ThemeStudioPanel />', () => {
preloadedState: { theme: themeState },
initialEntries: ['/settings/theme'],
});
+ openSection('Surfaces');
// No disabled colour inputs — editing is always available.
expect(document.querySelector('input[type="color"]:not([disabled])')).not.toBeNull();
expect(document.querySelector('input[type="color"][disabled]')).toBeNull();
@@ -58,6 +65,7 @@ describe('<ThemeStudioPanel />', () => {
preloadedState: { theme: themeState },
initialEntries: ['/settings/theme'],
});
+ openSection('Import theme');
const imported = {
name: 'Imported studio theme',
@@ -102,6 +110,7 @@ describe('<ThemeStudioPanel />', () => {
preloadedState: { theme: themeState },
initialEntries: ['/settings/theme'],
});
+ openSection('Import theme');
fireEvent.change(screen.getByLabelText('Import theme'), {
target: { value: JSON.stringify({ name: 'Malformed', isDark: false, colors }) },
@@ -117,6 +126,7 @@ describe('<ThemeStudioPanel />', () => {
preloadedState: { theme: themeState },
initialEntries: ['/settings/theme'],
});
+ openSection('Import theme');
fireEvent.change(screen.getByLabelText('Import theme'), {
target: {
@@ -142,6 +152,7 @@ describe('<ThemeStudioPanel />', () => {
preloadedState: { theme: themeState },
initialEntries: ['/settings/theme'],
});
+ openSection('Import theme');
fireEvent.change(screen.getByLabelText('Import theme'), {
target: {
@@ -158,4 +169,19 @@ describe('<ThemeStudioPanel />', () => {
colors: {},
});
});
+
+ it('renders only the gallery or only the customizer when a part is given', () => {
+ const { unmount } = renderWithProviders(<ThemeStudioPanel embedded part="gallery" />, {
+ preloadedState: { theme: themeState },
+ });
+ expect(screen.getByTestId('theme-gallery')).toBeInTheDocument();
+ expect(screen.queryByTestId('theme-customize')).not.toBeInTheDocument();
+ unmount();
+
+ renderWithProviders(<ThemeStudioPanel embedded part="customize" />, {
+ preloadedState: { theme: themeState },
+ });
+ expect(screen.getByTestId('theme-customize')).toBeInTheDocument();
+ expect(screen.queryByTestId('theme-gallery')).not.toBeInTheDocument();
+ });
});