Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat: update unit test

amlannandy2508e6f9f17c
diff --git a/frontend/src/pages/DashboardsListPage/__tests__/DashboardListPage.test.tsx b/frontend/src/pages/DashboardsListPage/__tests__/DashboardListPage.test.tsx
index 0fcdea102b..e8ab48f9c3 100644
--- a/frontend/src/pages/DashboardsListPage/__tests__/DashboardListPage.test.tsx
+++ b/frontend/src/pages/DashboardsListPage/__tests__/DashboardListPage.test.tsx
@@ -1,6 +1,7 @@
/* eslint-disable sonarjs/no-duplicate-string */
import ROUTES from 'constants/routes';
import DashboardsList from 'container/ListOfDashboard';
+import * as dashboardUtils from 'container/NewDashboard/DashboardDescription';
import {
dashboardEmptyState,
dashboardSuccessResponse,
@@ -11,6 +12,10 @@ import { DashboardProvider } from 'providers/Dashboard/Dashboard';
import { MemoryRouter, useLocation } from 'react-router-dom';
import { fireEvent, render, waitFor } from 'tests/test-utils';
+jest.mock('container/NewDashboard/DashboardDescription', () => ({
+ sanitizeDashboardData: jest.fn(),
+}));
+
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useLocation: jest.fn(),
@@ -208,7 +213,7 @@ describe('dashboard list page', () => {
);
});
- it('ensure that the popover actions on each list item renders list of options', async () => {
+ it('ensure that the popover action renders list of options and export JSON works correctly', async () => {
const { getByText, getAllByTestId } = render(
<MemoryRouter initialEntries={['/dashbords']}>
<DashboardProvider>
@@ -226,5 +231,8 @@ describe('dashboard list page', () => {
expect(getByText('View')).toBeInTheDocument();
expect(getByText('Copy Link')).toBeInTheDocument();
expect(getByText('Export JSON')).toBeInTheDocument();
+
+ fireEvent.click(getByText('Export JSON'));
+ expect(dashboardUtils.sanitizeDashboardData).toHaveBeenCalled();
});
});