From 005c8077eb2c574fe0f5ecc0b5f7284eaf3ca24b Mon Sep 17 00:00:00 2001 From: arslanhaiderbuttar <83570904+arslanhaiderbuttar@users.noreply.github.com> Date: Thu, 17 Jun 2021 18:47:54 +0500 Subject: [PATCH] Add commands in Command.js Add commands in Command.js copyWidget, deleteWidget --- app/client/cypress/support/commands.js | 36 +++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index d8602d442e..fa7ed5d087 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -2053,7 +2053,7 @@ Cypress.Commands.add("executeDbQuery", (queryName) => { }); Cypress.Commands.add("CreateMockQuery", (queryName) => { - cy.get(queryEditor.addNewQueryBtn).click({ force: true }); + // cy.get(queryEditor.addNewQueryBtn).click({ force: true }); cy.get(queryEditor.createQuery) .first() .click({ force: true }); @@ -2160,6 +2160,40 @@ Cypress.Commands.add("onClickActions", (forSuccess, forFailure) => { .contains(forFailure) .click(); }); + +Cypress.Commands.add("copyWidget", (widget, widgetLocator) => { + const modifierKey = Cypress.platform === "darwin" ? "meta" : "ctrl"; + //Copy widget and verify all properties + cy.get(widgetsPage.propertypaneText) + .children() + .last() + .invoke("text") + .then((originalWidget) => { + cy.log(originalWidget); + cy.get(widgetsPage.copyWidget).click(); + cy.reload(); + // Wait for the widget to be appear in the DOM and press Ctrl/Cmd + V to paste the button. + cy.get(widgetLocator).should("be.visible"); + cy.get("body").type(`{${modifierKey}}v`); + cy.wait(2000); + cy.openPropertyPaneCopy(widget); + cy.get(widgetsPage.propertypaneText) + .children() + .last() + .invoke("text") + .then((copiedWidget) => { + cy.log(copiedWidget); + expect(originalWidget).to.be.equal(copiedWidget); + }); + }); +}); + +Cypress.Commands.add("deleteWidget", (widget) => { + // Delete the button widget + cy.get(widgetsPage.removeWidget).click(); + cy.get(widgetsPage.deleteToast).should("have.text", "UNDO"); +}); + Cypress.Commands.add("createAndFillApi", (url, parameters) => { cy.NavigateToApiEditor(); cy.testCreateApiButton();