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.

1.6 KB
Raw Blame
import { PanelMode } from 'lib/visualization/panels/types';
import { render } from 'tests/test-utils';
import { Widgets } from 'types/api/widgets/widget';

import ValuePanelWrapper from 'container/WidgetCard/Panels/ValuePanelWrapper';
import {
	thresholds,
	valuePanelQueryResponse,
	valuePanelWidget,
} from 'container/WidgetCard/Panels/__tests__/valuePanelWrapperHelper';

window.ResizeObserver =
	window.ResizeObserver ||
	jest.fn().mockImplementation(() => ({
		disconnect: jest.fn(),
		observe: jest.fn(),
		unobserve: jest.fn(),
	}));

describe('Value panel wrappper tests', () => {
	it('should render value panel correctly with yaxis unit', () => {
		const { getByText } = render(
			<ValuePanelWrapper
				panelMode={PanelMode.DASHBOARD_VIEW}
				widget={valuePanelWidget as unknown as Widgets}
				queryResponse={valuePanelQueryResponse as unknown as any}
				onDragSelect={(): void => {}}
			/>,
		);

		// selected y axis unit as miliseconds (ms)
		expect(getByText('295.43')).toBeInTheDocument();
		expect(getByText('ms')).toBeInTheDocument();
	});

	it('should render tooltip when there are conflicting thresholds', () => {
		const { getByTestId, container } = render(
			<ValuePanelWrapper
				panelMode={PanelMode.DASHBOARD_VIEW}
				widget={{ ...valuePanelWidget, thresholds } as unknown as Widgets}
				queryResponse={valuePanelQueryResponse as unknown as any}
				onDragSelect={(): void => {}}
			/>,
		);

		expect(getByTestId('conflicting-thresholds')).toBeInTheDocument();
		// added snapshot test here for checking the thresholds color being applied properly
		expect(container).toMatchSnapshot();
	});
});