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.

2.7 KB
Raw Blame
import { I18nextProvider } from 'react-i18next';
import { QueryClient, QueryClientProvider } from 'react-query';
// eslint-disable-next-line no-restricted-imports
import { Provider } from 'react-redux';
import { render } from '@testing-library/react';
import TimezoneProvider from 'providers/Timezone';
import i18n from 'ReactI18';
import store from 'store';
import { TestRouter } from 'tests/router';

import ChangeHistory from '../index';
import { pipelineData, pipelineDataHistory } from './testUtils';

const queryClient = new QueryClient({
	defaultOptions: {
		queries: {
			refetchOnWindowFocus: false,
		},
	},
});

describe('ChangeHistory test', () => {
	it('should render changeHistory correctly', () => {
		const { getAllByText, getByText } = render(
			<TestRouter>
				<QueryClientProvider client={queryClient}>
					<Provider store={store}>
						<I18nextProvider i18n={i18n}>
							<TimezoneProvider>
								<ChangeHistory pipelineData={pipelineData} />
							</TimezoneProvider>
						</I18nextProvider>
					</Provider>
				</QueryClientProvider>
			</TestRouter>,
		);

		// change History table headers
		[
			'Version',
			'Deployment Stage',
			'Last Deploy Message',
			'Last Deployed Time',
			'Edited by',
		].forEach((text) => expect(getByText(text)).toBeInTheDocument());

		// table content
		expect(getAllByText('test-user')).toHaveLength(2);
		expect(getAllByText('Deployment was successful')).toHaveLength(2);
	});

	it('test deployment stage and icon based on history data', () => {
		const { getByText, container } = render(
			<TestRouter>
				<QueryClientProvider client={queryClient}>
					<Provider store={store}>
						<I18nextProvider i18n={i18n}>
							<TimezoneProvider>
								<ChangeHistory
									pipelineData={{
										...pipelineData,
										history: pipelineDataHistory,
									}}
								/>
							</TimezoneProvider>
						</I18nextProvider>
					</Provider>
				</QueryClientProvider>
			</TestRouter>,
		);

		// assertion for different deployment stages
		expect(
			container.querySelector('[data-testid="deployment-icon-in-progress"]'),
		).toBeInTheDocument();
		expect(getByText('In Progress')).toBeInTheDocument();

		expect(
			container.querySelector('[data-testid="deployment-icon-dirty"]'),
		).toBeInTheDocument();
		expect(getByText('Dirty')).toBeInTheDocument();

		expect(
			container.querySelector('[data-testid="deployment-icon-failed"]'),
		).toBeInTheDocument();
		expect(getByText('Failed')).toBeInTheDocument();

		expect(
			container.querySelector('[data-testid="deployment-icon-unknown"]'),
		).toBeInTheDocument();
		expect(getByText('Unknown')).toBeInTheDocument();

		expect(container.querySelectorAll('.ant-table-row')).toHaveLength(5);
	});
});