Skip to content

Commit

Permalink
Manually cherry-picked PR 1093. (#1114)
Browse files Browse the repository at this point in the history
Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
  • Loading branch information
AWSHurneyt authored Feb 19, 2024
1 parent 7c04fd9 commit 25e23cb
Show file tree
Hide file tree
Showing 10 changed files with 311 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import {
ALERTING_INDEX,
ALERTING_PLUGIN_NAME,
ALERTING_PLUGIN_TIMEOUT,
} from '../../../utils/plugins/alerting-dashboards-plugin/constants';
import sampleAlertsFlyoutBucketMonitor from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_alerts_flyout_bucket_level_monitor.json';
import sampleAlertsFlyoutQueryMonitor from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_alerts_flyout_query_level_monitor.json';
Expand All @@ -16,8 +17,6 @@ const BUCKET_TRIGGER = 'sample_alerts_flyout_bucket_level_trigger';
const QUERY_MONITOR = 'sample_alerts_flyout_query_level_monitor';
const QUERY_TRIGGER = 'sample_alerts_flyout_query_level_trigger';

const TWENTY_SECONDS = 20000;

describe('AcknowledgeAlertsModal', () => {
before(() => {
// Delete any existing monitors
Expand All @@ -34,8 +33,8 @@ describe('AcknowledgeAlertsModal', () => {
cy.visit(`${BASE_PATH}/app/${ALERTING_PLUGIN_NAME}#/monitors`);

// Confirm test monitors were created successfully
cy.contains(BUCKET_MONITOR, { timeout: TWENTY_SECONDS });
cy.contains(QUERY_MONITOR, { timeout: TWENTY_SECONDS });
cy.contains(BUCKET_MONITOR, { timeout: ALERTING_PLUGIN_TIMEOUT });
cy.contains(QUERY_MONITOR, { timeout: ALERTING_PLUGIN_TIMEOUT });

// Wait 1 minute for the test monitors to trigger alerts, then go to the 'Alerts by trigger' dashboard page to view alerts
cy.wait(60000);
Expand All @@ -46,16 +45,16 @@ describe('AcknowledgeAlertsModal', () => {
cy.visit(`${BASE_PATH}/app/${ALERTING_PLUGIN_NAME}#/dashboard`);

// Confirm dashboard is displaying rows for the test monitors.
cy.contains(BUCKET_MONITOR, { timeout: TWENTY_SECONDS });
cy.contains(QUERY_MONITOR, { timeout: TWENTY_SECONDS });
cy.contains(BUCKET_MONITOR, { timeout: ALERTING_PLUGIN_TIMEOUT });
cy.contains(QUERY_MONITOR, { timeout: ALERTING_PLUGIN_TIMEOUT });
});

it('Acknowledge button disabled when more than 1 trigger selected', () => {
// Set the 'severity' filter to only display rows with ACTIVE alerts.
cy.get('[data-test-subj="dashboardAlertStateFilter"]').select('Active');

// Confirm the 'Alerts by trigger' dashboard contains more than 1 row.
cy.get('tbody > tr', { timeout: TWENTY_SECONDS }).should(($tr) =>
cy.get('tbody > tr', { timeout: ALERTING_PLUGIN_TIMEOUT }).should(($tr) =>
expect($tr).to.have.length.greaterThan(1)
);

Expand All @@ -72,7 +71,7 @@ describe('AcknowledgeAlertsModal', () => {
cy.get(`input[type="search"]`).focus().type(BUCKET_TRIGGER);

// Confirm the dashboard is displaying only 1 row.
cy.get('tbody > tr', { timeout: TWENTY_SECONDS }).should(($tr) =>
cy.get('tbody > tr', { timeout: ALERTING_PLUGIN_TIMEOUT }).should(($tr) =>
expect($tr).to.have.length(1)
);

Expand All @@ -95,18 +94,18 @@ describe('AcknowledgeAlertsModal', () => {

// This monitor configuration consistently returns 46 alerts when testing locally.
// Confirm the modal dashboard contains more than 1 ACTIVE alert.
cy.get('tbody > tr', { timeout: TWENTY_SECONDS }).should(($tr) =>
expect($tr).to.have.length.greaterThan(1)
cy.get('tbody > tr', { timeout: ALERTING_PLUGIN_TIMEOUT }).should(
($tr) => expect($tr).to.have.length.greaterThan(1)
);

// Select the first and last alerts in the table.
cy.get('input[data-test-subj^="checkboxSelectRow-"]', {
timeout: TWENTY_SECONDS,
timeout: ALERTING_PLUGIN_TIMEOUT,
})
.first()
.click();
cy.get('input[data-test-subj^="checkboxSelectRow-"]', {
timeout: TWENTY_SECONDS,
timeout: ALERTING_PLUGIN_TIMEOUT,
})
.last()
.click();
Expand All @@ -130,8 +129,8 @@ describe('AcknowledgeAlertsModal', () => {
);

// Confirm the table displays 2 acknowledged alerts.
cy.get('tbody > tr', { timeout: TWENTY_SECONDS }).should(($tr) =>
expect($tr).to.have.length(2)
cy.get('tbody > tr', { timeout: ALERTING_PLUGIN_TIMEOUT }).should(
($tr) => expect($tr).to.have.length(2)
);
}
);
Expand All @@ -150,7 +149,7 @@ describe('AcknowledgeAlertsModal', () => {
cy.get(`input[type="search"]`).focus().type(QUERY_TRIGGER);

// Confirm the dashboard is displaying only 1 row.
cy.get('tbody > tr', { timeout: TWENTY_SECONDS }).should(($tr) =>
cy.get('tbody > tr', { timeout: ALERTING_PLUGIN_TIMEOUT }).should(($tr) =>
expect($tr).to.have.length(1)
);

Expand All @@ -172,8 +171,8 @@ describe('AcknowledgeAlertsModal', () => {
cy.get('[data-test-subj="dashboardAlertStateFilter"]').select('Active');

// Confirm the modal dashboard contains 1 alert.
cy.get('tbody > tr', { timeout: TWENTY_SECONDS }).should(($tr) =>
expect($tr).to.have.length(1)
cy.get('tbody > tr', { timeout: ALERTING_PLUGIN_TIMEOUT }).should(
($tr) => expect($tr).to.have.length(1)
);

// Select the alert.
Expand All @@ -198,8 +197,8 @@ describe('AcknowledgeAlertsModal', () => {
);

// Confirm the table displays 1 acknowledged alert.
cy.get('tbody > tr', { timeout: TWENTY_SECONDS }).should(($tr) =>
expect($tr).to.have.length(1)
cy.get('tbody > tr', { timeout: ALERTING_PLUGIN_TIMEOUT }).should(
($tr) => expect($tr).to.have.length(1)
);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ALERTING_PLUGIN_NAME } from '../../../utils/plugins/alerting-dashboards-plugin/constants';
import {
ALERTING_PLUGIN_NAME,
ALERTING_PLUGIN_TIMEOUT,
} from '../../../utils/plugins/alerting-dashboards-plugin/constants';
import sampleQueryLevelMonitorWithAlwaysTrueTrigger from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_query_level_monitor_with_always_true_trigger';
import sampleQueryLevelMonitorWorkflow from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_query_level_monitor_workflow';
import { BASE_PATH } from '../../../utils/base_constants';
Expand All @@ -19,7 +22,7 @@ describe('Alerts', () => {
cy.visit(`${BASE_PATH}/app/${ALERTING_PLUGIN_NAME}#/dashboard`);

// Common text to wait for to confirm page loaded, give up to 30 seconds for initial load
cy.contains('Acknowledge', { timeout: 30000 });
cy.contains('Acknowledge', { timeout: ALERTING_PLUGIN_TIMEOUT });
});

describe("can be in 'Active' state", () => {
Expand Down
Loading

0 comments on commit 25e23cb

Please sign in to comment.