From 0a071689d8f2c2d17180dfd9f12a804dbacca6cc Mon Sep 17 00:00:00 2001 From: ivanahuckova Date: Mon, 13 Oct 2025 18:32:52 +0200 Subject: [PATCH] Improve mocks --- .../ExtensionSidebarProvider.test.tsx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionSidebarProvider.test.tsx b/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionSidebarProvider.test.tsx index 7d0e58dac4a..da218b19ae5 100644 --- a/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionSidebarProvider.test.tsx +++ b/public/app/core/components/AppChrome/ExtensionSidebar/ExtensionSidebarProvider.test.tsx @@ -396,6 +396,17 @@ describe('ExtensionSidebarProvider', () => { }); it('should toggle sidebar closed when receiving ToggleExtensionSidebarEvent for currently open component', async () => { + // Mock usePluginLinks to return a link that matches our test component + jest.requireMock('@grafana/runtime').usePluginLinks.mockImplementation(() => ({ + links: [ + { + pluginId: mockPluginMeta.pluginId, + title: mockComponent.title, + }, + ], + isLoading: false, + })); + const componentId = getComponentIdFromComponentMeta(mockPluginMeta.pluginId, mockComponent); const TestComponentWithProps = () => { @@ -446,6 +457,21 @@ describe('ExtensionSidebarProvider', () => { }); it('should toggle to different component when receiving ToggleExtensionSidebarEvent for different component', async () => { + // Mock usePluginLinks to return links that match both test components + jest.requireMock('@grafana/runtime').usePluginLinks.mockImplementation(() => ({ + links: [ + { + pluginId: mockPluginMeta.pluginId, + title: mockComponent.title, + }, + { + pluginId: mockPluginMeta.pluginId, + title: mockDifferentComponent.title, + }, + ], + isLoading: false, + })); + const componentId = getComponentIdFromComponentMeta(mockPluginMeta.pluginId, mockComponent); const TestComponentWithProps = () => {