diff --git a/cypress/fixtures/sample_destination_chime.json b/cypress/fixtures/sample_destination_chime.json deleted file mode 100644 index 147b589cf..000000000 --- a/cypress/fixtures/sample_destination_chime.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "sample_destination_chime", - "type": "chime", - "chime": { - "url": "https://hooks.chime.aws/incomingwebhooks/XXX?token=XXX" - } -} diff --git a/cypress/fixtures/sample_destination_custom_webhook.json b/cypress/fixtures/sample_destination_custom_webhook.json deleted file mode 100644 index 657b60c50..000000000 --- a/cypress/fixtures/sample_destination_custom_webhook.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "sample_destination", - "type": "custom_webhook", - "custom_webhook": { - "header_params": { - "Content-Type": "application/json" - }, - "url": "http://www.sampledestination.com" - } -} diff --git a/cypress/integration/bucket_level_monitor_spec.js b/cypress/integration/bucket_level_monitor_spec.js index 4b52523cb..b00687c0d 100644 --- a/cypress/integration/bucket_level_monitor_spec.js +++ b/cypress/integration/bucket_level_monitor_spec.js @@ -5,7 +5,6 @@ import { INDEX, PLUGIN_NAME } from '../support/constants'; import sampleAggregationQuery from '../fixtures/sample_aggregation_query'; -import sampleDestination from '../fixtures/sample_destination_custom_webhook'; import sampleExtractionQueryMonitor from '../fixtures/sample_extraction_query_bucket_level_monitor'; import sampleVisualEditorMonitor from '../fixtures/sample_visual_editor_bucket_level_monitor'; diff --git a/cypress/integration/cluster_metrics_monitor_spec.js b/cypress/integration/cluster_metrics_monitor_spec.js index 9800d1630..da8d576a3 100644 --- a/cypress/integration/cluster_metrics_monitor_spec.js +++ b/cypress/integration/cluster_metrics_monitor_spec.js @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import sampleDestination from '../fixtures/sample_destination_custom_webhook'; import sampleClusterMetricsMonitor from '../fixtures/sample_cluster_metrics_monitor.json'; import { INDEX, PLUGIN_NAME } from '../../cypress/support/constants'; diff --git a/cypress/integration/destination_spec.js b/cypress/integration/destination_spec.js deleted file mode 100644 index a30f9101d..000000000 --- a/cypress/integration/destination_spec.js +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -import { PLUGIN_NAME } from '../support/constants'; -import sampleDestination from '../fixtures/sample_destination_custom_webhook'; -import sampleDestinationChime from '../fixtures/sample_destination_chime'; - -const SAMPLE_DESTINATION = 'sample_destination'; -const SAMPLE_DESTINATION_WITH_ANOTHER_NAME = 'sample_destination_chime'; -const UPDATED_DESTINATION = 'updated_destination'; -const SAMPLE_URL = 'http://www.sampledestination.com'; - -describe('Destinations', () => { - beforeEach(() => { - // Set welcome screen tracking to false - localStorage.setItem('home:welcome:show', 'false'); - - // Visit Alerting OpenSearch Dashboards - cy.visit(`${Cypress.env('opensearch_dashboards')}/app/${PLUGIN_NAME}#/destinations`); - - // Common text to wait for to confirm page loaded, give up to 20 seconds for initial load - cy.contains('Add destination', { timeout: 20000 }); - }); - - describe('can be created', () => { - before(() => { - cy.deleteAllDestinations(); - }); - - it('with a custom webhook', () => { - // Confirm we loaded empty destination list - cy.contains('There are no existing destinations'); - - // Route us to create destination page - cy.contains('Add destination').click({ force: true }); - - // Wait for input to load and then type in the destination name - cy.get('input[name="name"]').type(SAMPLE_DESTINATION, { force: true }); - - // Select the type of destination - cy.get('#type').select('custom_webhook', { force: true }); - - // Wait for input to load and then type in the index name - cy.get('input[name="custom_webhook.url"]').type(SAMPLE_URL, { force: true }); - - // Click the create button - cy.get('button').contains('Create').click({ force: true }); - - // Confirm we can see the created destination in the list - cy.contains(SAMPLE_DESTINATION); - }); - }); - - describe('can be updated', () => { - before(() => { - cy.deleteAllDestinations(); - cy.createDestination(sampleDestination); - }); - - it('by changing the name', () => { - // Confirm we can see the created destination in the list - cy.contains(SAMPLE_DESTINATION); - - // Click the Edit button - cy.get('button').contains('Edit').click({ force: true }); - - // Wait for input to load and then type in the destination name - // should() is used to wait for input loading before clearing - cy.get('input[name="name"]') - .should('have.value', SAMPLE_DESTINATION) - .clear() - .type(UPDATED_DESTINATION, { force: true }); - - // Click the create button - cy.get('button').contains('Update').click({ force: true }); - - // Confirm we can see the updated destination in the list - cy.contains(UPDATED_DESTINATION); - }); - }); - - describe('can be deleted', () => { - before(() => { - cy.deleteAllDestinations(); - cy.createDestination(sampleDestination); - }); - - it('by clicking the button under "Actions"', () => { - // Confirm we can see the created destination in the list - cy.contains(SAMPLE_DESTINATION); - - // Click the Delete button - cy.contains('Delete').click({ force: true }); - - // Click the delete confirmation button in modal - cy.get(`[data-test-subj="confirmModalConfirmButton"]`).click(); - - // Confirm we can see an empty destination list - cy.contains('There are no existing destinations'); - }); - }); - - describe('can be searched', () => { - before(() => { - cy.deleteAllDestinations(); - // Create 21 destinations so that a monitor will not appear in the first page - for (let i = 0; i < 20; i++) { - cy.createDestination(sampleDestination); - } - cy.createDestination(sampleDestinationChime); - }); - - it('by name', () => { - // Sort the table by monitor name in alphabetical order - cy.get('thead > tr > th').contains('Destination name').click({ force: true }); - - // Confirm the monitor with a different name does not exist - cy.contains(SAMPLE_DESTINATION_WITH_ANOTHER_NAME).should('not.exist'); - - // Type in monitor name in search box - cy.get(`input[type="search"]`).focus().type(SAMPLE_DESTINATION_WITH_ANOTHER_NAME); - - // Confirm we filtered down to our one and only destination - cy.get('tbody > tr').should(($tr) => { - expect($tr, '1 row').to.have.length(1); - expect($tr, 'item').to.contain(SAMPLE_DESTINATION_WITH_ANOTHER_NAME); - }); - }); - }); - - after(() => { - // Delete all existing destinations - cy.deleteAllDestinations(); - }); -}); diff --git a/cypress/integration/query_level_monitor_spec.js b/cypress/integration/query_level_monitor_spec.js index e31a23bae..057b14820 100644 --- a/cypress/integration/query_level_monitor_spec.js +++ b/cypress/integration/query_level_monitor_spec.js @@ -7,7 +7,6 @@ import _ from 'lodash'; import { INDEX, PLUGIN_NAME } from '../support/constants'; import sampleQueryLevelMonitor from '../fixtures/sample_query_level_monitor'; import sampleQueryLevelMonitorWithAlwaysTrueTrigger from '../fixtures/sample_query_level_monitor_with_always_true_trigger'; -import sampleDestination from '../fixtures/sample_destination_custom_webhook.json'; const SAMPLE_MONITOR = 'sample_query_level_monitor'; const UPDATED_MONITOR = 'updated_query_level_monitor'; @@ -314,7 +313,6 @@ describe('Query-Level Monitors', () => { after(() => { // Delete all existing monitors and destinations cy.deleteAllMonitors(); - cy.deleteAllDestinations(); // Delete sample data cy.deleteIndexByName(`${INDEX.SAMPLE_DATA_ECOMMERCE}`); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 0188b9925..260b1587c 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -74,10 +74,6 @@ Cypress.Commands.add('createMonitor', (monitorJSON) => { cy.request('POST', `${Cypress.env('opensearch')}${API.MONITOR_BASE}`, monitorJSON); }); -Cypress.Commands.add('createDestination', (destinationJSON) => { - cy.request('POST', `${Cypress.env('opensearch')}${API.DESTINATION_BASE}`, destinationJSON); -}); - Cypress.Commands.add('createAndExecuteMonitor', (monitorJSON) => { cy.request('POST', `${Cypress.env('opensearch')}${API.MONITOR_BASE}`, monitorJSON).then( (response) => { @@ -138,25 +134,6 @@ Cypress.Commands.add('deleteAllMonitors', () => { }); }); -Cypress.Commands.add('deleteAllDestinations', () => { - cy.request({ - method: 'GET', - url: `${Cypress.env('opensearch')}${API.DESTINATION_BASE}?size=200`, - failOnStatusCode: false, // In case there is no alerting config index in cluster, where the status code is 404 - }).then((response) => { - if (response.status === 200) { - for (let i = 0; i < response.body.totalDestinations; i++) { - cy.request( - 'DELETE', - `${Cypress.env('opensearch')}${API.DESTINATION_BASE}/${response.body.destinations[i].id}` - ); - } - } else { - cy.log('Failed to get all destinations.', response); - } - }); -}); - Cypress.Commands.add('createIndexByName', (indexName) => { cy.request('PUT', `${Cypress.env('opensearch')}/${indexName}`); });