@@ -88,7 +88,7 @@ const testSuggestAD = (url) => {
8888 . click ( ) ;
8989 } ) ;
9090
91- it ( 'test before and after ' , ( ) => {
91+ it ( 'should create detector successfully ' , ( ) => {
9292 cy . get ( 'button[aria-label="OpenSearch assistant trigger button"]' , {
9393 timeout : 60000 ,
9494 } ) . click ( ) ;
@@ -122,37 +122,21 @@ const testSuggestAD = (url) => {
122122
123123 // Check main UI elements are present
124124 cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' ) . should ( 'exist' ) ; // Check for initial elements with adequate timeouts
125- cy . get ( '#add-anomaly-detector__title' , { timeout : 10000 } )
126- . should ( 'be.visible' )
127- . should ( 'contain' , 'Suggested anomaly detector' ) ;
128-
129- cy . get ( '[data-test-subj="detectionInterval"]' , { timeout : 5000 } ) . should (
130- 'exist'
131- ) ;
132- cy . get ( '[data-test-subj="windowDelay"]' , { timeout : 5000 } ) . should (
133- 'exist'
125+ cy . get ( '#add-anomaly-detector__title' ) . should (
126+ 'contain' ,
127+ 'Suggested anomaly detector'
134128 ) ;
129+ cy . get ( '[data-test-subj="detectionInterval"]' ) . should ( 'exist' ) ;
130+ cy . get ( '[data-test-subj="windowDelay"]' ) . should ( 'exist' ) ;
135131
136- // Expand the accordion with proper waiting
137132 cy . get ( '[id="detectorDetailsAccordion"]' )
138- . should ( 'exist' )
139133 . parent ( )
140134 . find ( '[data-test-subj="accordionTitleButton"]' )
141- . should ( 'be.visible' )
142135 . click ( ) ;
143136
144- // Wait for animation to complete
145- cy . wait ( 1000 ) ;
146-
147- // Test empty name validation with safer interactions
148- cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' )
149- . should ( 'be.visible' )
150- . clear ( ) ;
151-
152- // Use separate commands instead of chaining for more stability
153- cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' )
154- . should ( 'be.visible' )
155- . blur ( { force : true } ) ;
137+ // Test empty name validation
138+ cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' ) . clear ( ) ;
139+ cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' ) . blur ( ) ;
156140
157141 // Wait and check for error message with retry
158142 cy . wait ( 500 ) ;
@@ -226,106 +210,6 @@ const testSuggestAD = (url) => {
226210 cy . wait ( '@startDetector' ) ;
227211 } ) ;
228212
229- it . skip ( 'should create detector successfully' , ( ) => {
230- cy . get ( 'button[aria-label="OpenSearch assistant trigger button"]' , {
231- timeout : 60000 ,
232- } ) . click ( ) ;
233- cy . contains ( 'Suggest anomaly detector' ) . click ( ) ;
234-
235- cy . intercept ( 'POST' , 'w/*/api/assistant/agent/_execute**' , ( req ) => {
236- req . reply ( ( ) => {
237- return {
238- statusCode : 200 ,
239- headers : {
240- 'content-type' : 'application/json' ,
241- } ,
242- body : {
243- inference_results : [
244- {
245- output : [
246- {
247- name : 'response' ,
248- result :
249- '{"index":"opensearch_dashboards_sample_data_logs","categoryField":"geo.src","aggregationField":"bytes,memory,phpmemory","aggregationMethod":"sum,avg,max","dateFields":"utc_time,timestamp"}' ,
250- } ,
251- ] ,
252- } ,
253- ] ,
254- } ,
255- } ;
256- } ) ;
257- } ) . as ( 'suggestParameters' ) ;
258-
259- cy . wait ( '@suggestParameters' ) ;
260-
261- // Check main UI elements are present
262- cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' ) . should ( 'exist' ) ;
263- cy . get ( '#add-anomaly-detector__title' ) . should (
264- 'contain' ,
265- 'Suggested anomaly detector'
266- ) ;
267- cy . get ( '[data-test-subj="detectionInterval"]' ) . should ( 'exist' ) ;
268- cy . get ( '[data-test-subj="windowDelay"]' ) . should ( 'exist' ) ;
269-
270- cy . get ( '[id="detectorDetailsAccordion"]' )
271- . parent ( )
272- . find ( '[data-test-subj="accordionTitleButton"]' )
273- . click ( ) ;
274-
275- // Test empty name validation
276- cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' ) . clear ( ) ;
277- cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' ) . blur ( ) ;
278- cy . contains ( 'Detector name cannot be empty' ) . should ( 'be.visible' ) ;
279-
280- // Test valid name
281- cy . get ( '[data-test-subj="detectorNameTextInputFlyout"]' ) . type (
282- 'test-detector-name' + Math . floor ( Math . random ( ) * 100 ) + 1
283- ) ;
284- cy . contains ( 'Detector name cannot be empty' ) . should ( 'not.exist' ) ;
285-
286- // Test interval input
287- cy . get ( '[data-test-subj="detectionInterval"]' ) . clear ( ) . type ( '15' ) ;
288-
289- // Test window delay input
290- cy . get ( '[data-test-subj="windowDelay"]' ) . clear ( ) . type ( '5' ) ;
291-
292- // Mock the create detector API call
293- cy . intercept ( 'POST' , 'w/*/api/anomaly_detectors/detectors/*' , ( req ) => {
294- req . reply ( {
295- statusCode : 200 ,
296- body : {
297- ok : true ,
298- response : {
299- id : 'test-detector-id' ,
300- } ,
301- } ,
302- } ) ;
303- } ) . as ( 'createDetector' ) ;
304-
305- // Mock the start detector API call
306- cy . intercept (
307- 'POST' ,
308- 'w/*/api/anomaly_detectors/detectors/test-detector-id/start/*' ,
309- ( req ) => {
310- req . reply ( {
311- statusCode : 200 ,
312- body : {
313- ok : true ,
314- response : {
315- _id : 'test-detector-id' ,
316- } ,
317- } ,
318- } ) ;
319- }
320- ) . as ( 'startDetector' ) ;
321-
322- // Click create button
323- cy . contains ( 'button' , 'Create detector' ) . click ( ) ;
324- cy . wait ( '@createDetector' ) ;
325- cy . contains ( 'Detector created' ) . should ( 'be.visible' ) ;
326- cy . wait ( '@startDetector' ) ;
327- } ) ;
328-
329213 it ( 'should handle suggest parameters error gracefully' , ( ) => {
330214 cy . get ( 'button[aria-label="OpenSearch assistant trigger button"]' , {
331215 timeout : 60000 ,
0 commit comments