Skip to content

Commit 75cbfa9

Browse files
authored
[Presentation] Fix slow FilterItems tests (#238401)
## Summary Fixes #237143 Fixes #235143 Summarize your PR. If it involves visual changes include a screenshot or gif. Fixes slow tests in dashboard and presentation panel components by mocking the `FilterItems` component from `@kbn/unified-search-plugin/public`. ## Problem Two test we causing timeouts on CI. Locally, they were getting these results: - `customize_panel_editor.test.tsx`: "renders local filters, if provided" test took **367ms** - `filters_notification_popover.test.tsx`: "renders the filter section when given filters" test took **962ms** The root cause was that `FilterItems` is a complex component with lazy-loaded dependencies that caused: - Expensive rendering operations - React Suspense delays - Unnecessary overhead for tests that only verify component structure ## Solution Added a mock for `FilterItems` in both test files to replace the heavy component with a simple mock implementation. This avoids loading the entire unified search plugin infrastructure during tests. ## Performance Improvements - **customize_panel_editor.test.tsx**: 367ms → 10ms (97% faster) - **filters_notification_popover.test.tsx**: 962ms → 68ms (93% faster)
1 parent df167c7 commit 75cbfa9

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/platform/plugins/private/presentation_panel/public/panel_actions/customize_panel_action/customize_panel_editor.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import { BehaviorSubject } from 'rxjs';
1818
import type { CustomizePanelActionApi } from './customize_panel_action';
1919
import { CustomizePanelEditor } from './customize_panel_editor';
2020

21+
// Mock FilterItems to avoid expensive rendering and lazy-loading delays in tests
22+
jest.mock('@kbn/unified-search-plugin/public', () => ({
23+
FilterItems: () => <div data-test-subj="mocked-filter-items">Mocked FilterItems</div>,
24+
}));
25+
2126
describe('customize panel editor', () => {
2227
let api: CustomizePanelActionApi;
2328
let setTitle: (title?: string) => void;

src/platform/plugins/shared/dashboard/public/dashboard_actions/filters_notification_popover.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ import type { FiltersNotificationActionApi } from './filters_notification_action
1919
import { FiltersNotificationPopover } from './filters_notification_popover';
2020
import type { ViewMode } from '@kbn/presentation-publishing';
2121

22+
// Mock FilterItems to avoid expensive rendering and lazy-loading delays in tests
23+
jest.mock('@kbn/unified-search-plugin/public', () => ({
24+
FilterItems: () => <div data-test-subj="mocked-filter-items">Mocked FilterItems</div>,
25+
}));
26+
2227
const canEditUnifiedSearch = jest.fn().mockReturnValue(true);
2328

2429
const getMockPhraseFilter = (key: string, value: string): Filter => {

0 commit comments

Comments
 (0)