mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-04 11:25:52 +08:00

* fix: fix pipeline add and edit form flow * test: update test cases --------- Co-authored-by: Aditya Singh <adityasingh@Adityas-MacBook-Pro.local> Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
66 lines
1.5 KiB
TypeScript
66 lines
1.5 KiB
TypeScript
import { Form } from 'antd';
|
|
import { render } from 'tests/test-utils';
|
|
import { PipelineData } from 'types/api/pipeline/def';
|
|
|
|
import { pipelineMockData } from '../mocks/pipeline';
|
|
import AddNewPipeline from '../PipelineListsView/AddNewPipeline';
|
|
|
|
jest.mock('uplot', () => {
|
|
const paths = {
|
|
spline: jest.fn(),
|
|
bars: jest.fn(),
|
|
};
|
|
const uplotMock = jest.fn(() => ({
|
|
paths,
|
|
}));
|
|
return {
|
|
paths,
|
|
default: uplotMock,
|
|
};
|
|
});
|
|
|
|
export function matchMedia(): void {
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: jest.fn().mockImplementation((query) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
addEventListener: jest.fn(),
|
|
removeEventListener: jest.fn(),
|
|
dispatchEvent: jest.fn(),
|
|
})),
|
|
});
|
|
}
|
|
beforeAll(() => {
|
|
matchMedia();
|
|
});
|
|
|
|
function AddNewPipelineWrapper(): JSX.Element {
|
|
const setActionType = jest.fn();
|
|
const selectedPipelineData = pipelineMockData[0];
|
|
const isActionType = 'add-pipeline';
|
|
const [pipelineForm] = Form.useForm<PipelineData>();
|
|
|
|
return (
|
|
<AddNewPipeline
|
|
isActionType={isActionType}
|
|
setActionType={setActionType}
|
|
selectedPipelineData={selectedPipelineData}
|
|
setShowSaveButton={jest.fn()}
|
|
setCurrPipelineData={jest.fn()}
|
|
currPipelineData={pipelineMockData}
|
|
form={pipelineForm}
|
|
/>
|
|
);
|
|
}
|
|
|
|
describe('PipelinePage container test', () => {
|
|
it('should render AddNewPipeline section', () => {
|
|
const { asFragment } = render(<AddNewPipelineWrapper />);
|
|
expect(asFragment()).toMatchSnapshot();
|
|
});
|
|
});
|