Description
The custom-import-map-dashboards Cypress test suite contains 33 hardcoded cy.wait() calls totaling 289 seconds (~5 minutes) of unconditional sleep per test run. Zero cy.intercept() / cy.wait('@alias') calls exist. This is a primary source of both test flakiness and slow CI feedback loops.
Affected files
All under cypress/integration/plugins/custom-import-map-dashboards/:
| File |
cy.wait() calls |
Total sleep |
4_documentsLayer.spec.js |
13 |
112s |
5_add_map_to_dashboard.spec.js |
7 |
45s |
2_opensearchMapLayer.spec.js |
4 |
36s |
3_add_saved_object.spec.js |
3 |
35s |
1_import_vector_map_tab.spec.js |
2 |
25s |
6_geojson_file_upload.spec.js |
1 |
15s |
0_add_saved_object.js |
2 |
11s |
7_enable_new_home_ui.spec.js |
1 |
10s |
Anti-patterns found
1. Sleep-before-visit — Every file calls cy.wait(10000-15000) in before() after addSampleData(), then again after cy.visit(). Example in 4_documentsLayer.spec.js:19,25,27: 15s + 10s + 10s before the first assertion.
2. Sleep-instead-of-assertion — In 5_add_map_to_dashboard.spec.js:29-40, every UI interaction is preceded by cy.wait(5000). The pattern cy.wait(5000).get(selector).click() appears 6 times in a row.
3. Sleep-in-a-loop — At 2_opensearchMapLayer.spec.js:40-44, a for loop runs 21 iterations of cy.wait(1000).get('canvas').trigger('dblclick'), adding 21 seconds of dead time.
Suggested fixes
-
Replace cy.wait(N) after addSampleData() with cy.intercept on the sample data API, then cy.wait('@sampleData'). Eliminates 10-15s in every before() hook.
-
Replace cy.wait(N).get(selector) with cy.get(selector, { timeout }).should('be.visible') — Cypress's built-in retry makes this both faster and more reliable. Mechanical find-and-replace for ~20 occurrences.
-
Replace the zoom loop with programmatic map control via cy.window() to call setZoom(), or at minimum remove the cy.wait(1000) inside the loop.
-
Add cy.intercept for page-load readiness after cy.visit() instead of fixed sleeps.
Impact
- Flakiness on slower CI: if the server takes longer than the hardcoded sleep, the test fails
- Wasted time on faster CI: always sleeps the full duration even when the UI is ready in 200ms
- ~289 seconds of dead time per test run that could be reduced to near-zero with proper Cypress patterns
Description
The
custom-import-map-dashboardsCypress test suite contains 33 hardcodedcy.wait()calls totaling 289 seconds (~5 minutes) of unconditional sleep per test run. Zerocy.intercept()/cy.wait('@alias')calls exist. This is a primary source of both test flakiness and slow CI feedback loops.Affected files
All under
cypress/integration/plugins/custom-import-map-dashboards/:cy.wait()calls4_documentsLayer.spec.js5_add_map_to_dashboard.spec.js2_opensearchMapLayer.spec.js3_add_saved_object.spec.js1_import_vector_map_tab.spec.js6_geojson_file_upload.spec.js0_add_saved_object.js7_enable_new_home_ui.spec.jsAnti-patterns found
1. Sleep-before-visit — Every file calls
cy.wait(10000-15000)inbefore()afteraddSampleData(), then again aftercy.visit(). Example in4_documentsLayer.spec.js:19,25,27: 15s + 10s + 10s before the first assertion.2. Sleep-instead-of-assertion — In
5_add_map_to_dashboard.spec.js:29-40, every UI interaction is preceded bycy.wait(5000). The patterncy.wait(5000).get(selector).click()appears 6 times in a row.3. Sleep-in-a-loop — At
2_opensearchMapLayer.spec.js:40-44, aforloop runs 21 iterations ofcy.wait(1000).get('canvas').trigger('dblclick'), adding 21 seconds of dead time.Suggested fixes
Replace
cy.wait(N)afteraddSampleData()withcy.intercepton the sample data API, thency.wait('@sampleData'). Eliminates 10-15s in everybefore()hook.Replace
cy.wait(N).get(selector)withcy.get(selector, { timeout }).should('be.visible')— Cypress's built-in retry makes this both faster and more reliable. Mechanical find-and-replace for ~20 occurrences.Replace the zoom loop with programmatic map control via
cy.window()to callsetZoom(), or at minimum remove thecy.wait(1000)inside the loop.Add
cy.interceptfor page-load readiness aftercy.visit()instead of fixed sleeps.Impact