From 1cc3899ad470a17f49998dc3f1d7e17e02daae68 Mon Sep 17 00:00:00 2001 From: Sagar Khalasi Date: Mon, 13 Jan 2025 10:43:55 +0530 Subject: [PATCH] fix: Fix copy issue in embedsetting spec (#38590) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description RCA: Found the copy the clipboard is not working in chrome. Have enabled spec specific permission for copy and the store the cypress variable in local variable to get firm run results. Fixes # https://app.zenhub.com/workspaces/qa-63316faf86bb2e170ed2e46b/issues/gh/appsmithorg/appsmith/38589 ## Automation /ok-to-test tags="@tag.Settings" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: e1903dbd34f17722bf798e4a79687cb6201a78ed > Cypress dashboard. > Tags: `@tag.Settings` > Spec: >
Mon, 13 Jan 2025 05:11:28 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No ## Summary by CodeRabbit - **Tests** - Updated clipboard handling in end-to-end testing - Improved clipboard permission and content retrieval for test scenarios --- .../EmbedSettings/EmbedSettings_spec.js | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/EmbedSettings/EmbedSettings_spec.js b/app/client/cypress/e2e/Regression/ClientSide/EmbedSettings/EmbedSettings_spec.js index d139fd045d7..5502737bd61 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/EmbedSettings/EmbedSettings_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/EmbedSettings/EmbedSettings_spec.js @@ -18,6 +18,8 @@ describe("Embed settings options", { tags: ["@tag.Settings"] }, function () { ); }; + let clipboardData; + function ValidateEditModeSetting(setting) { _.deployMode.NavigateBacktoEditor(); _.embedSettings.OpenEmbedSettings(); @@ -31,6 +33,7 @@ describe("Embed settings options", { tags: ["@tag.Settings"] }, function () { } before(() => { + _.agHelper.GiveChromeCopyPermission(); _.homePage.NavigateToHome(); _.homePage.CreateNewApplication(); _.entityExplorer.DragDropWidgetNVerify(_.draggableWidgets.IFRAME); @@ -48,9 +51,22 @@ describe("Embed settings options", { tags: ["@tag.Settings"] }, function () { .click() .wait(1000); _.agHelper.ClickButton("Copy application url"); + cy.window().then((win) => { - cy.stub(win.navigator.clipboard, "writeText").as("deployUrl").resolves(); + new Cypress.Promise((resolve, reject) => { + win.navigator.clipboard.readText().then(resolve).catch(reject); + }).then((text) => { + clipboardData = text; // Store the clipboard content in a variable + cy.log(`Clipboard Content: ${clipboardData}`); // Log clipboard content + expect(clipboardData).to.equal("Expected clipboard text"); // Add assertions if needed + }); }); + + // Log clipboard data after it's been set + cy.then(() => { + cy.log(`Stored Clipboard Data: ${clipboardData}`); + }); + cy.enablePublicAccess(); cy.wait(8000); //adding wait time for iframe to load fully! _.agHelper.RefreshPage(); @@ -67,10 +83,8 @@ describe("Embed settings options", { tags: ["@tag.Settings"] }, function () { cy.get(adminSettings.saveButton).click(); cy.waitForServerRestart(); _.agHelper.Sleep(2000); - cy.get("@deployUrl").then((depUrl) => { - cy.log("deployUrl is " + depUrl); - cy.visit(depUrl, { timeout: 60000 }); - }); + + cy.visit(clipboardData, { timeout: 60000 }); getIframeBody().contains("Submit").should("exist"); ValidateEditModeSetting(_.embedSettings.locators._restrictedText); // }); @@ -84,10 +98,7 @@ describe("Embed settings options", { tags: ["@tag.Settings"] }, function () { cy.get(adminSettings.saveButton).click(); cy.waitForServerRestart(); _.agHelper.Sleep(2000); - cy.get("@deployUrl").then((depUrl) => { - cy.log("deployUrl is " + depUrl); - cy.visit(depUrl, { timeout: 60000 }); - }); + cy.visit(clipboardData, { timeout: 60000 }); getIframeBody().contains("Submit").should("exist"); ValidateEditModeSetting(_.embedSettings.locators._allowAllText); // }); @@ -98,13 +109,11 @@ describe("Embed settings options", { tags: ["@tag.Settings"] }, function () { cy.get(".t--admin-settings-APPSMITH_ALLOWED_FRAME_ANCESTORS").within(() => { cy.get("input").last().click(); }); + cy.get(adminSettings.saveButton).click(); cy.waitForServerRestart(); _.agHelper.Sleep(2000); - cy.get("@deployUrl").then((depUrl) => { - cy.log("deployUrl is " + depUrl); - cy.visit(depUrl, { timeout: 60000 }); - }); + cy.visit(clipboardData, { timeout: 60000 }); getIframeBody().contains("Submit").should("not.exist"); ValidateEditModeSetting(_.embedSettings.locators._disabledText);