diff --git a/cypress/integration/plugins/alerting-dashboards-plugin/cluster_metrics_monitor_spec.js b/cypress/integration/plugins/alerting-dashboards-plugin/cluster_metrics_monitor_spec.js index 4d0413330..944df9127 100644 --- a/cypress/integration/plugins/alerting-dashboards-plugin/cluster_metrics_monitor_spec.js +++ b/cypress/integration/plugins/alerting-dashboards-plugin/cluster_metrics_monitor_spec.js @@ -101,9 +101,7 @@ describe('ClusterMetricsMonitor', () => { beforeEach(() => { cy.deleteAllMonitors(); cy.reload(); - }); - it('for the Cluster Health API', () => { // Confirm empty monitor list is loaded cy.contains('There are no existing monitors'); @@ -117,11 +115,15 @@ describe('ClusterMetricsMonitor', () => { force: true, }); + // Wait for API types to load to reduce flakiness + cy.wait(5000); + }); + + it('for the Cluster Health API', () => { // Wait for input to load and then type in the monitor name cy.get('input[name="name"]').type(SAMPLE_CLUSTER_METRICS_HEALTH_MONITOR); - // Wait for the API types to load and then type in the Cluster Health API - cy.wait(5000); + // Type in the Cluster Health API cy.get('[data-test-subj="clusterMetricsApiTypeComboBox"]').type( 'cluster health{enter}' ); @@ -168,21 +170,12 @@ describe('ClusterMetricsMonitor', () => { }); it('for the Nodes Stats API', () => { - // Confirm empty monitor list is loaded - cy.contains('There are no existing monitors'); - - // Go to create monitor page - cy.contains('Create monitor').click(); - - // Select ClusterMetrics radio card - cy.get('[data-test-subj="clusterMetricsMonitorRadioCard"]').click(); - // Wait for input to load and then type in the monitor name cy.get('input[name="name"]').type( SAMPLE_CLUSTER_METRICS_NODES_STATS_MONITOR ); - // Wait for the API types to load and then type in the Cluster Health API + // Type in the Cluster Health API cy.get('[data-test-subj="clusterMetricsApiTypeComboBox"]').type( 'nodes stats{enter}' ); diff --git a/cypress/integration/plugins/alerting-dashboards-plugin/composite_level_monitor_spec.js b/cypress/integration/plugins/alerting-dashboards-plugin/composite_level_monitor_spec.js index 49bd4053f..e06a68ff8 100644 --- a/cypress/integration/plugins/alerting-dashboards-plugin/composite_level_monitor_spec.js +++ b/cypress/integration/plugins/alerting-dashboards-plugin/composite_level_monitor_spec.js @@ -11,6 +11,7 @@ import { import sampleCompositeJson from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_composite_level_monitor.json'; import * as _ from 'lodash'; import { BASE_PATH } from '../../../utils/base_constants'; +import { setupIntercept } from '../../../utils/plugins/security-analytics-dashboards-plugin/helpers'; const sample_index_1 = 'sample_index_1'; const sample_index_2 = 'sample_index_2'; @@ -109,8 +110,7 @@ describe('CompositeLevelMonitor', () => { .type('{backspace}', { force: true }) .type('Composite trigger', { force: true }); - cy.intercept('api/alerting/workflows').as('createMonitorRequest'); - cy.intercept(`api/alerting/monitors?*`).as('getMonitorsRequest'); + setupIntercept(cy, 'api/alerting/workflows', 'createMonitorRequest'); cy.get('button').contains('Create').click({ force: true }); // Wait for monitor to be created @@ -192,7 +192,12 @@ describe('CompositeLevelMonitor', () => { .type('monitorThree', { delay: 50 }) .type('{enter}'); - cy.intercept('api/alerting/workflows/*').as('updateMonitorRequest'); + setupIntercept( + cy, + 'api/alerting/workflows', + 'updateMonitorRequest', + 'PUT' + ); cy.get('button').contains('Update').click({ force: true }); // Wait for monitor to be created