From 688ef8e65e219fedbd15dd5863d8ae8b4f40c942 Mon Sep 17 00:00:00 2001 From: "leanne.laceybyrne@eliatra.com" Date: Mon, 6 Nov 2023 07:57:17 +0100 Subject: [PATCH 1/5] copy link lint fix Signed-off-by: leanne.laceybyrne@eliatra.com --- .../security-dashboards-plugin/copy_link.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cypress/integration/plugins/security-dashboards-plugin/copy_link.js diff --git a/cypress/integration/plugins/security-dashboards-plugin/copy_link.js b/cypress/integration/plugins/security-dashboards-plugin/copy_link.js new file mode 100644 index 000000000..66a87944e --- /dev/null +++ b/cypress/integration/plugins/security-dashboards-plugin/copy_link.js @@ -0,0 +1,19 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { STACK_MANAGEMENT_PATH } from '../../../utils/dashboards/constants'; + +if (Cypress.env('SECURITY_ENABLED')) { + describe('Copy Link functionality working ', () => { + it('Tests the link copys and can be routed to in Safari ', () => { + cy.visit(STACK_MANAGEMENT_PATH); + cy.waitForLoader(); + cy.getElementByTestId('toggleNavButton').click(); + cy.get('span[title="Discover"]').click(); + cy.getElementByTestId('shareTopNavButton').click(); + cy.getElementByTestId('copyShareUrlButton').click(); + }); + }); +} From b013db3226d77ac54e9a6a5346ff2e5aba570a5a Mon Sep 17 00:00:00 2001 From: "leanne.laceybyrne@eliatra.com" Date: Mon, 6 Nov 2023 13:51:48 +0100 Subject: [PATCH 2/5] testing visit to copyed link works Signed-off-by: leanne.laceybyrne@eliatra.com --- .../integration/plugins/security-dashboards-plugin/copy_link.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/integration/plugins/security-dashboards-plugin/copy_link.js b/cypress/integration/plugins/security-dashboards-plugin/copy_link.js index 66a87944e..881c960a0 100644 --- a/cypress/integration/plugins/security-dashboards-plugin/copy_link.js +++ b/cypress/integration/plugins/security-dashboards-plugin/copy_link.js @@ -14,6 +14,7 @@ if (Cypress.env('SECURITY_ENABLED')) { cy.get('span[title="Discover"]').click(); cy.getElementByTestId('shareTopNavButton').click(); cy.getElementByTestId('copyShareUrlButton').click(); + cy.window().its('navigator.clipboard').invoke('readText').then(cy.visit); }); }); } From 04d435883fd46a3d7568dd0a7f339da082fbce65 Mon Sep 17 00:00:00 2001 From: "leanne.laceybyrne@eliatra.com" Date: Mon, 13 Nov 2023 18:27:38 +0000 Subject: [PATCH 3/5] copy from clipboard and visit copied link Signed-off-by: leanne.laceybyrne@eliatra.com --- .../security-dashboards-plugin/copy_link.js | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/cypress/integration/plugins/security-dashboards-plugin/copy_link.js b/cypress/integration/plugins/security-dashboards-plugin/copy_link.js index 881c960a0..268f6ff29 100644 --- a/cypress/integration/plugins/security-dashboards-plugin/copy_link.js +++ b/cypress/integration/plugins/security-dashboards-plugin/copy_link.js @@ -2,19 +2,39 @@ * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ - import { STACK_MANAGEMENT_PATH } from '../../../utils/dashboards/constants'; if (Cypress.env('SECURITY_ENABLED')) { - describe('Copy Link functionality working ', () => { - it('Tests the link copys and can be routed to in Safari ', () => { + describe('Copy Link functionality working', () => { + it('Tests the link copys and can be routed to in Safari', () => { cy.visit(STACK_MANAGEMENT_PATH); cy.waitForLoader(); cy.getElementByTestId('toggleNavButton').click(); cy.get('span[title="Discover"]').click(); cy.getElementByTestId('shareTopNavButton').click(); cy.getElementByTestId('copyShareUrlButton').click(); - cy.window().its('navigator.clipboard').invoke('readText').then(cy.visit); + + // Capture the copied content + cy.window().then((win) => { + // Access the clipboard contents + cy.document().then((doc) => { + cy.wait(1000); // Wait for clipboard data to be available + cy.log('Trying to read clipboard data...'); + + // Read the clipboard text + cy.wrap(win.navigator.clipboard.readText()).then((clipboardData) => { + cy.log('url copied:', clipboardData); + + // Assert that the clipboard has data + expect(clipboardData).to.have.length.greaterThan(0); + + cy.visit(clipboardData); + cy.waitForLoader(); + + // Now on the page referred to by the copied URL + }); + }); + }); }); }); } From 58ce580e960218f1e16dc3bc3833117caa97c7d8 Mon Sep 17 00:00:00 2001 From: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> Date: Tue, 14 Nov 2023 21:50:37 +0000 Subject: [PATCH 4/5] Update copy_link.js Signed-off-by: leanneeliatra <131779422+leanneeliatra@users.noreply.github.com> --- .../plugins/security-dashboards-plugin/copy_link.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/integration/plugins/security-dashboards-plugin/copy_link.js b/cypress/integration/plugins/security-dashboards-plugin/copy_link.js index 268f6ff29..b955145c5 100644 --- a/cypress/integration/plugins/security-dashboards-plugin/copy_link.js +++ b/cypress/integration/plugins/security-dashboards-plugin/copy_link.js @@ -17,7 +17,7 @@ if (Cypress.env('SECURITY_ENABLED')) { // Capture the copied content cy.window().then((win) => { // Access the clipboard contents - cy.document().then((doc) => { + cy.document().then(() => { cy.wait(1000); // Wait for clipboard data to be available cy.log('Trying to read clipboard data...'); @@ -31,7 +31,7 @@ if (Cypress.env('SECURITY_ENABLED')) { cy.visit(clipboardData); cy.waitForLoader(); - // Now on the page referred to by the copied URL + // Now on copied URL page }); }); }); From 57131536fc137eaf012801d1c103e59bdfc355f0 Mon Sep 17 00:00:00 2001 From: "leanne.laceybyrne@eliatra.com" Date: Fri, 17 Nov 2023 13:40:48 +0000 Subject: [PATCH 5/5] renamed copy_link and moved file location Signed-off-by: leanne.laceybyrne@eliatra.com --- .../opensearch-dashboards/dashboard_share_copy_link_test.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cypress/integration/{plugins/security-dashboards-plugin/copy_link.js => core-opensearch-dashboards/opensearch-dashboards/dashboard_share_copy_link_test.js} (100%) diff --git a/cypress/integration/plugins/security-dashboards-plugin/copy_link.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_share_copy_link_test.js similarity index 100% rename from cypress/integration/plugins/security-dashboards-plugin/copy_link.js rename to cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_share_copy_link_test.js