From cd227a655bb65d9aaac516164b2eaace548a94d1 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:14:25 +0800 Subject: [PATCH 01/12] Security notif test (#1494) (#1496) * fix tests to work with security enabled Signed-off-by: Riya Saxena * fix tests with security enabled Signed-off-by: Riya Saxena * fix delete ses, smtp senders with security Signed-off-by: Riya Saxena * fix notifications dashboards tests Signed-off-by: Riya Saxena --------- Signed-off-by: Riya Saxena Signed-off-by: Riya <69919272+riysaxen-amzn@users.noreply.github.com> (cherry picked from commit 336902be94d9ab475eb433cc62c737ea2e1deb4a) Co-authored-by: Riya <69919272+riysaxen-amzn@users.noreply.github.com> --- .../1_email_senders_and_groups.spec.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cypress/integration/plugins/notifications-dashboards/1_email_senders_and_groups.spec.js b/cypress/integration/plugins/notifications-dashboards/1_email_senders_and_groups.spec.js index 59df1b96d..92d276176 100644 --- a/cypress/integration/plugins/notifications-dashboards/1_email_senders_and_groups.spec.js +++ b/cypress/integration/plugins/notifications-dashboards/1_email_senders_and_groups.spec.js @@ -265,9 +265,8 @@ describe('Test create, edit and delete recipient group', () => { it('deletes recipient groups', () => { cy.wait(NOTIFICATIONS_DELAY); - cy.get('tbody > tr').should(($tr) => { - expect($tr, '1 row').to.have.length(1); - }); + cy.contains('Test recipient group').should('exist'); + cy.wait(NOTIFICATIONS_DELAY); cy.get('[data-test-subj="checkboxSelectAll"]').click({ force: true }); cy.wait(NOTIFICATIONS_DELAY); cy.get('[data-test-subj="recipient-groups-table-delete-button"]').click({ From 7b4cd75c7b0143bdbd9b7894415919cc7b5c0290 Mon Sep 17 00:00:00 2001 From: Riya <69919272+riysaxen-amzn@users.noreply.github.com> Date: Mon, 5 Aug 2024 10:14:02 -0700 Subject: [PATCH 02/12] add ; to tests (#1505) Signed-off-by: Riya Saxena --- .../1_email_senders_and_groups.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/integration/plugins/notifications-dashboards/1_email_senders_and_groups.spec.js b/cypress/integration/plugins/notifications-dashboards/1_email_senders_and_groups.spec.js index 92d276176..530a3c0c4 100644 --- a/cypress/integration/plugins/notifications-dashboards/1_email_senders_and_groups.spec.js +++ b/cypress/integration/plugins/notifications-dashboards/1_email_senders_and_groups.spec.js @@ -164,7 +164,7 @@ describe('Test delete senders', () => { force: true, }); cy.wait(NOTIFICATIONS_DELAY); - cy.get('input[placeholder="delete"]').should('be.visible').type('delete') + cy.get('input[placeholder="delete"]').should('be.visible').type('delete'); cy.wait(NOTIFICATIONS_DELAY); cy.get('[data-test-subj="delete-sender-modal-delete-button"]').click(); cy.contains('successfully deleted.').should('exist'); @@ -178,7 +178,7 @@ describe('Test delete senders', () => { force: true, }); cy.wait(NOTIFICATIONS_DELAY); - cy.get('input[placeholder="delete"]').should('be.visible').type('delete') + cy.get('input[placeholder="delete"]').should('be.visible').type('delete'); cy.wait(NOTIFICATIONS_DELAY); cy.get('[data-test-subj="delete-sender-modal-delete-button"]').click(); cy.contains('successfully deleted.').should('exist'); From 77b4d191e18f08c420a1ff7b3705385240d484ca Mon Sep 17 00:00:00 2001 From: Nishant Goel <113011736+nisgoel-amazon@users.noreply.github.com> Date: Mon, 5 Aug 2024 23:18:00 +0530 Subject: [PATCH 03/12] select checkbox via id instead of class name (#1503) * select checkbox via id instead of class name Signed-off-by: Nishant Goel * Re trigger PR workflows Signed-off-by: Nishant Goel * Instead of sorting in asc order on aliases page, search the alias via text Signed-off-by: Nishant Goel --------- Signed-off-by: Nishant Goel --- .../aliases.js | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/cypress/integration/plugins/index-management-dashboards-plugin/aliases.js b/cypress/integration/plugins/index-management-dashboards-plugin/aliases.js index bb0b4cf41..72442ee0b 100644 --- a/cypress/integration/plugins/index-management-dashboards-plugin/aliases.js +++ b/cypress/integration/plugins/index-management-dashboards-plugin/aliases.js @@ -142,9 +142,9 @@ describe('Aliases', () => { describe('can flush an alias', () => { it('successfully flush an index', () => { - let sample_alias = `${SAMPLE_ALIAS_PREFIX}-${1}`; + let sample_alias = `${SAMPLE_ALIAS_PREFIX}-1`; // Sort all aliases in asc order to make it at first page - cy.contains('Alias name').click(); + cy.get('[placeholder="Search..."]').type(`${sample_alias}{enter}`); // Confirm we have our initial alias cy.contains(sample_alias); // index a test doc @@ -170,28 +170,20 @@ describe('Aliases', () => { expect(num).to.equal(1); }); - cy.get('[data-test-subj="moreAction"]').click(); - // Flush btn should be disabled if no items selected - cy.get('[data-test-subj="Flush Action"]').should( - 'have.class', - 'euiContextMenuItem-isDisabled' - ); - - // Select an alias - cy.get(`[data-test-subj="checkboxSelectRow-${sample_alias}"]`).check({ - force: true, - }); - - cy.get('[data-test-subj="moreAction"]').click(); - - // Extra wait required for page data to load, otherwise "Enable" button will be disabled - cy.wait(2000); + cy.get('[data-test-subj="moreAction"] button') + .click() + .get('[data-test-subj="Flush Action"]') + .should('be.disabled') + .end(); - // Flush btn should be enabled - cy.get('[data-test-subj="Flush Action"]') - .should('exist') - .should('not.have.class', 'euiContextMenuItem-isDisabled') - .click(); + cy.get(`#_selection_column_${sample_alias}-checkbox`) + .click() + .get('[data-test-subj="moreAction"] button') + .click() + .get('[data-test-subj="Flush Action"]') + .should('not.be.disabled') + .click() + .end(); // Check for flush index modal cy.contains('Flush alias'); From 09bf9ce4d661b3f287a3d6454da89be2fafeaf6e Mon Sep 17 00:00:00 2001 From: Riya <69919272+riysaxen-amzn@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:49:17 -0700 Subject: [PATCH 04/12] Fix channel tests (#1507) * add ; to tests Signed-off-by: Riya Saxena * fix channel tests in notifications Signed-off-by: Riya Saxena * fix channel tests in notifications Signed-off-by: Riya Saxena --------- Signed-off-by: Riya Saxena --- .../notifications-dashboards/test_chime_channel.json | 2 +- .../notifications-dashboards/test_slack_channel.json | 2 +- .../plugins/notifications-dashboards/2_channels.spec.js | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cypress/fixtures/plugins/notifications-dashboards/test_chime_channel.json b/cypress/fixtures/plugins/notifications-dashboards/test_chime_channel.json index feb56cc1f..e3e4b214a 100644 --- a/cypress/fixtures/plugins/notifications-dashboards/test_chime_channel.json +++ b/cypress/fixtures/plugins/notifications-dashboards/test_chime_channel.json @@ -5,7 +5,7 @@ "config_type": "chime", "is_enabled": true, "chime": { - "url": "https://sample-chime-webhook" + "url": "https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456" } } } \ No newline at end of file diff --git a/cypress/fixtures/plugins/notifications-dashboards/test_slack_channel.json b/cypress/fixtures/plugins/notifications-dashboards/test_slack_channel.json index 7643b2b0d..e24a94462 100644 --- a/cypress/fixtures/plugins/notifications-dashboards/test_slack_channel.json +++ b/cypress/fixtures/plugins/notifications-dashboards/test_slack_channel.json @@ -5,7 +5,7 @@ "config_type": "slack", "is_enabled": true, "slack": { - "url": "https://sample-slack-webhook" + "url": "https://hooks.slack.com/services/A123456/B1234567/A1B2C3D4E5F6G7H8I9J0K1L2" } } } \ No newline at end of file diff --git a/cypress/integration/plugins/notifications-dashboards/2_channels.spec.js b/cypress/integration/plugins/notifications-dashboards/2_channels.spec.js index bd5766e86..be783bec4 100644 --- a/cypress/integration/plugins/notifications-dashboards/2_channels.spec.js +++ b/cypress/integration/plugins/notifications-dashboards/2_channels.spec.js @@ -35,7 +35,7 @@ describe('Test create channels', () => { cy.get('[placeholder="Enter channel name"]').type('Test slack channel'); cy.get('[data-test-subj="create-channel-slack-webhook-input"]').type( - 'https://sample-slack-webhook' + 'https://hooks.slack.com/services/A123456/B1234567/A1B2C3D4E5F6G7H8I9J0K1L2' ); cy.wait(NOTIFICATIONS_DELAY); cy.get('[data-test-subj="create-channel-send-test-message-button"]').click({ @@ -44,10 +44,12 @@ describe('Test create channels', () => { cy.wait(NOTIFICATIONS_DELAY); // This needs some time to appear as it will wait for backend call to timeout cy.contains('test message.').should('exist'); + cy.wait(NOTIFICATIONS_DELAY); cy.get('[data-test-subj="create-channel-create-button"]').click({ force: true, }); + cy.wait(NOTIFICATIONS_DELAY); cy.contains('successfully created.').should('exist'); }); @@ -62,11 +64,12 @@ describe('Test create channels', () => { cy.wait(NOTIFICATIONS_DELAY); cy.get('[data-test-subj="create-channel-chime-webhook-input"]').type( - 'https://sample-chime-webhook' + 'https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456' ); cy.wait(NOTIFICATIONS_DELAY); cy.get('[data-test-subj="create-channel-create-button"]').click(); + cy.wait(NOTIFICATIONS_DELAY); cy.contains('successfully created.').should('exist'); }); From 4ff7b93a0b8adbb0200d8bd77bab55b9bd58cc61 Mon Sep 17 00:00:00 2001 From: Simeon Widdis Date: Sun, 18 Aug 2024 18:00:19 -0700 Subject: [PATCH 05/12] Fix panel test not respecting base path setting (#1520) * Fix panel test not respecting base path setting Signed-off-by: Simeon Widdis * Apply prettier lints Signed-off-by: Simeon Widdis --------- Signed-off-by: Simeon Widdis --- .../plugins/observability-dashboards/4_panels.spec.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cypress/integration/plugins/observability-dashboards/4_panels.spec.js b/cypress/integration/plugins/observability-dashboards/4_panels.spec.js index 001c25f9f..4b63d5e54 100644 --- a/cypress/integration/plugins/observability-dashboards/4_panels.spec.js +++ b/cypress/integration/plugins/observability-dashboards/4_panels.spec.js @@ -30,7 +30,9 @@ describe('Testing panels table', () => { cy.get('input.euiFieldText').focus().type(TEST_PANEL, { delay: 50, }); - cy.intercept('POST', '/api/saved_objects/*').as('createDashboard'); + cy.intercept('POST', `${BASE_PATH}/api/saved_objects/*`).as( + 'createDashboard' + ); cy.get('.euiButton__text') .contains(/^Create$/) .trigger('mouseover') From 6a4e9b98472aeacba775a35680b9980cea6c5663 Mon Sep 17 00:00:00 2001 From: AWSHurneyt Date: Mon, 19 Aug 2024 10:20:42 -0700 Subject: [PATCH 06/12] Removed test index settings. (#1523) Signed-off-by: AWSHurneyt --- .../integration_tests/index/create_dns_settings.json | 6 ------ .../integration_tests/index/create_windows_settings.json | 6 ------ .../sample_dns_index_settings.json | 6 ------ .../sample_network_index_settings.json | 6 ------ .../sample_windows_index_settings.json | 6 ------ 5 files changed, 30 deletions(-) diff --git a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/integration_tests/index/create_dns_settings.json b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/integration_tests/index/create_dns_settings.json index 970a6089a..4eb7e78b1 100644 --- a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/integration_tests/index/create_dns_settings.json +++ b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/integration_tests/index/create_dns_settings.json @@ -11,11 +11,5 @@ "type": "text" } } - }, - "settings": { - "index": { - "number_of_shards": "1", - "number_of_replicas": "1" - } } } diff --git a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/integration_tests/index/create_windows_settings.json b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/integration_tests/index/create_windows_settings.json index 02c187caf..0eeda505a 100644 --- a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/integration_tests/index/create_windows_settings.json +++ b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/integration_tests/index/create_windows_settings.json @@ -8,11 +8,5 @@ "type": "text" } } - }, - "settings": { - "index": { - "number_of_shards": "1", - "number_of_replicas": "1" - } } } diff --git a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_dns_index_settings.json b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_dns_index_settings.json index 02b01e771..7ff9d6935 100644 --- a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_dns_index_settings.json +++ b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_dns_index_settings.json @@ -11,11 +11,5 @@ "type": "text" } } - }, - "settings": { - "index": { - "number_of_shards": "1", - "number_of_replicas": "1" - } } } diff --git a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_network_index_settings.json b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_network_index_settings.json index c1451abf3..71b48c2ce 100644 --- a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_network_index_settings.json +++ b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_network_index_settings.json @@ -29,11 +29,5 @@ "type": "text" } } - }, - "settings": { - "index": { - "number_of_shards": "1", - "number_of_replicas": "1" - } } } diff --git a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_windows_index_settings.json b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_windows_index_settings.json index 480f63ba1..8882302cd 100644 --- a/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_windows_index_settings.json +++ b/cypress/fixtures/plugins/security-analytics-dashboards-plugin/sample_windows_index_settings.json @@ -8,11 +8,5 @@ "type": "text" } } - }, - "settings": { - "index": { - "number_of_shards": "1", - "number_of_replicas": "1" - } } } From 415c2f0c252d6a41a7dd80d5ceff82df583d9337 Mon Sep 17 00:00:00 2001 From: Dan Dong <58446449+danieldong51@users.noreply.github.com> Date: Wed, 21 Aug 2024 10:59:33 -0700 Subject: [PATCH 07/12] updated AD testing (#1518) --- .../vis_augmenter/associate_detector_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_spec.js index 7a9c8ee4d..042546d83 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_spec.js @@ -88,7 +88,7 @@ describe('Anomaly detection integration with vis augmenter', () => { it('Associate existing detector - creation flow', () => { openAddAnomalyDetectorFlyout(dashboardName, visualizationName); - cy.get('.euiFlyout').find('.euiTitle').contains('Add anomaly detector'); + cy.get('.euiFlyout').find('.euiText').contains('Add anomaly detector'); // ensuring the flyout is defaulting to detector creation vs. association cy.getElementByTestId('adAnywhereCreateDetectorButton'); cy.get('[id="add-anomaly-detector__existing"]').click(); From cc112532b48b6f23260f8dfec04cfff0d2a6c374 Mon Sep 17 00:00:00 2001 From: Sumukh Swamy Date: Thu, 22 Aug 2024 09:40:14 -0700 Subject: [PATCH 08/12] Fix for reporting integ test failures (#1530) * added fix for integ test failures Signed-off-by: sumukhswamy * linter changes Signed-off-by: sumukhswamy --------- Signed-off-by: sumukhswamy --- .../reports-dashboards/02-edit.spec.js | 89 +++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/cypress/integration/plugins/reports-dashboards/02-edit.spec.js b/cypress/integration/plugins/reports-dashboards/02-edit.spec.js index 152094d61..53ced4565 100644 --- a/cypress/integration/plugins/reports-dashboards/02-edit.spec.js +++ b/cypress/integration/plugins/reports-dashboards/02-edit.spec.js @@ -17,6 +17,24 @@ describe('Cypress', () => { cy.wait(12500); + cy.intercept( + 'GET', + `${BASE_PATH}/api/reporting/getReportSource/dashboard` + ).as('dashboard'); + + cy.intercept( + 'GET', + `${BASE_PATH}/api/reporting/getReportSource/visualization` + ).as('visualization'); + + cy.intercept('GET', `${BASE_PATH}/api/reporting/getReportSource/search`).as( + 'search' + ); + + cy.intercept('GET', `${BASE_PATH}/api/observability/notebooks/`).as( + 'notebook' + ); + cy.get('#reportDefinitionDetailsLink').first().click({ force: true }); cy.get('#editReportDefinitionButton').should('exist'); @@ -26,14 +44,23 @@ describe('Cypress', () => { cy.url().should('include', 'edit'); cy.wait(1000); + cy.wait('@dashboard'); + cy.wait('@visualization'); + cy.wait('@search'); + cy.wait('@notebook'); // update the report name - cy.get('#reportSettingsName').type(' update name'); + cy.get('#reportSettingsName').type('{selectall}{backspace} update name'); // update report description - cy.get('#reportSettingsDescription').type(' update description'); + cy.get('#reportSettingsDescription').type( + '{selectall}{backspace} update description' + ); - cy.get('#editReportDefinitionButton').click({ force: true }); + cy.get('#editReportDefinitionButton') + .contains('Save Changes') + .trigger('mouseover') + .click({ force: true }); cy.wait(12500); @@ -52,6 +79,24 @@ describe('Cypress', () => { cy.wait(12500); + cy.intercept( + 'GET', + `${BASE_PATH}/api/reporting/getReportSource/dashboard` + ).as('dashboard'); + + cy.intercept( + 'GET', + `${BASE_PATH}/api/reporting/getReportSource/visualization` + ).as('visualization'); + + cy.intercept('GET', `${BASE_PATH}/api/reporting/getReportSource/search`).as( + 'search' + ); + + cy.intercept('GET', `${BASE_PATH}/api/observability/notebooks/`).as( + 'notebook' + ); + cy.get('#reportDefinitionDetailsLink').first().click(); cy.get('#editReportDefinitionButton').should('exist'); @@ -61,12 +106,20 @@ describe('Cypress', () => { cy.url().should('include', 'edit'); cy.wait(1000); + + cy.wait('@dashboard'); + cy.wait('@visualization'); + cy.wait('@search'); + cy.wait('@notebook'); cy.get('#reportDefinitionTriggerTypes > div:nth-child(2)').click({ force: true, }); cy.get('#Schedule').check({ force: true }); - cy.get('#editReportDefinitionButton').click({ force: true }); + cy.get('#editReportDefinitionButton') + .contains('Save Changes') + .trigger('mouseover') + .click({ force: true }); cy.wait(12500); @@ -85,6 +138,24 @@ describe('Cypress', () => { cy.wait(12500); + cy.intercept( + 'GET', + `${BASE_PATH}/api/reporting/getReportSource/dashboard` + ).as('dashboard'); + + cy.intercept( + 'GET', + `${BASE_PATH}/api/reporting/getReportSource/visualization` + ).as('visualization'); + + cy.intercept('GET', `${BASE_PATH}/api/reporting/getReportSource/search`).as( + 'search' + ); + + cy.intercept('GET', `${BASE_PATH}/api/observability/notebooks/`).as( + 'notebook' + ); + cy.get('#reportDefinitionDetailsLink').first().click(); cy.get('#editReportDefinitionButton').should('exist'); @@ -95,11 +166,19 @@ describe('Cypress', () => { cy.wait(1000); + cy.wait('@dashboard'); + cy.wait('@visualization'); + cy.wait('@search'); + cy.wait('@notebook'); + cy.get('#reportDefinitionTriggerTypes > div:nth-child(1)').click({ force: true, }); - cy.get('#editReportDefinitionButton').click({ force: true }); + cy.get('#editReportDefinitionButton') + .contains('Save Changes') + .trigger('mouseover') + .click({ force: true }); cy.wait(12500); From 221231d976d1c111e79827f0a8e29eacb64efd7b Mon Sep 17 00:00:00 2001 From: Kaituo Li Date: Mon, 26 Aug 2024 17:00:54 -0700 Subject: [PATCH 09/12] Fix Cypress Test Flakiness by Executing cy.visit Before cy.request (#1537) This PR addresses intermittent failures in the AD Cypress tests related to a known issue in Cypress (https://github.com/cypress-io/cypress/issues/25397). The specific failure observed was: ``` Sample detector "before all" hook for "Empty message with modal": AssertionError: Timed out retrying after 60000ms: Expected to find element: `[data-test-subj="viewSampleDetectorLink"]`, but never found it. ``` To mitigate this issue, we applied a workaround suggested in the GitHub issue, ensuring that cy.visit is executed before cy.request. This change helps stabilize the tests by properly loading AD overview page before making any API requests. Testing: * Ran all Cypress tests with the modified code to verify the fix. Signed-off-by: Kaituo Li --- .../create_detector_spec.js | 1 + .../detector_configuration_spec.js | 1 + .../historical_analysis_spec.js | 4 +++- .../anomaly-detection-dashboards-plugin/overview_spec.js | 2 +- .../sample_detector_spec.js | 4 ++++ .../vis_augmenter/associate_detector_spec.js | 2 ++ .../vis_augmenter/augment_vis_saved_object_spec.js | 2 ++ .../vis_augmenter/view_anomaly_events_spec.js | 2 ++ 8 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/create_detector_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/create_detector_spec.js index 556e0b981..a1829941a 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/create_detector_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/create_detector_spec.js @@ -15,6 +15,7 @@ context('Create detector workflow', () => { // Index some sample data first beforeEach(() => { + cy.visit(AD_URL.OVERVIEW, { timeout: 10000 }); cy.deleteAllIndices(); cy.deleteADSystemIndices(); cy.fixture(AD_FIXTURE_BASE_PATH + 'sample_test_data.txt').then((data) => { diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/detector_configuration_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/detector_configuration_spec.js index 66b4f97ac..c4a626e9d 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/detector_configuration_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/detector_configuration_spec.js @@ -9,6 +9,7 @@ context('Detector configuration page', () => { // Creating a sample detector and visiting the config page. Stopping the detector // for easier checks when editing detector before(() => { + cy.visit(AD_URL.OVERVIEW, { timeout: 10000 }); cy.deleteAllIndices(); cy.deleteADSystemIndices(); cy.visit(AD_URL.OVERVIEW); diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/historical_analysis_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/historical_analysis_spec.js index 1cf93e8c9..929814808 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/historical_analysis_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/historical_analysis_spec.js @@ -52,10 +52,12 @@ describe('Historical results page', () => { // Creating a sample detector and visiting the config page before(() => { + cy.visit(AD_URL.OVERVIEW, { timeout: 10000 }); cy.deleteAllIndices(); cy.deleteADSystemIndices(); cy.wait(5000); - cy.visit(AD_URL.OVERVIEW); + cy.visit(AD_URL.OVERVIEW, { timeout: 10000 }); + cy.wait(2000); cy.get('[data-test-subj=createHttpSampleDetectorButton]').then(() => { cy.getElementByTestId('createHttpSampleDetectorButton').click(); cy.wait(10000); diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/overview_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/overview_spec.js index c8e7acb9c..26b1cdb46 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/overview_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/overview_spec.js @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { AD_URL } from '../../../utils/constants'; +import { AD_URL } from '../../../utils/plugins/anomaly-detection-dashboards-plugin/constants'; context('Overview page', () => { function validatePageElements() { diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/sample_detector_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/sample_detector_spec.js index ebcab7e29..8fcb07f89 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/sample_detector_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/sample_detector_spec.js @@ -4,8 +4,12 @@ */ import { createSampleDetector } from '../../../utils/helpers'; +import { AD_URL } from '../../../utils/plugins/anomaly-detection-dashboards-plugin/constants'; context('Sample detectors', () => { + before(() => { + cy.visit(AD_URL.OVERVIEW, { timeout: 10000 }); + }); beforeEach(() => { cy.deleteAllIndices(); cy.deleteADSystemIndices(); diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_spec.js index 042546d83..e345b7d53 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_spec.js @@ -20,6 +20,7 @@ import { INDEX_SETTINGS_FILEPATH_SIMPLE, SAMPLE_DATA_FILEPATH_SIMPLE, } from '../../../../utils/constants'; +import { AD_URL } from '../../../../utils/plugins/anomaly-detection-dashboards-plugin/constants'; describe('Anomaly detection integration with vis augmenter', () => { const indexName = 'ad-vis-augmenter-sample-index'; @@ -51,6 +52,7 @@ describe('Anomaly detection integration with vis augmenter', () => { dashboardName, [visualizationSpec] ); + cy.visit(AD_URL.OVERVIEW, { timeout: 10000 }); }); after(() => { diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/augment_vis_saved_object_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/augment_vis_saved_object_spec.js index 1f02b0f90..76827c712 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/augment_vis_saved_object_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/augment_vis_saved_object_spec.js @@ -18,6 +18,7 @@ import { INDEX_SETTINGS_FILEPATH_SIMPLE, SAMPLE_DATA_FILEPATH_SIMPLE, } from '../../../../utils/constants'; +import { AD_URL } from '../../../../utils/plugins/anomaly-detection-dashboards-plugin/constants'; describe('AD augment-vis saved objects', () => { const commonUI = new CommonUI(cy); @@ -50,6 +51,7 @@ describe('AD augment-vis saved objects', () => { dashboardName, [visualizationSpec] ); + cy.visit(AD_URL.OVERVIEW, { timeout: 10000 }); }); after(() => { diff --git a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/view_anomaly_events_spec.js b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/view_anomaly_events_spec.js index 40583a39f..b195edeaf 100644 --- a/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/view_anomaly_events_spec.js +++ b/cypress/integration/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/view_anomaly_events_spec.js @@ -17,6 +17,7 @@ import { INDEX_SETTINGS_FILEPATH_SIMPLE, SAMPLE_DATA_FILEPATH_SIMPLE, } from '../../../../utils/constants'; +import { AD_URL } from '../../../../utils/plugins/anomaly-detection-dashboards-plugin/constants'; describe('View anomaly events in flyout', () => { const indexName = 'ad-vis-augmenter-sample-index'; @@ -48,6 +49,7 @@ describe('View anomaly events in flyout', () => { dashboardName, [visualizationSpec] ); + cy.visit(AD_URL.OVERVIEW, { timeout: 10000 }); }); after(() => { From 1ceb4c9a547781b62a7ee8736ed287bfe9ca8109 Mon Sep 17 00:00:00 2001 From: Dan Dong <58446449+danieldong51@users.noreply.github.com> Date: Tue, 27 Aug 2024 11:30:56 -0700 Subject: [PATCH 10/12] Update Security Dashboards testing due to look&feel changes (#1535) Signed-off-by: Dan Dong --- cypress/integration/plugins/security/audit_log_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/plugins/security/audit_log_spec.js b/cypress/integration/plugins/security/audit_log_spec.js index 369169b92..2f5fce5f7 100644 --- a/cypress/integration/plugins/security/audit_log_spec.js +++ b/cypress/integration/plugins/security/audit_log_spec.js @@ -24,7 +24,7 @@ if (Cypress.env('SECURITY_ENABLED')) { } ); - cy.contains('h3', 'Audit logging'); + cy.contains('h1', 'Audit logging'); cy.contains('h3', 'General settings'); cy.contains('h3', 'Compliance settings'); }); From e06a6f28245adc43623892f540f59976e0813b61 Mon Sep 17 00:00:00 2001 From: Junqiu Lei Date: Thu, 29 Aug 2024 18:14:17 -0700 Subject: [PATCH 11/12] Add test cases to dashboards maps (#1540) Signed-off-by: Junqiu Lei --- .../sample_geo.json | 8 ++++ .../0_add_saved_object.js | 34 +++++++++++++ .../1_import_vector_map_tab.spec.js | 4 +- .../2_opensearchMapLayer.spec.js | 23 +++------ .../3_add_saved_object.spec.js | 25 +++------- .../4_documentsLayer.spec.js | 27 +++-------- .../5_add_map_to_dashboard.spec.js | 37 ++++++++++++++ .../6_geojson_file_upload.spec.js | 48 +++++++++++++++++++ package-lock.json | 20 ++++++++ package.json | 1 + 10 files changed, 172 insertions(+), 55 deletions(-) create mode 100644 cypress/fixtures/plugins/custom-import-map-dashboards/sample_geo.json create mode 100644 cypress/integration/plugins/custom-import-map-dashboards/0_add_saved_object.js create mode 100644 cypress/integration/plugins/custom-import-map-dashboards/5_add_map_to_dashboard.spec.js create mode 100644 cypress/integration/plugins/custom-import-map-dashboards/6_geojson_file_upload.spec.js diff --git a/cypress/fixtures/plugins/custom-import-map-dashboards/sample_geo.json b/cypress/fixtures/plugins/custom-import-map-dashboards/sample_geo.json new file mode 100644 index 000000000..6145026a5 --- /dev/null +++ b/cypress/fixtures/plugins/custom-import-map-dashboards/sample_geo.json @@ -0,0 +1,8 @@ +{ + "type": "FeatureCollection", + "name": "sample", + "features": [ + { "type": "Feature", "properties": { "iso2": "IN", "iso3": "IND", "name": "Abc" }, "geometry": { "type": "MultiPolygon", "coordinates": [[[[70.6640625,39.639537564366684],[69.78515625,37.020098201368114],[69.60937499999999,33.7243396617476],[69.9609375,29.99300228455108],[69.2578125,27.839076094777816],[69.60937499999999,26.588527147308614],[70.6640625,25.799891182088334],[70.13671875,24.206889622398023],[67.67578124999999,23.885837699862005],[69.78515625,21.616579336740603],[73.30078125,17.644022027872726],[75.76171875,13.581920900545844],[76.2890625,10.487811882056695],[77.51953125,8.233237111274565],[79.453125,11.178401873711785],[80.15625,16.97274101999902],[85.78125,19.973348786110602],[90.703125,21.616579336740603],[95.80078125,21.616579336740603],[96.85546875,26.27371402440643],[97.3828125,28.613459424004414],[92.98828125,30.14512718337613],[88.9453125,29.6880527498568],[83.84765625,30.14512718337613],[80.33203125,34.161818161230386],[81.2109375,37.020098201368114],[76.2890625,38.272688535980976],[71.54296874999999,39.774769485295465],[70.6640625,39.639537564366684]]]] } }, + { "type": "Feature", "properties": { "iso2": "CN", "iso3": "CHN", "name": "Xyz" }, "geometry": { "type": "MultiPolygon", "coordinates": [[ [ [ 113.36476, 22.1579 ], [ 113.35401, 22.13085 ], [ 113.33619, 22.10049 ], [ 113.31365, 22.0764 ], [ 113.28907, 22.06851 ], [ 113.27914, 22.07469 ], [ 113.26881, 22.08832 ], [ 113.26417, 22.10493 ], [ 113.27174, 22.12002 ], [ 113.27914, 22.1232 ], [ 113.28972, 22.12547 ], [ 113.29868, 22.12857 ], [ 113.30274, 22.13398 ], [ 113.30421, 22.14183 ], [ 113.30844, 22.14863 ], [ 113.31495, 22.154 ], [ 113.32309, 22.1579 ], [ 113.32797, 22.14582 ], [ 113.33546, 22.14887 ], [ 113.34718, 22.15644 ], [ 113.36476, 22.1579 ] ] ], [ [ [ 113.59352, 22.78482 ], [ 113.60288, 22.77245 ], [ 113.60279, 22.76264 ], [ 113.59457, 22.75609 ], [ 113.57984, 22.75373 ], [ 113.55828, 22.75788 ], [ 113.54461, 22.76878 ], [ 113.53566, 22.78433 ], [ 113.52858, 22.80215 ], [ 113.52117, 22.78791 ], [ 113.50611, 22.79804 ], [ 113.49529, 22.81387 ], [ 113.4808, 22.84931 ], [ 113.47397, 22.84931 ], [ 113.47316, 22.82538 ], [ 113.4559, 22.83076 ], [ 113.43409, 22.84907 ], [ 113.40211, 22.88288 ], [ 113.39617, 22.8981 ], [ 113.40512, 22.90811 ], [ 113.43295, 22.91201 ], [ 113.4756, 22.9007 ], [ 113.4878, 22.89281 ], [ 113.52703, 22.84663 ], [ 113.54672, 22.83487 ], [ 113.57301, 22.83006 ], [ 113.57643, 22.82392 ], [ 113.58766, 22.79462 ], [ 113.59352, 22.78482 ] ] ] ] } } + ] +} diff --git a/cypress/integration/plugins/custom-import-map-dashboards/0_add_saved_object.js b/cypress/integration/plugins/custom-import-map-dashboards/0_add_saved_object.js new file mode 100644 index 000000000..f3273f35a --- /dev/null +++ b/cypress/integration/plugins/custom-import-map-dashboards/0_add_saved_object.js @@ -0,0 +1,34 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { BASE_PATH } from '../../../utils/constants'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; +import { CURRENT_TENANT } from '../../../utils/commands'; + +const miscUtils = new MiscUtils(cy); + +describe('Add flights dataset saved object', () => { + before(() => { + CURRENT_TENANT.newTenant = 'global'; + cy.deleteAllIndices(); + miscUtils.addSampleData(); + cy.wait(10000); + }); + + after(() => { + miscUtils.removeSampleData(); + }); + + it('check if maps saved object of flights dataset can be found and open', () => { + cy.visit(`${BASE_PATH}/app/maps-dashboards`); + cy.contains( + '[Flights] Flights Status on Maps Destination Location' + ).click(); + cy.get('[data-test-subj="layerControlPanel"]').should( + 'contain', + 'Flights On Time' + ); + }); +}); diff --git a/cypress/integration/plugins/custom-import-map-dashboards/1_import_vector_map_tab.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/1_import_vector_map_tab.spec.js index 0099d7960..fb495b0bd 100644 --- a/cypress/integration/plugins/custom-import-map-dashboards/1_import_vector_map_tab.spec.js +++ b/cypress/integration/plugins/custom-import-map-dashboards/1_import_vector_map_tab.spec.js @@ -6,15 +6,17 @@ /// import { BASE_PATH } from '../../../utils/constants'; -import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; import { CURRENT_TENANT } from '../../../utils/commands'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; const miscUtils = new MiscUtils(cy); + describe('Verify the presence of import custom map tab in region map plugin', () => { before(() => { CURRENT_TENANT.newTenant = 'global'; cy.deleteAllIndices(); miscUtils.addSampleData(); + cy.wait(15000); // Load region map visualization with sample data opensearch_dashboards_sample_data_flights cy.visit( diff --git a/cypress/integration/plugins/custom-import-map-dashboards/2_opensearchMapLayer.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/2_opensearchMapLayer.spec.js index f2536f73b..c4f79a23d 100644 --- a/cypress/integration/plugins/custom-import-map-dashboards/2_opensearchMapLayer.spec.js +++ b/cypress/integration/plugins/custom-import-map-dashboards/2_opensearchMapLayer.spec.js @@ -5,21 +5,16 @@ import { BASE_PATH } from '../../../utils/constants'; import { CURRENT_TENANT } from '../../../utils/commands'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); describe('Default OpenSearch base map layer', () => { before(() => { CURRENT_TENANT.newTenant = 'global'; - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { - retryOnStatusCodeFailure: true, - timeout: 60000, - }); - cy.wait(5000); - cy.get('div[data-test-subj="sampleDataSetCardflights"]', { - timeout: 60000, - }) - .contains(/(Add|View) data/) - .click(); - cy.wait(60000); + cy.deleteAllIndices(); + miscUtils.addSampleData(); + cy.wait(15000); }); it('check if default OpenSearch map layer can be open', () => { @@ -49,10 +44,6 @@ describe('Default OpenSearch base map layer', () => { }); after(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); - cy.wait(5000); - cy.get('button[data-test-subj="removeSampleDataSetflights"]') - .should('be.visible') - .click(); + miscUtils.removeSampleData(); }); }); diff --git a/cypress/integration/plugins/custom-import-map-dashboards/3_add_saved_object.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/3_add_saved_object.spec.js index 2d8b29495..aa629653b 100644 --- a/cypress/integration/plugins/custom-import-map-dashboards/3_add_saved_object.spec.js +++ b/cypress/integration/plugins/custom-import-map-dashboards/3_add_saved_object.spec.js @@ -5,31 +5,20 @@ import { BASE_PATH } from '../../../utils/constants'; import { CURRENT_TENANT } from '../../../utils/commands'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); describe('Add flights dataset saved object', () => { before(() => { CURRENT_TENANT.newTenant = 'global'; - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { - retryOnStatusCodeFailure: true, - timeout: 60000, - }); - cy.wait(5000); - cy.get('div[data-test-subj="sampleDataSetCardflights"]', { - timeout: 60000, - }) - .contains(/Add data/) - .click(); - cy.wait(60000); + cy.deleteAllIndices(); + miscUtils.addSampleData(); + cy.wait(15000); }); after(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); - cy.wait(5000); - cy.get('button[data-test-subj="removeSampleDataSetflights"]', { - timeout: 120000, - }) - .should('be.visible') - .click(); + miscUtils.removeSampleData(); }); it('check if maps saved object of flights dataset can be found and open', () => { diff --git a/cypress/integration/plugins/custom-import-map-dashboards/4_documentsLayer.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/4_documentsLayer.spec.js index 07fe01765..012bf5598 100644 --- a/cypress/integration/plugins/custom-import-map-dashboards/4_documentsLayer.spec.js +++ b/cypress/integration/plugins/custom-import-map-dashboards/4_documentsLayer.spec.js @@ -5,21 +5,16 @@ import { BASE_PATH } from '../../../utils/constants'; import { CURRENT_TENANT } from '../../../utils/commands'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; + +const miscUtils = new MiscUtils(cy); describe('Documents layer', () => { before(() => { CURRENT_TENANT.newTenant = 'global'; - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, { - retryOnStatusCodeFailure: true, - timeout: 60000, - }); - cy.wait(5000); - cy.get('div[data-test-subj="sampleDataSetCardflights"]', { - timeout: 60000, - }) - .contains(/(Add|View) data/) - .click(); - cy.wait(60000); + cy.deleteAllIndices(); + miscUtils.addSampleData(); + cy.wait(15000); }); const uniqueName = 'saved-map-' + Date.now().toString(); @@ -76,10 +71,6 @@ describe('Documents layer', () => { cy.wait(30000); cy.visit(`${BASE_PATH}/app/maps-dashboards`); cy.wait(10000); - cy.get('[data-test-subj="mapListingPage"]', { timeout: 120000 }).should( - 'contain', - uniqueName - ); cy.contains(uniqueName).click(); cy.get('[data-test-subj="layerControlPanel"]').should( 'contain', @@ -88,10 +79,6 @@ describe('Documents layer', () => { }); after(() => { - cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`); - cy.wait(5000); - cy.get('button[data-test-subj="removeSampleDataSetflights"]') - .should('be.visible') - .click(); + miscUtils.removeSampleData(); }); }); diff --git a/cypress/integration/plugins/custom-import-map-dashboards/5_add_map_to_dashboard.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/5_add_map_to_dashboard.spec.js new file mode 100644 index 000000000..d143601c0 --- /dev/null +++ b/cypress/integration/plugins/custom-import-map-dashboards/5_add_map_to_dashboard.spec.js @@ -0,0 +1,37 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { BASE_PATH } from '../../../utils/constants'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; +import { CURRENT_TENANT } from '../../../utils/commands'; + +const miscUtils = new MiscUtils(cy); + +describe('Add map to dashboard', () => { + before(() => { + CURRENT_TENANT.newTenant = 'global'; + cy.deleteAllIndices(); + miscUtils.addSampleData(); + cy.wait(15000); + }); + + it('Add new map to dashboard', () => { + const testMapName = 'saved-map-' + Date.now().toString(); + cy.visit(`${BASE_PATH}/app/dashboards`); + cy.get('[data-test-subj="newItemButton"]').click(); + cy.get('button[data-test-subj="dashboardAddNewPanelButton"]').click(); + cy.get('button[data-test-subj="visType-customImportMap"]').click(); + cy.wait(5000).get('button[data-test-subj="mapSaveButton"]').click(); + cy.wait(5000).get('[data-test-subj="savedObjectTitle"]').type(testMapName); + cy.wait(5000) + .get('[data-test-subj="confirmSaveSavedObjectButton"]') + .click(); + cy.get('.embPanel__titleText').should('contain', testMapName); + }); + + after(() => { + miscUtils.removeSampleData(); + }); +}); diff --git a/cypress/integration/plugins/custom-import-map-dashboards/6_geojson_file_upload.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/6_geojson_file_upload.spec.js new file mode 100644 index 000000000..c98eeb7a7 --- /dev/null +++ b/cypress/integration/plugins/custom-import-map-dashboards/6_geojson_file_upload.spec.js @@ -0,0 +1,48 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { BASE_PATH } from '../../../utils/constants'; +import { CURRENT_TENANT } from '../../../utils/commands'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; +import 'cypress-file-upload'; + +const miscUtils = new MiscUtils(cy); + +describe('Verify successful custom geojson file upload', () => { + before(() => { + CURRENT_TENANT.newTenant = 'global'; + cy.deleteAllIndices(); + miscUtils.addSampleData(); + cy.wait(15000); + + // Load region map visualization with sample data opensearch_dashboards_sample_data_flights + cy.visit( + `${BASE_PATH}/app/visualize#/create?type=region_map&indexPattern=d3d7af60-4c81-11e8-b3d7-01146121b73d`, + { + retryOnStatusCodeFailure: true, + timeout: 60000, + } + ); + }); + + it('checks if the file uploaded successfully', () => { + // Click on "Import Vector Map" tab, which is part of customImportMap plugin + cy.contains('Import Vector Map').click({ force: true }); + + cy.get('[data-testId="filePicker"]').attachFile( + 'plugins/custom-import-map-dashboards/sample_geo.json' + ); + cy.get('[data-testId="customIndex"]').type('sample'); + cy.contains('Import file').click({ force: true }); + cy.contains( + 'Successfully added 2 features to sample-map. Refresh to visualize the uploaded map.', + { timeout: 240000 } + ); + }); + + after(() => { + miscUtils.removeSampleData(); + }); +}); diff --git a/package-lock.json b/package-lock.json index 5740ead3a..b2e54dae1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@faker-js/faker": "^7.6.0", "commander": "^9.4.1", "cypress": "9.5.4", + "cypress-file-upload": "^5.0.8", "cypress-multi-reporters": "^1.5.0", "cypress-real-events": "1.7.6", "eslint": "^7.0.0", @@ -939,6 +940,18 @@ "node": ">=12.0.0" } }, + "node_modules/cypress-file-upload": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz", + "integrity": "sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==", + "dev": true, + "engines": { + "node": ">=8.2.1" + }, + "peerDependencies": { + "cypress": ">3.0.0" + } + }, "node_modules/cypress-multi-reporters": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/cypress-multi-reporters/-/cypress-multi-reporters-1.5.0.tgz", @@ -4754,6 +4767,13 @@ } } }, + "cypress-file-upload": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz", + "integrity": "sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==", + "dev": true, + "requires": {} + }, "cypress-multi-reporters": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/cypress-multi-reporters/-/cypress-multi-reporters-1.5.0.tgz", diff --git a/package.json b/package.json index e8398d60d..59d66bc47 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "@faker-js/faker": "^7.6.0", "commander": "^9.4.1", "cypress": "9.5.4", + "cypress-file-upload": "^5.0.8", "cypress-multi-reporters": "^1.5.0", "cypress-real-events": "1.7.6", "eslint": "^7.0.0", From 34ba5be6db8f75e5da5e369b5311d3077f2ea521 Mon Sep 17 00:00:00 2001 From: Junqiu Lei Date: Fri, 30 Aug 2024 16:50:43 -0700 Subject: [PATCH 12/12] Add new home ui test for maps (#1542) Signed-off-by: Junqiu Lei --- .../5_add_map_to_dashboard.spec.js | 23 +++--- .../7_enable_new_home_ui.spec.js | 78 +++++++++++++++++++ 2 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 cypress/integration/plugins/custom-import-map-dashboards/7_enable_new_home_ui.spec.js diff --git a/cypress/integration/plugins/custom-import-map-dashboards/5_add_map_to_dashboard.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/5_add_map_to_dashboard.spec.js index d143601c0..98fe83183 100644 --- a/cypress/integration/plugins/custom-import-map-dashboards/5_add_map_to_dashboard.spec.js +++ b/cypress/integration/plugins/custom-import-map-dashboards/5_add_map_to_dashboard.spec.js @@ -4,8 +4,8 @@ */ import { BASE_PATH } from '../../../utils/constants'; -import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; import { CURRENT_TENANT } from '../../../utils/commands'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; const miscUtils = new MiscUtils(cy); @@ -17,21 +17,24 @@ describe('Add map to dashboard', () => { cy.wait(15000); }); + after(() => { + miscUtils.removeSampleData(); + }); + it('Add new map to dashboard', () => { const testMapName = 'saved-map-' + Date.now().toString(); - cy.visit(`${BASE_PATH}/app/dashboards`); - cy.get('[data-test-subj="newItemButton"]').click(); - cy.get('button[data-test-subj="dashboardAddNewPanelButton"]').click(); - cy.get('button[data-test-subj="visType-customImportMap"]').click(); + cy.visit(`${BASE_PATH}/app/dashboards#/create`); + cy.wait(5000) + .get('button[data-test-subj="addVisualizationButton"]') + .click(); + cy.wait(5000) + .get('button[data-test-subj="visType-customImportMap"]') + .click(); cy.wait(5000).get('button[data-test-subj="mapSaveButton"]').click(); cy.wait(5000).get('[data-test-subj="savedObjectTitle"]').type(testMapName); cy.wait(5000) .get('[data-test-subj="confirmSaveSavedObjectButton"]') .click(); - cy.get('.embPanel__titleText').should('contain', testMapName); - }); - - after(() => { - miscUtils.removeSampleData(); + cy.wait(5000).get('.embPanel__titleText').should('contain', testMapName); }); }); diff --git a/cypress/integration/plugins/custom-import-map-dashboards/7_enable_new_home_ui.spec.js b/cypress/integration/plugins/custom-import-map-dashboards/7_enable_new_home_ui.spec.js new file mode 100644 index 000000000..ec1d1d5ff --- /dev/null +++ b/cypress/integration/plugins/custom-import-map-dashboards/7_enable_new_home_ui.spec.js @@ -0,0 +1,78 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { BASE_PATH } from '../../../utils/constants'; +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; +import { CURRENT_TENANT } from '../../../utils/commands'; + +const miscUtils = new MiscUtils(cy); + +describe('Add flights dataset saved object', () => { + before(() => { + CURRENT_TENANT.newTenant = 'global'; + cy.deleteAllIndices(); + miscUtils.addSampleData(); + cy.wait(10000); + + // Enable the new home UI + cy.visit(`${BASE_PATH}/app/settings`); + cy.get( + '[data-test-subj="advancedSetting-editField-home:useNewHomePage"]' + ).then(($switch) => { + if ($switch.attr('aria-checked') === 'false') { + cy.wrap($switch).click(); + cy.get('[data-test-subj="advancedSetting-saveButton"]').click(); + cy.get('button.euiButton--primary.euiButton--small', { + timeout: 15000, + }).click(); + } else { + cy.log('The switch is already on.'); + } + }); + }); + + after(() => { + miscUtils.removeSampleData(); + // Disable the new home UI + cy.visit(`${BASE_PATH}/app/settings`); + cy.get( + '[data-test-subj="advancedSetting-editField-home:useNewHomePage"]' + ).then(($switch) => { + if ($switch.attr('aria-checked') === 'true') { + cy.wrap($switch).click(); + cy.get('[data-test-subj="advancedSetting-saveButton"]').click(); + cy.get('button.euiButton--primary.euiButton--small', { + timeout: 15000, + }).click(); + } else { + cy.log('The switch is already off.'); + } + }); + }); + + it('Verify component in maps listing page', () => { + cy.visit(`${BASE_PATH}/app/maps-dashboards`); + + // Verify the presence of the headerRightControl component + cy.get('[data-test-subj="headerRightControl"]').should('exist'); + + // Verify the presence of the maps createButton within the headerRightControl + cy.get('[data-test-subj="headerRightControl"]') + .find('[data-test-subj="createButton"]') + .should('exist'); + }); + + it('Verify component in maps visualization page', () => { + cy.visit(`${BASE_PATH}/app/maps-dashboards/create`); + + // Verify the presence of the top-nav component + cy.get('[data-test-subj="top-nav"]').should('exist'); + + // Verify the presence of the mapSaveButton inside the top-nav component + cy.get('[data-test-subj="top-nav"]') + .find('[data-test-subj="mapSaveButton"]') + .should('exist'); + }); +});