@@ -74,7 +74,6 @@ describe('WorkflowDetail Page with create ingestion option', () => {
74
74
getAllByText,
75
75
getByText,
76
76
getByRole,
77
- container,
78
77
getByTestId,
79
78
} = renderWithRouter ( workflowId , workflowName , type ) ;
80
79
@@ -109,14 +108,6 @@ describe('WorkflowDetail Page with create ingestion option', () => {
109
108
const searchPipelineButton = getByTestId ( 'searchPipelineButton' ) ;
110
109
expect ( searchPipelineButton ) . toBeInTheDocument ( ) ;
111
110
expect ( searchPipelineButton ) . toBeDisabled ( ) ;
112
-
113
- // "Create an ingest pipeline" option should be selected by default
114
- const createIngestRadio = container . querySelector ( '#create' ) ;
115
- expect ( createIngestRadio ) . toBeChecked ( ) ;
116
-
117
- // "Skip ingestion pipeline" option should be unselected by default
118
- const skipIngestRadio = container . querySelector ( '#skip' ) ;
119
- expect ( skipIngestRadio ) . not . toBeChecked ( ) ;
120
111
} ) ;
121
112
} ) ;
122
113
} ) ;
@@ -133,37 +124,49 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
133
124
) ;
134
125
135
126
// Export button opens the export component
136
- await waitFor ( ( ) => userEvent . click ( getByTestId ( 'exportButton' ) ) ) ;
137
- expect ( getByText ( `Export ${ workflowName } ` ) ) . toBeInTheDocument ( ) ;
127
+ userEvent . click ( getByTestId ( 'exportButton' ) ) ;
128
+ await waitFor ( ( ) => {
129
+ expect ( getByText ( `Export ${ workflowName } ` ) ) . toBeInTheDocument ( ) ;
130
+ } ) ;
138
131
139
132
// Close the export component
140
- await waitFor ( ( ) => userEvent . click ( getByTestId ( 'exportCloseButton' ) ) ) ;
133
+ userEvent . click ( getByTestId ( 'exportCloseButton' ) ) ;
141
134
142
135
// Check workspace buttons (Visual and JSON)
143
136
const visualButton = getByTestId ( 'workspaceVisualButton' ) ;
144
- expect ( visualButton ) . toBeVisible ( ) ;
137
+ await waitFor ( ( ) => {
138
+ expect ( visualButton ) . toBeVisible ( ) ;
139
+ } ) ;
145
140
expect ( visualButton ) . toHaveClass ( 'euiFilterButton-hasActiveFilters' ) ;
146
141
const jsonButton = getByTestId ( 'workspaceJSONButton' ) ;
147
142
expect ( jsonButton ) . toBeVisible ( ) ;
148
- await waitFor ( ( ) => userEvent . click ( jsonButton ) ) ;
149
- expect ( jsonButton ) . toHaveClass ( 'euiFilterButton-hasActiveFilters' ) ;
143
+ userEvent . click ( jsonButton ) ;
144
+ await waitFor ( ( ) => {
145
+ expect ( jsonButton ) . toHaveClass ( 'euiFilterButton-hasActiveFilters' ) ;
146
+ } ) ;
150
147
151
148
// Tools panel should collapse and expand on toggle
152
149
const toolsPanel = container . querySelector ( '#tools_panel_id' ) ;
153
150
expect ( toolsPanel ) . toBeVisible ( ) ;
154
151
155
152
const toggleButton = toolsPanel ?. querySelector ( 'button[type="button"]' ) ;
156
153
expect ( toggleButton ) . toBeInTheDocument ( ) ;
157
- await waitFor ( ( ) => userEvent . click ( toggleButton ! ) ) ;
154
+ userEvent . click ( toggleButton ! ) ;
158
155
159
156
// Tools panel after collapsing
160
157
const collapsedToolsPanel = container . querySelector ( '#tools_panel_id' ) ;
161
- expect ( collapsedToolsPanel ) . toHaveClass ( 'euiResizablePanel-isCollapsed' ) ;
158
+ await waitFor ( ( ) => {
159
+ expect ( collapsedToolsPanel ) . toHaveClass ( 'euiResizablePanel-isCollapsed' ) ;
160
+ } ) ;
162
161
163
162
// Tools panel after expanding
164
- await waitFor ( ( ) => userEvent . click ( toggleButton ! ) ) ;
163
+ userEvent . click ( toggleButton ! ) ;
165
164
const expandedToolsPanel = container . querySelector ( '#tools_panel_id' ) ;
166
- expect ( expandedToolsPanel ) . not . toHaveClass ( 'euiResizablePanel-isCollapsed' ) ;
165
+ await waitFor ( ( ) => {
166
+ expect ( expandedToolsPanel ) . not . toHaveClass (
167
+ 'euiResizablePanel-isCollapsed'
168
+ ) ;
169
+ } ) ;
167
170
} ) ;
168
171
169
172
test ( 'tests navigation to workflows list on Close button click' , async ( ) => {
@@ -174,7 +177,87 @@ describe('WorkflowDetail Page Functionality (Custom Workflow)', () => {
174
177
) ;
175
178
176
179
// The WorkflowDetail Page Close button should navigate back to the workflows list
177
- await waitFor ( ( ) => userEvent . click ( getByTestId ( 'closeButton' ) ) ) ;
178
- expect ( history . location . pathname ) . toBe ( '/workflows' ) ;
180
+ userEvent . click ( getByTestId ( 'closeButton' ) ) ;
181
+ await waitFor ( ( ) => {
182
+ expect ( history . location . pathname ) . toBe ( '/workflows' ) ;
183
+ } ) ;
184
+ } ) ;
185
+ } ) ;
186
+
187
+ describe ( 'WorkflowDetail Page with skip ingestion option (Hybrid Search Workflow)' , ( ) => {
188
+ beforeEach ( ( ) => {
189
+ jest . clearAllMocks ( ) ;
190
+ } ) ;
191
+ test ( `renders the WorkflowDetail page with skip ingestion option` , async ( ) => {
192
+ const {
193
+ container,
194
+ getByTestId,
195
+ getAllByText,
196
+ getAllByTestId,
197
+ } = renderWithRouter ( workflowId , workflowName , WORKFLOW_TYPE . HYBRID_SEARCH ) ;
198
+
199
+ // "Create an ingest pipeline" option should be selected by default
200
+ const createIngestRadio = container . querySelector ( '#create' ) ;
201
+ expect ( createIngestRadio ) . toBeChecked ( ) ;
202
+
203
+ // "Skip ingestion pipeline" option should be unselected by default
204
+ const skipIngestRadio = container . querySelector ( '#skip' ) ;
205
+ expect ( skipIngestRadio ) . not . toBeChecked ( ) ;
206
+
207
+ // Selected "Skip ingestion pipeline"
208
+ userEvent . click ( skipIngestRadio ! ) ;
209
+ await waitFor ( ( ) => {
210
+ expect ( createIngestRadio ) . not . toBeChecked ( ) ;
211
+ } ) ;
212
+ expect ( skipIngestRadio ) . toBeChecked ( ) ;
213
+ const searchPipelineButton = getByTestId ( 'searchPipelineButton' ) ;
214
+ userEvent . click ( searchPipelineButton ) ;
215
+
216
+ // Search pipeline
217
+ await waitFor ( ( ) => {
218
+ expect ( getAllByText ( 'Define search pipeline' ) . length ) . toBeGreaterThan ( 0 ) ;
219
+ } ) ;
220
+ expect ( getAllByText ( 'Configure query' ) . length ) . toBeGreaterThan ( 0 ) ;
221
+ const searchTestButton = getByTestId ( 'searchTestButton' ) ;
222
+ expect ( searchTestButton ) . toBeInTheDocument ( ) ;
223
+
224
+ // Edit Search Query
225
+ const queryEditButton = getByTestId ( 'queryEditButton' ) ;
226
+ expect ( queryEditButton ) . toBeInTheDocument ( ) ;
227
+ userEvent . click ( queryEditButton ) ;
228
+ await waitFor ( ( ) => {
229
+ expect ( getAllByText ( 'Edit query' ) . length ) . toBeGreaterThan ( 0 ) ;
230
+ } ) ;
231
+ const searchQueryPresetButton = getByTestId ( 'searchQueryPresetButton' ) ;
232
+ expect ( searchQueryPresetButton ) . toBeInTheDocument ( ) ;
233
+ const searchQueryCloseButton = getByTestId ( 'searchQueryCloseButton' ) ;
234
+ expect ( searchQueryCloseButton ) . toBeInTheDocument ( ) ;
235
+ userEvent . click ( searchQueryCloseButton ) ;
236
+
237
+ // Add request processor
238
+ const addRequestProcessorButton = await waitFor (
239
+ ( ) => getAllByTestId ( 'addProcessorButton' ) [ 0 ]
240
+ ) ;
241
+ userEvent . click ( addRequestProcessorButton ) ;
242
+ await waitFor ( ( ) => {
243
+ expect ( getAllByText ( 'Processors' ) . length ) . toBeGreaterThan ( 0 ) ;
244
+ } ) ;
245
+
246
+ // Add response processor
247
+ const addResponseProcessorButton = getAllByTestId ( 'addProcessorButton' ) [ 1 ] ;
248
+ userEvent . click ( addResponseProcessorButton ) ;
249
+ await waitFor ( ( ) => {
250
+ expect ( getAllByText ( 'Processors' ) . length ) . toBeGreaterThan ( 0 ) ;
251
+ } ) ;
252
+
253
+ // Save, Build and Run query, Back buttons
254
+ expect ( getByTestId ( 'saveSearchPipelineButton' ) ) . toBeInTheDocument ( ) ;
255
+ expect ( getByTestId ( 'runQueryButton' ) ) . toBeInTheDocument ( ) ;
256
+ const searchPipelineBackButton = getByTestId ( 'searchPipelineBackButton' ) ;
257
+ userEvent . click ( searchPipelineBackButton ) ;
258
+
259
+ await waitFor ( ( ) => {
260
+ expect ( skipIngestRadio ) . toBeChecked ( ) ;
261
+ } ) ;
179
262
} ) ;
180
263
} ) ;
0 commit comments