-
Notifications
You must be signed in to change notification settings - Fork 596
/
PipelineRunDetailsPage.spec.tsx
81 lines (70 loc) · 3.15 KB
/
PipelineRunDetailsPage.spec.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { SemVer } from 'semver';
import { DetailsPage } from '@console/internal/components/factory';
import { referenceForModel } from '@console/internal/module/k8s';
import { PipelineRunModel } from '../../../models';
import { getPipelineRunKebabActions } from '../../../utils/pipeline-actions';
import * as hookUtils from '../../pipelines/hooks';
import * as taskRunUtils from '../../taskruns/useTaskRuns';
import TaskRuns from '../detail-page-tabs/TaskRuns';
import PipelineRunEvents from '../events/PipelineRunEvents';
import PipelineRunDetailsPage from '../PipelineRunDetailsPage';
import * as triggerHooksModule from '../triggered-by/hooks';
const menuActions = jest.spyOn(triggerHooksModule, 'useMenuActionsWithUserAnnotation');
const breadCrumbs = jest.spyOn(hookUtils, 'useDevPipelinesBreadcrumbsFor');
const taskRuns = jest.spyOn(taskRunUtils, 'useTaskRuns');
type PipelineRunDetailsPageProps = React.ComponentProps<typeof PipelineRunDetailsPage>;
const i18nNS = 'public';
const i18nPipelineNS = 'pipelines-plugin';
describe('PipelineRunDetailsPage:', () => {
let pipelineRunDetailsPageProps: PipelineRunDetailsPageProps;
let wrapper: ShallowWrapper<PipelineRunDetailsPageProps>;
beforeEach(() => {
pipelineRunDetailsPageProps = {
kind: PipelineRunModel.kind,
kindObj: PipelineRunModel,
match: {
isExact: true,
path: `/k8s/ns/:ns/${referenceForModel(PipelineRunModel)}/events`,
url: `k8s/ns/rhd-test/${referenceForModel(PipelineRunModel)}/events`,
params: {
ns: 'rhd-test',
},
},
};
menuActions.mockReturnValue([getPipelineRunKebabActions(new SemVer('1.9.0'), [], true)]);
breadCrumbs.mockReturnValue([{ label: 'PipelineRuns' }, { label: 'PipelineRuns Details' }]);
taskRuns.mockReturnValue([]);
wrapper = shallow(<PipelineRunDetailsPage {...pipelineRunDetailsPageProps} />);
});
it('Should render a DetailsPage component', () => {
expect(wrapper.find(DetailsPage).exists()).toBe(true);
});
it('Should contain five tabs in the details page', () => {
const { pages } = wrapper.props();
expect(pages).toHaveLength(6);
});
it('Should contain events page', () => {
const { pages } = wrapper.props();
const eventPage = pages.find((page) => page.nameKey === `${i18nNS}~Events`);
expect(eventPage).toBeDefined();
expect(eventPage.component).toBe(PipelineRunEvents);
});
it('Should contain task runs page', () => {
const { pages } = wrapper.props();
const taskRunsPage = pages.find((page) => page.nameKey.includes('TaskRuns'));
expect(taskRunsPage).toBeDefined();
expect(taskRunsPage.component).toBe(TaskRuns);
});
it('Should contain Parameters page', () => {
const { pages } = wrapper.props();
const parametersPage = pages.find((page) => page.nameKey === `${i18nPipelineNS}~Parameters`);
expect(parametersPage).toBeDefined();
});
it('Should contain Output tab', () => {
const { pages } = wrapper.props();
const outputPage = pages.find((page) => page.nameKey === `${i18nPipelineNS}~Output`);
expect(outputPage).toBeDefined();
});
});