forked from opensearch-project/dashboards-flow-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflow_detail.test.tsx
93 lines (85 loc) · 3.01 KB
/
workflow_detail.test.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
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import {
RouteComponentProps,
Route,
Switch,
Router,
Redirect,
} from 'react-router-dom';
import { WorkflowDetail } from './workflow_detail';
import { WorkflowDetailRouterProps } from '../../pages';
import '@testing-library/jest-dom';
import { mockStore, resizeObserverMock } from '../../../test/utils';
import { createMemoryHistory } from 'history';
import { WORKFLOW_TYPE } from '../../../common';
jest.mock('../../services', () => {
const { mockCoreServices } = require('../../../test');
return {
...jest.requireActual('../../services'),
...mockCoreServices,
};
});
const workflowId = '12345';
const workflowName = 'test_workflow';
const history = createMemoryHistory({
initialEntries: [`/workflow/${workflowId}`],
});
window.ResizeObserver = resizeObserverMock;
const renderWithRouter = (
workflowId: string,
workflowName: string,
workflowType: WORKFLOW_TYPE
) => ({
...render(
<Provider store={mockStore(workflowId, workflowName, workflowType)}>
<Router history={history}>
<Switch>
<Route
path="/workflow/:workflowId"
render={(props: RouteComponentProps<WorkflowDetailRouterProps>) => {
return <WorkflowDetail setActionMenu={jest.fn()} {...props} />;
}}
/>
</Switch>
</Router>
</Provider>
),
});
describe('WorkflowDetail', () => {
Object.values(WORKFLOW_TYPE).forEach((type) => {
test(`renders the page with ${type} type`, () => {
const { getAllByText, getByText, getByRole } = renderWithRouter(
workflowId,
workflowName,
type
);
expect(getAllByText(workflowName).length).toBeGreaterThan(0);
expect(getAllByText('Create an ingest pipeline').length).toBeGreaterThan(
0
);
expect(getAllByText('Skip ingestion pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Define ingest pipeline').length).toBeGreaterThan(0);
expect(getAllByText('Tools').length).toBeGreaterThan(0);
expect(getAllByText('Preview').length).toBeGreaterThan(0);
expect(getAllByText('Not started').length).toBeGreaterThan(0);
expect(
getAllByText((content) => content.startsWith('Last updated:')).length
).toBeGreaterThan(0);
expect(getAllByText('Search pipeline').length).toBeGreaterThan(0);
expect(getByText('Close')).toBeInTheDocument();
expect(getByText('Export')).toBeInTheDocument();
expect(getByText('Visual')).toBeInTheDocument();
expect(getByText('JSON')).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run ingestion' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Run queries' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Errors' })).toBeInTheDocument();
expect(getByRole('tab', { name: 'Resources' })).toBeInTheDocument();
});
});
});