@@ -13,7 +13,7 @@ import { WorkflowDetailRouterProps } from '../../pages';
13
13
import '@testing-library/jest-dom' ;
14
14
import { mockStore , resizeObserverMock } from '../../../test/utils' ;
15
15
import { createMemoryHistory } from 'history' ;
16
- import { WORKFLOW_TYPE } from '../../../common' ;
16
+ import { MINIMUM_FULL_SUPPORTED_VERSION , WORKFLOW_TYPE } from '../../../common' ;
17
17
18
18
jest . mock ( '../../services' , ( ) => {
19
19
const { mockCoreServices } = require ( '../../../test' ) ;
@@ -39,15 +39,22 @@ const renderWithRouter = (
39
39
initialEntries : [ `/workflow/${ workflowId } ` ] ,
40
40
} ) ;
41
41
42
+ const mockInput = {
43
+ id : workflowId ,
44
+ name : workflowName ,
45
+ type : workflowType ,
46
+ version : [
47
+ WORKFLOW_TYPE . SEMANTIC_SEARCH ,
48
+ WORKFLOW_TYPE . MULTIMODAL_SEARCH ,
49
+ WORKFLOW_TYPE . HYBRID_SEARCH ,
50
+ ] . includes ( workflowType )
51
+ ? MINIMUM_FULL_SUPPORTED_VERSION
52
+ : undefined ,
53
+ } ;
54
+
42
55
return {
43
56
...render (
44
- < Provider
45
- store = { mockStore ( {
46
- id : workflowId ,
47
- name : workflowName ,
48
- type : workflowType ,
49
- } ) }
50
- >
57
+ < Provider store = { mockStore ( mockInput ) } >
51
58
< Router history = { history } >
52
59
< Switch >
53
60
< Route
@@ -68,6 +75,7 @@ describe('WorkflowDetail Page with create ingestion option', () => {
68
75
beforeEach ( ( ) => {
69
76
jest . clearAllMocks ( ) ;
70
77
} ) ;
78
+
71
79
Object . values ( WORKFLOW_TYPE ) . forEach ( ( type ) => {
72
80
test ( `renders the WorkflowDetail page with ${ type } type` , async ( ) => {
73
81
const {
@@ -110,33 +118,27 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
110
118
workflowName ,
111
119
WORKFLOW_TYPE . CUSTOM
112
120
) ;
113
-
114
121
// Export button opens the export component
115
122
userEvent . click ( getByTestId ( 'exportButton' ) ) ;
116
123
await waitFor ( ( ) => {
117
124
expect ( getByText ( `Export '${ workflowName } '` ) ) . toBeInTheDocument ( ) ;
118
125
} ) ;
119
-
120
126
// Close the export component
121
127
userEvent . click ( getByTestId ( 'exportCloseButton' ) ) ;
122
-
123
128
// Check workspace button group exists (Visual and JSON)
124
129
getByTestId ( 'visualJSONToggleButtonGroup' ) ;
125
-
126
- // Tools panel should collapse and expand on toggle
130
+ // Tools panel should collapse and expand the toggle
127
131
const toolsPanel = container . querySelector ( '#tools_panel_id' ) ;
128
132
expect ( toolsPanel ) . toBeVisible ( ) ;
129
133
130
134
const toggleButton = toolsPanel ?. querySelector ( 'button[type="button"]' ) ;
131
135
expect ( toggleButton ) . toBeInTheDocument ( ) ;
132
136
userEvent . click ( toggleButton ! ) ;
133
-
134
137
// Tools panel after collapsing
135
138
const collapsedToolsPanel = container . querySelector ( '#tools_panel_id' ) ;
136
139
await waitFor ( ( ) => {
137
140
expect ( collapsedToolsPanel ) . toHaveClass ( 'euiResizablePanel-isCollapsed' ) ;
138
141
} ) ;
139
-
140
142
// Tools panel after expanding
141
143
userEvent . click ( toggleButton ! ) ;
142
144
const expandedToolsPanel = container . querySelector ( '#tools_panel_id' ) ;
@@ -153,7 +155,6 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
153
155
workflowName ,
154
156
WORKFLOW_TYPE . CUSTOM
155
157
) ;
156
-
157
158
// The WorkflowDetail Page Close button should navigate back to the workflows list
158
159
userEvent . click ( getByTestId ( 'closeButton' ) ) ;
159
160
await waitFor ( ( ) => {
@@ -166,57 +167,57 @@ describe('WorkflowDetail Page with skip ingestion option (Hybrid Search Workflow
166
167
beforeEach ( ( ) => {
167
168
jest . clearAllMocks ( ) ;
168
169
} ) ;
170
+
169
171
test ( `renders the WorkflowDetail page with skip ingestion option` , async ( ) => {
170
172
const { getByTestId, getAllByText, getAllByTestId } = renderWithRouter (
171
173
workflowId ,
172
174
workflowName ,
173
175
WORKFLOW_TYPE . HYBRID_SEARCH
174
176
) ;
175
-
176
177
// Defining a new ingest pipeline & index is enabled by default
177
178
const enabledCheckbox = getByTestId ( 'switch-ingest.enabled' ) ;
178
-
179
179
// Skipping ingest pipeline and navigating to search
180
180
userEvent . click ( enabledCheckbox ) ;
181
181
await waitFor ( ( ) => { } ) ;
182
+
182
183
const searchPipelineButton = getByTestId ( 'searchPipelineButton' ) ;
183
184
userEvent . click ( searchPipelineButton ) ;
184
-
185
185
// Search pipeline
186
186
await waitFor ( ( ) => {
187
187
expect ( getAllByText ( 'Define search flow' ) . length ) . toBeGreaterThan ( 0 ) ;
188
188
} ) ;
189
189
expect ( getAllByText ( 'Configure query' ) . length ) . toBeGreaterThan ( 0 ) ;
190
-
191
190
// Edit Search Query
192
191
const queryEditButton = getByTestId ( 'queryEditButton' ) ;
193
192
expect ( queryEditButton ) . toBeInTheDocument ( ) ;
194
193
userEvent . click ( queryEditButton ) ;
194
+
195
195
await waitFor ( ( ) => {
196
196
expect ( getAllByText ( 'Edit query definition' ) . length ) . toBeGreaterThan ( 0 ) ;
197
197
} ) ;
198
+
198
199
const searchQueryPresetButton = getByTestId ( 'searchQueryPresetButton' ) ;
199
200
expect ( searchQueryPresetButton ) . toBeInTheDocument ( ) ;
200
201
const updateSearchQueryButton = getByTestId ( 'updateSearchQueryButton' ) ;
201
202
expect ( updateSearchQueryButton ) . toBeInTheDocument ( ) ;
202
203
userEvent . click ( updateSearchQueryButton ) ;
203
-
204
204
// Add request processor
205
205
const addRequestProcessorButton = await waitFor (
206
206
( ) => getAllByTestId ( 'addProcessorButton' ) [ 0 ]
207
207
) ;
208
208
userEvent . click ( addRequestProcessorButton ) ;
209
+
209
210
await waitFor ( ( ) => {
210
- expect ( getAllByText ( 'PROCESSORS' ) . length ) . toBeGreaterThan ( 0 ) ;
211
+ const popoverPanel = document . querySelector ( '.euiPopover__panel' ) ;
212
+ expect ( popoverPanel ) . toBeTruthy ( ) ;
211
213
} ) ;
212
-
213
214
// Add response processor
214
215
const addResponseProcessorButton = getAllByTestId ( 'addProcessorButton' ) [ 1 ] ;
215
216
userEvent . click ( addResponseProcessorButton ) ;
216
217
await waitFor ( ( ) => {
217
- expect ( getAllByText ( 'PROCESSORS' ) . length ) . toBeGreaterThan ( 0 ) ;
218
+ const popoverPanel = document . querySelector ( '.euiPopover__panel' ) ;
219
+ expect ( popoverPanel ) . toBeTruthy ( ) ;
218
220
} ) ;
219
-
220
221
// Build and Run query, Back buttons are present
221
222
const searchPipelineBackButton = getByTestId ( 'searchPipelineBackButton' ) ;
222
223
userEvent . click ( searchPipelineBackButton ) ;
0 commit comments