Skip to content

Commit 7f4527d

Browse files
committed
Fix CommandPalette test for Spotlight rebuild
The Spotlight rewrite widened the palette to search projects, saved queries, visualizations, and dashboards — and updated the placeholder text accordingly. The test still expected the old 'Search projects...' placeholder and didn't mock the three new API modules, so the calls to getSavedQueries / getVisualizations / getDashboards triggered real network requests in jsdom. Updated the placeholder assertion to match the new copy (regex-based for robustness to typographic punctuation) and added vi.mock entries for the three additional API modules.
1 parent 2e705ac commit 7f4527d

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

exec/java-exec/src/main/resources/webapp/src/components/common/CommandPalette.test.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ vi.mock('../../api/projects', () => ({
2626
getProjects: vi.fn(() => Promise.resolve([])),
2727
}));
2828

29+
vi.mock('../../api/savedQueries', () => ({
30+
getSavedQueries: vi.fn(() => Promise.resolve([])),
31+
}));
32+
33+
vi.mock('../../api/visualizations', () => ({
34+
getVisualizations: vi.fn(() => Promise.resolve([])),
35+
}));
36+
37+
vi.mock('../../api/dashboards', () => ({
38+
getDashboards: vi.fn(() => Promise.resolve([])),
39+
}));
40+
2941
function createQueryClient() {
3042
return new QueryClient({
3143
defaultOptions: {
@@ -61,7 +73,9 @@ describe('CommandPalette', () => {
6173
fireEvent.keyDown(window, { key: 'k', ctrlKey: true });
6274

6375
await waitFor(() => {
64-
expect(screen.getByPlaceholderText('Search projects...')).toBeInTheDocument();
76+
expect(
77+
screen.getByPlaceholderText(/Search projects, queries, visualizations, dashboards/i)
78+
).toBeInTheDocument();
6579
});
6680
});
6781

@@ -72,7 +86,9 @@ describe('CommandPalette', () => {
7286
fireEvent.keyDown(window, { key: 'k', ctrlKey: true });
7387

7488
await waitFor(() => {
75-
expect(screen.getByPlaceholderText('Search projects...')).toBeInTheDocument();
89+
expect(
90+
screen.getByPlaceholderText(/Search projects, queries, visualizations, dashboards/i)
91+
).toBeInTheDocument();
7692
});
7793
});
7894
});

0 commit comments

Comments
 (0)