From 861ab7ec81c54aa4ae419d7c17aef4ad79ddc978 Mon Sep 17 00:00:00 2001 From: NandanAnantharamu <67676905+NandanAnantharamu@users.noreply.github.com> Date: Mon, 14 Jun 2021 19:29:13 +0530 Subject: [PATCH] Updated fork/duplicate test (#4923) * Updated test to handle version * updated test * added a small wait * Assertion updated * formatted code * fork test updated * dsl file added * Updated test * Try waiting in the addDsl step * Other fixes Co-authored-by: hetunandu --- app/client/cypress/fixtures/basicDsl.json | 1 + .../Applications/DuplicateApplication_spec.js | 31 +++++++++++++------ .../Applications/ForkApplication_spec.js | 29 +++++++++++------ app/client/cypress/support/commands.js | 1 + 4 files changed, 43 insertions(+), 19 deletions(-) create mode 100644 app/client/cypress/fixtures/basicDsl.json diff --git a/app/client/cypress/fixtures/basicDsl.json b/app/client/cypress/fixtures/basicDsl.json new file mode 100644 index 0000000000..a1a2ec69a7 --- /dev/null +++ b/app/client/cypress/fixtures/basicDsl.json @@ -0,0 +1 @@ +{"dsl":{"widgetName":"MainContainer","backgroundColor":"none","rightColumn":966,"snapColumns":64,"detachFromLayout":true,"widgetId":"0","topRow":0,"bottomRow":320,"containerStyle":"none","snapRows":125,"parentRowSpace":1,"type":"CANVAS_WIDGET","canExtend":true,"version":23,"minHeight":330,"parentColumnSpace":1,"dynamicBindingPathList":[],"leftColumn":0,"children":[{"isVisible":true,"inputType":"TEXT","label":"","widgetName":"Input1","version":1,"resetOnSubmit":true,"isRequired":false,"isDisabled":false,"type":"INPUT_WIDGET","isLoading":false,"parentColumnSpace":14.84375,"parentRowSpace":10,"leftColumn":23,"rightColumn":43,"topRow":8,"bottomRow":12,"parentId":"0","widgetId":"ihviqc47ev"}],"dynamicTriggerPathList":[]}} \ No newline at end of file diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js index 7cc05bf94f..c133dd319f 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/DuplicateApplication_spec.js @@ -1,22 +1,30 @@ -const dsl = require("../../../../fixtures/displayWidgetDsl.json"); +const dsl = require("../../../../fixtures/basicDsl.json"); const homePage = require("../../../../locators/HomePage.json"); const commonlocators = require("../../../../locators/commonlocators.json"); -const explorerlocators = require("../../../../locators/explorerlocators.json"); +const widgetsPage = require("../../../../locators/Widgets.json"); + let duplicateApplicationDsl; +let parentApplicationDsl; describe("Duplicate application", function() { before(() => { - dsl.dsl.version = 23; // latest migrated version cy.addDsl(dsl); }); it("Check whether the duplicate application has the same dsl as the original", function() { - cy.get(commonlocators.homeIcon).click({ force: true }); const appname = localStorage.getItem("AppName"); + cy.SearchEntityandOpen("Input1"); + cy.get(widgetsPage.defaultInput).type("A"); + cy.get(commonlocators.editPropCrossButton).click({ force: true }); + cy.wait("@updateLayout").then((httpResponse) => { + parentApplicationDsl = httpResponse.response.body.data.dsl; + }); + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(2000); + cy.NavigateToHome(); cy.get(homePage.searchInput).type(appname); // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(2000); - cy.get(homePage.applicationCard) .first() .trigger("mouseover"); @@ -24,17 +32,20 @@ describe("Duplicate application", function() { .first() .click({ force: true }); cy.get(homePage.duplicateApp).click({ force: true }); - + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(4000); cy.wait("@getPage").should( "have.nested.property", "response.body.responseMeta.status", 200, ); cy.get("@getPage").then((httpResponse) => { - const data = httpResponse.response.body.data; - duplicateApplicationDsl = data.layouts[0].dsl; - - expect(duplicateApplicationDsl).to.deep.equal(dsl.dsl); + duplicateApplicationDsl = httpResponse.response.body.data.layouts[0].dsl; + cy.log(JSON.stringify(duplicateApplicationDsl)); + cy.log(JSON.stringify(parentApplicationDsl)); + expect(JSON.stringify(duplicateApplicationDsl)).to.deep.equal( + JSON.stringify(parentApplicationDsl), + ); }); }); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js index 91f4ece082..1a33fcb0da 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ClientSideTests/Applications/ForkApplication_spec.js @@ -1,21 +1,30 @@ -const dsl = require("../../../../fixtures/displayWidgetDsl.json"); +const dsl = require("../../../../fixtures/basicDsl.json"); const homePage = require("../../../../locators/HomePage.json"); const commonlocators = require("../../../../locators/commonlocators.json"); +const widgetsPage = require("../../../../locators/Widgets.json"); + let forkedApplicationDsl; +let parentApplicationDsl; describe("Fork application across orgs", function() { before(() => { - dsl.dsl.version = 23; // latest migrated version cy.addDsl(dsl); }); it("Check if the forked application has the same dsl as the original", function() { - cy.get(commonlocators.homeIcon).click({ force: true }); const appname = localStorage.getItem("AppName"); + cy.SearchEntityandOpen("Input1"); + cy.get(widgetsPage.defaultInput).type("A"); + cy.get(commonlocators.editPropCrossButton).click({ force: true }); + cy.wait("@updateLayout").then((response) => { + parentApplicationDsl = response.response.body.data.dsl; + }); + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(2000); + cy.NavigateToHome(); cy.get(homePage.searchInput).type(appname); // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(2000); - cy.get(homePage.applicationCard) .first() .trigger("mouseover"); @@ -29,18 +38,20 @@ describe("Fork application across orgs", function() { .last() .click({ force: true }); cy.get(homePage.forkAppOrgButton).click({ force: true }); + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(4000); cy.wait("@postForkAppOrg").then((httpResponse) => { expect(httpResponse.status).to.equal(200); }); - cy.get("@getPage").then((httpResponse) => { - expect(httpResponse.status).to.deep.equal(200); - }); // check that forked application has same dsl cy.get("@getPage").then((httpResponse) => { const data = httpResponse.response.body.data; forkedApplicationDsl = data.layouts[0].dsl; - expect(forkedApplicationDsl).to.deep.equal(dsl.dsl); + cy.log(JSON.stringify(forkedApplicationDsl)); + cy.log(JSON.stringify(parentApplicationDsl)); + expect(JSON.stringify(forkedApplicationDsl)).to.contain( + JSON.stringify(parentApplicationDsl), + ); }); - cy.NavigateToHome(); }); }); diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index e467b7b416..5d7ead70f5 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -1645,6 +1645,7 @@ Cypress.Commands.add("addDsl", (dsl) => { }); }); }); + cy.wait("@updateLayout"); }); Cypress.Commands.add("DeleteAppByApi", () => {