diff --git a/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_share_copy_link_test.js b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_share_copy_link_test.js new file mode 100644 index 000000000..b955145c5 --- /dev/null +++ b/cypress/integration/core-opensearch-dashboards/opensearch-dashboards/dashboard_share_copy_link_test.js @@ -0,0 +1,40 @@ +/* + * 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(); + + // Capture the copied content + cy.window().then((win) => { + // Access the clipboard contents + cy.document().then(() => { + 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 copied URL page + }); + }); + }); + }); + }); +}