diff --git a/app/client/cypress/fixtures/example.json b/app/client/cypress/fixtures/example.json index da18d9352a..47dc71d630 100644 --- a/app/client/cypress/fixtures/example.json +++ b/app/client/cypress/fixtures/example.json @@ -1,5 +1,19 @@ { "name": "Using fixtures to represent data", "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" + "body": "Fixtures are a great way to mock data for responses to routes", + "ButtonLabel": "Test Button", + "ButtonName": "Submitbutton", + "AlertModalName": "Alert_Modal", + "FormModalName": "Form_Modal", + "TextLabelValue": "Test Text Label", + "TextName": "TestTextBox", + "TextLabel": "Label", + "TextBody": "Body", + "TextHeading": "Heading", + "Datepickername": "Datepicker", + "DatepickerLable": "date", + "RichTextEditorName": "RichtextEditor", + "HtmlText": "This is the initialcontent
This is a paragraph.
", + "RichTexteditorBody": "Here is the text area to edit html" } \ No newline at end of file diff --git a/app/client/cypress/fixtures/formdsl1.json b/app/client/cypress/fixtures/formdsl1.json new file mode 100644 index 0000000000..1eb938642a --- /dev/null +++ b/app/client/cypress/fixtures/formdsl1.json @@ -0,0 +1,119 @@ +{ + "dsl": { + "widgetName": "MainContainer", + "backgroundColor": "none", + "rightColumn": 1224, + "snapColumns": 16, + "detachFromLayout": true, + "widgetId": "0", + "topRow": 0, + "bottomRow": 1254, + "containerStyle": "none", + "snapRows": 33, + "parentRowSpace": 1, + "type": "CANVAS_WIDGET", + "canExtend": true, + "dynamicBindings": {}, + "version": 3, + "minHeight": 1292, + "parentColumnSpace": 1, + "leftColumn": 0, + "children": [ + { + "backgroundColor": "#FFFFFF", + "widgetName": "Container3", + "type": "CONTAINER_WIDGET", + "containerStyle": "card", + "isVisible": true, + "isLoading": false, + "parentColumnSpace": 75.25, + "parentRowSpace": 38, + "dynamicBindings": {}, + "leftColumn": 0, + "rightColumn": 16, + "topRow": 1, + "bottomRow": 23, + "snapColumns": 16, + "orientation": "VERTICAL", + "children": [ + { + "backgroundColor": "transparent", + "widgetName": "6gcpyqo8my", + "type": "CANVAS_WIDGET", + "containerStyle": "none", + "isVisible": true, + "isLoading": false, + "parentColumnSpace": 1, + "parentRowSpace": 1, + "leftColumn": 0, + "rightColumn": 1204, + "topRow": 0, + "bottomRow": 532, + "snapColumns": 16, + "orientation": "VERTICAL", + "children": [ + { + "isVisible": true, + "isDisabled": false, + "datePickerType": "DATE_PICKER", + "dateFormat": "DD/MM/YYYY", + "label": "Date", + "widgetName": "DatePicker1", + "defaultDate": "2020-05-07T10:52:14.548+05:30", + "type": "DATE_PICKER_WIDGET", + "isLoading": false, + "parentColumnSpace": 71.75, + "parentRowSpace": 38, + "leftColumn": 1, + "rightColumn": 8, + "topRow": 13, + "bottomRow": 14, + "parentId": "7tkpo9s22m", + "widgetId": "4y9j8f6kg2" + }, + { + "isVisible": true, + "text": "Submit", + "buttonStyle": "PRIMARY_BUTTON", + "widgetName": "Button1", + "isDisabled": false, + "isDefaultClickDisabled": true, + "type": "BUTTON_WIDGET", + "isLoading": false, + "parentColumnSpace": 71.75, + "parentRowSpace": 38, + "leftColumn": 12, + "rightColumn": 14, + "topRow": 9, + "bottomRow": 10, + "parentId": "7tkpo9s22m", + "widgetId": "nlzw81fc9u" + }, + { + "isVisible": true, + "defaultText": "This is the initial content of the editor", + "isDisabled": false, + "widgetName": "RichTextEditor1", + "isDefaultClickDisabled": true, + "type": "RICH_TEXT_EDITOR_WIDGET", + "isLoading": false, + "parentColumnSpace": 71.75, + "parentRowSpace": 38, + "leftColumn": 3, + "rightColumn": 11, + "topRow": 2, + "bottomRow": 7, + "parentId": "7tkpo9s22m", + "widgetId": "6h8j08u7ea" + } + ], + "widgetId": "7tkpo9s22m", + "detachFromLayout": true, + "canExtend": false + } + ], + "widgetId": "8xlprxx5pe" + } + ] + } + } \ No newline at end of file diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Search_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Search_spec.js index 3bc0ee7a02..6d1cb11118 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Search_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Search_spec.js @@ -3,13 +3,13 @@ const testdata = require("../../../fixtures/testdata.json"); describe("API Panel Test Functionality ", function() { it("Test Search API fetaure", function() { cy.log("Login Successful"); - cy.viewport('macbook-15'); //To avoid screen Resize issues + cy.viewport("macbook-15"); //To avoid screen Resize issues cy.NavigateToAPI_Panel(); cy.log("Navigation to API Panel screen successful"); cy.CreateAPI("FirstAPI"); cy.log("Creation of FirstAPI Action successful"); cy.CreateAPI("SecondAPI"); cy.log("Creation of SecondAPI Action successful"); - cy.SearchAPI("SecondAPI","FirstAPI"); + cy.SearchAPI("SecondAPI", "FirstAPI"); }); -}); \ No newline at end of file +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_With_Headers_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_With_Headers_spec.js index 492f99be33..3a48b346c6 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_With_Headers_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_With_Headers_spec.js @@ -4,12 +4,17 @@ const testdata = require("../../../fixtures/testdata.json"); describe("API Panel Test Functionality ", function() { it("Test GET Action for mock API with header", function() { cy.log("Login Successful"); - cy.viewport('macbook-15'); + cy.viewport("macbook-15"); cy.NavigateToAPI_Panel(); cy.log("Navigation to API Panel screen successful"); cy.CreateAPI("TestAPINew"); cy.log("Creation of API Action successful"); - cy.EnterSourceDetailsWithHeader(testdata.baseUrl,testdata.methods,testdata.headerKey,testdata.headerValue); + cy.EnterSourceDetailsWithHeader( + testdata.baseUrl, + testdata.methods, + testdata.headerKey, + testdata.headerValue, + ); cy.ResponseStatusCheck(testdata.successStatusCode); cy.log("Response code check successful"); cy.ResponseCheck(testdata.responsetext); diff --git a/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Button_spec.js b/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Button_spec.js index b4c84570e4..fbe5aad335 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Button_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Button_spec.js @@ -1,6 +1,7 @@ const widgetsPage = require("../../../locators/Widgets.json"); const commonlocators = require("../../../locators/commonlocators.json"); const dsl = require("../../../fixtures/commondsl.json"); +const homePage = require("../../../locators/HomePage.json"); describe("Button Widget Functionality", function() { beforeEach(() => { @@ -11,24 +12,42 @@ describe("Button Widget Functionality", function() { cy.get(".t--nav-link-widgets-editor").click(); cy.openPropertyPane("buttonwidget"); + //changing the Button Name + cy.widgetText( + this.data.ButtonName, + widgetsPage.buttonWidget, + widgetsPage.buttonWidget + " pre", + ); + //Changing the text on the Button - cy.testCodeMirror("Test Button Text"); + cy.testCodeMirror(this.data.ButtonLabel); + cy.xpath(homePage.homePageID).contains("All changes saved"); - //Select and verify the Show Modal from the onClick dropdown - cy.get(widgetsPage.buttonOnClick) - .get(commonlocators.dropdownSelectButton) - .click({ force: true }) - .get("ul.bp3-menu") - .children() - .contains("Show Modal") - .click(); - cy.get(widgetsPage.buttonOnClick) - .get(commonlocators.dropdownSelectButton) - .find(".bp3-button-text") - .should("have.text", "Show Modal"); + //Verify the Button name and label + cy.get(widgetsPage.buttonWidget).trigger("mouseover"); + cy.get(widgetsPage.buttonWidget + " span.bp3-button-text").should( + "have.text", + this.data.ButtonLabel, + ); - //Verify Modal Widget - cy.CreateModal(); + //Check the disableed checkbox and Validate + cy.CheckWidgetProperties(commonlocators.disableCheckbox); + cy.get(widgetsPage.buttonWidget + " .bp3-minimal.bp3-disabled").should( + "exist", + ); + + // //UnCheck the disabled checkbox and validate + cy.UnCheckWidgetProperties(commonlocators.disableCheckbox); + cy.get(widgetsPage.buttonWidget + " .bp3-minimal.bp3-disabled").should( + "not.exist", + ); + + //creating the Alert Modal and verify Modal name + cy.createModal("Alert Modal", this.data.AlertModalName); + + //creating the Form Modal and verify Modal name + cy.openPropertyPane("buttonwidget"); + cy.createModal("Form Modal", this.data.FormModalName); }); afterEach(() => { diff --git a/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Text_spec.js b/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Text_spec.js index 0322a37790..4d1cc10ab7 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Text_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Text_spec.js @@ -1,5 +1,6 @@ const commonlocators = require("../../../locators/commonlocators.json"); const dsl = require("../../../fixtures/commondsl.json"); +const widgetsPage = require("../../../locators/Widgets.json"); describe("Text Widget Functionality", function() { beforeEach(() => { @@ -9,8 +10,35 @@ describe("Text Widget Functionality", function() { it("Text Widget Functionality", function() { cy.openPropertyPane("textwidget"); - //Changing the text on the text widget - cy.testCodeMirror("Test text"); + //Changing the text label + cy.testCodeMirror(this.data.TextLabelValue); + + //changing the Text Name and verifying + cy.widgetText( + this.data.TextName, + widgetsPage.textWidget, + widgetsPage.textWidget + " pre", + ); + + //Changing the Text Style's and validating + cy.ChangeTextStyle( + this.data.TextLabel, + commonlocators.labelTextStyle, + this.data.TextLabelValue, + ); + + cy.ChangeTextStyle( + this.data.TextBody, + commonlocators.bodyTextStyle, + this.data.TextLabelValue, + ); + + cy.ChangeTextStyle( + this.data.TextHeading, + commonlocators.headingTextStyle, + this.data.TextLabelValue, + ); + cy.get(commonlocators.editPropCrossButton).click(); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_spec.js b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_spec.js index 877ca018df..0396785d3f 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_spec.js @@ -11,7 +11,54 @@ describe("DatePicker Widget Functionality", function() { cy.openPropertyPane("datepickerwidget"); //Checking the edit props for DatePicker and also the properties of DatePicker widget - cy.testCodeMirror("From Date"); + cy.testCodeMirror(this.data.DatepickerLable); + + // changing the date to today + cy.SetDateToToday(); + + // change the date to next day + cy.get(".t--property-control-defaultdate input").click(); + cy.get(".DayPicker-Day[aria-selected='true'] + div").click(); + const nd = Cypress.moment() + .add(1, "days") + .format("DD/MM/YYYY"); + cy.log(nd); + + //Validating the Date + cy.get(formWidgetsPage.datepickerWidget + " .bp3-input").should( + "contain.value", + nd, + ); + + // Check the required checkbox + cy.CheckWidgetProperties(commonlocators.requiredCheckbox); + cy.get(formWidgetsPage.datepickerWidget + " .bp3-label").should( + "contain.text", + "date *", + ); + + // UnCheck the required checkbox + cy.UnCheckWidgetProperties(commonlocators.requiredCheckbox); + cy.get(formWidgetsPage.datepickerWidget + " .bp3-label").should( + "contain.text", + "date", + ); + + // Check the visible checkbox + cy.CheckWidgetProperties(commonlocators.visibleCheckbox); + + //Check the Disabled checkbox + cy.CheckWidgetProperties(commonlocators.disableCheckbox); + cy.get( + formWidgetsPage.datepickerWidget + " .bp3-input-group.bp3-disabled", + ).should("exist"); + + //UnCheck the Disabled checkbox + cy.UnCheckWidgetProperties(commonlocators.disableCheckbox); + cy.get( + formWidgetsPage.datepickerWidget + " .bp3-input-group.bp3-disabled", + ).should("not.exist"); + cy.get(commonlocators.editPropCrossButton).click(); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/RichTextEditor_spec.js b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/RichTextEditor_spec.js index 3f48467d10..d9842bbffa 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/RichTextEditor_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/RichTextEditor_spec.js @@ -1,6 +1,7 @@ const commonlocators = require("../../../locators/commonlocators.json"); const formWidgetsPage = require("../../../locators/FormWidgets.json"); -const dsl = require("../../../fixtures/formdsl.json"); +const dsl = require("../../../fixtures/formdsl1.json"); +const homePage = require("../../../locators/HomePage.json"); describe("RichTextEditor Widget Functionality", function() { beforeEach(() => { @@ -9,19 +10,51 @@ describe("RichTextEditor Widget Functionality", function() { it("RichTextEditor Widget Functionality", function() { cy.openPropertyPane("richtexteditorwidget"); - //Checking the edit props for RichTextEditor and also the properties of RichTextEditor widget - cy.get(formWidgetsPage.richEditorOnTextChange) - .get(commonlocators.dropdownSelectButton) - .click({ force: true }) - .get("ul.bp3-menu") - .children() - .contains("Navigate To") - .click(); - cy.get(formWidgetsPage.richEditorOnTextChange) - .get(commonlocators.dropdownSelectButton) - .find("> span") - .eq(0) - .should("have.text", "Navigate To"); + //changing the Text Name + cy.widgetText( + this.data.RichTextEditorName, + formWidgetsPage.richTextEditorWidget, + formWidgetsPage.richTextEditorWidget + " pre", + ); + + //Edit the text area with Html + cy.testCodeMirror(this.data.HtmlText); + + //Validating Html + cy.get(formWidgetsPage.richTextEditorWidget + " iframe").then($iframe => { + const $body = $iframe.contents().find("body"); + cy.wrap($body) + .find("h1") + .should("have.text", "This is a Heading"); + }); + + //Edit the text area with Plain text + cy.testCodeMirror(this.data.RichTexteditorBody); + + //Validating Plain text + cy.get(formWidgetsPage.richTextEditorWidget + " iframe").then($iframe => { + const $body = $iframe.contents().find("body"); + cy.wrap($body) + .find("p") + .should("contain.text", this.data.RichTexteditorBody); + }); + + //Check the Disabled checkbox + cy.CheckWidgetProperties( + ".t--property-control-disable input[type='checkbox']", + ); + cy.get( + formWidgetsPage.richTextEditorWidget + " button[disabled='disabled']", + ).should("exist"); + + //UnCheck the Disabled checkbox + cy.UnCheckWidgetProperties( + ".t--property-control-disable input[type='checkbox']", + ); + cy.get( + formWidgetsPage.richTextEditorWidget + " button[disabled='disabled']", + ).should("not.exist"); + cy.get(commonlocators.editPropCrossButton).click(); }); diff --git a/app/client/cypress/locators/ModalWidget.json b/app/client/cypress/locators/ModalWidget.json index ef3fec17e7..48314b877a 100644 --- a/app/client/cypress/locators/ModalWidget.json +++ b/app/client/cypress/locators/ModalWidget.json @@ -2,6 +2,7 @@ "selectModal":".t--open-dropdown-Select-Modal", "createModalButton":".t--create-modal-btn", "controlModalType": ".t--property-control-modaltype", - "modalWidget":".t--modal-widget" + "modalWidget":".t--modal-widget", + "modalName":".t--modal-widget >div>pre" } \ No newline at end of file diff --git a/app/client/cypress/locators/Widgets.json b/app/client/cypress/locators/Widgets.json index 881b518c44..0a6e9058b2 100644 --- a/app/client/cypress/locators/Widgets.json +++ b/app/client/cypress/locators/Widgets.json @@ -11,6 +11,6 @@ "dropdownSelectButton":".t--open-dropdown-Select", "buttonOnClick": ".t--property-control-onclick", "deleteWidget":".t--modal-widget>div .t--widget-delete-control", - "textbuttonWidget":"button.bp3-button[type='button']" + "textbuttonWidget":".t--draggable-buttonwidget button.bp3-button[type='button']" } \ No newline at end of file diff --git a/app/client/cypress/locators/commonlocators.json b/app/client/cypress/locators/commonlocators.json index 07f2047337..4b48c96a7a 100644 --- a/app/client/cypress/locators/commonlocators.json +++ b/app/client/cypress/locators/commonlocators.json @@ -3,5 +3,15 @@ "editPropCrossButton":".t--property-pane-close-btn", "deleteWidgetIcon":".t--widget-delete-control", "dropdownSelectButton":".t--open-dropdown-Select-Action", - "homeIcon":".bp3-icon.bp3-icon-home" + "homeIcon":".bp3-icon.bp3-icon-home", + "typeWidgetName":".bp3-editable-text-editing>input", + "requiredCheckbox":".t--property-control-required input[type='checkbox']", + "visibleCheckbox":".t--property-control-visible input[type='checkbox']", + "disableCheckbox":".t--property-control-disabled input[type='checkbox']", + "labelTextStyle":".bp3-ui-text span", + "bodyTextStyle":".bp3-running-text span", + "headingTextStyle":".bp3-heading span", + "editWidgetName":".bp3-editable-text", + "dropDownIcon":".t--property-control-textstyle span.bp3-icon-chevron-down" + } \ No newline at end of file diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index d7e46476c8..3071fbd716 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -7,6 +7,7 @@ const commonlocators = require("../locators/commonlocators.json"); const queryEditor = require("../locators/QueryEditor.json"); const modalWidgetPage = require("../locators/ModalWidget.json"); const widgetsPage = require("../locators/Widgets.json"); +const formWidgetsPage = require("../locators/FormWidgets.json"); const ApiEditor = require("../locators/ApiEditor.json"); const apiwidget = require("../locators/apiWidgetslocator.json"); const method = "(//pre//span)[2]"; @@ -254,37 +255,6 @@ Cypress.Commands.add("DeleteAPI", apiname => { ); }); -// Cypress.Commands.add("NavigateToCommonWidgets", () => { -// cy.get(pages.pagesIcon).click({ force: true }); -// cy.get(pages.commonWidgets) -// .find(">div") -// .click({ force: true }); -// cy.get("#loading").should("not.exist"); -// cy.get(pages.widgetsEditor).click(); -// cy.wait("@getPage"); -// cy.get("#loading").should("not.exist"); -// }); - -// Cypress.Commands.add("NavigateToFormWidgets", () => { -// cy.get(pages.pagesIcon).click({ force: true }); -// cy.get(pages.formWidgets) -// .find(">div") -// .click({ force: true }); -// cy.get("#loading").should("not.exist"); -// cy.get(pages.widgetsEditor).click(); -// cy.get("#loading").should("not.exist"); -// }); - -// Cypress.Commands.add("NavigateToViewWidgets", () => { -// cy.get(pages.pagesIcon).click({ force: true }); -// cy.get(pages.viewWidgets) -// .find(">div") -// .click({ force: true }); -// cy.get("#loading").should("not.exist"); -// cy.get(pages.widgetsEditor).click(); -// cy.get("#loading").should("not.exist"); -// }); - Cypress.Commands.add("CreateModal", () => { cy.get(modalWidgetPage.selectModal).click(); cy.get(modalWidgetPage.createModalButton).click({ force: true }); @@ -302,6 +272,73 @@ Cypress.Commands.add("CreateModal", () => { cy.reload(); }); +Cypress.Commands.add("createModal", (modalType, ModalName) => { + cy.get(widgetsPage.buttonOnClick) + .get(commonlocators.dropdownSelectButton) + .click({ force: true }) + .get("ul.bp3-menu") + .children() + .contains("Show Modal") + .click(); + cy.get(modalWidgetPage.selectModal).click(); + cy.get(modalWidgetPage.createModalButton).click({ force: true }); + + cy.get(modalWidgetPage.controlModalType) + .find(".bp3-button") + .click({ force: true }) + .get("ul.bp3-menu") + .children() + .contains(modalType) + .click(); + cy.xpath(homePage.homePageID).contains("All changes saved"); + + // changing the model name verify + cy.widgetText( + ModalName, + modalWidgetPage.modalName, + modalWidgetPage.modalName, + ); + cy.get(commonlocators.editPropCrossButton).click(); + cy.reload(); +}); + +Cypress.Commands.add("CheckWidgetProperties", checkBoxTypeCss => { + cy.get(checkBoxTypeCss).check({ + force: true, + }); + cy.xpath(homePage.homePageID).contains("All changes saved"); +}); + +Cypress.Commands.add("UnCheckWidgetProperties", checkBoxTypeCss => { + cy.get(checkBoxTypeCss).uncheck({ + force: true, + }); + cy.xpath(homePage.homePageID).contains("All changes saved"); +}); + +Cypress.Commands.add( + "ChangeTextStyle", + (dropDownValue, textStylecss, labelName) => { + cy.get(commonlocators.dropDownIcon).click(); + cy.get("ul.bp3-menu") + .children() + .contains(dropDownValue) + .click(); + cy.get(textStylecss).should("have.text", labelName); + }, +); + +Cypress.Commands.add("widgetText", (text, inputcss, innercss) => { + cy.get(commonlocators.editWidgetName) + .dblclick({ force: true }) + .type(text) + .type("{enter}"); + cy.get(inputcss) + .first() + .trigger("mouseover", { force: true }); + cy.get(innercss).should("have.text", text); +}); + Cypress.Commands.add("PublishtheApp", () => { cy.xpath(homePage.homePageID).contains("All changes saved"); cy.get(homePage.publishButton).click(); @@ -345,6 +382,21 @@ Cypress.Commands.add("testCodeMirror", value => { }); }); +Cypress.Commands.add("SetDateToToday", () => { + cy.get(formWidgetsPage.datepickerWidget) + .first() + .trigger("mouseover"); + cy.get(formWidgetsPage.datepickerWidget) + .children(commonlocators.editicon) + .first() + .click({ force: true }); + cy.get(".t--property-control-defaultdate input").click(); + cy.get(".bp3-datepicker-footer span") + .contains("Today") + .click(); + cy.xpath(homePage.homePageID).contains("All changes saved"); +}); + Cypress.Commands.add("DeleteModal", () => { cy.get(widgetsPage.textbuttonWidget).dblclick("topRight", { force: true }); cy.get(widgetsPage.deleteWidget) @@ -397,30 +449,44 @@ Cypress.Commands.add("addDsl", dsl => { //Fetch the layout id cy.server(); - cy.request("GET", "https://dev.appsmith.com/api/v1/pages/" + pageid).then( - response => { - const len = JSON.stringify(response.body); - cy.log(len); - layoutId = JSON.parse(len).data.layouts[0].id; + cy.request("GET", "api/v1/pages/" + pageid).then(response => { + const len = JSON.stringify(response.body); + cy.log(len); + layoutId = JSON.parse(len).data.layouts[0].id; - // Dumpimg the DSL to the created page + // Dumpimg the DSL to the created page - cy.request( - "PUT", - "https://dev.appsmith.com/api/v1/layouts/" + - layoutId + - "/pages/" + - pageid, - dsl, - ).then(response => { - expect(response.status).equal(200); - cy.reload(); - }); - }, - ); + cy.request( + "PUT", + "api/v1/layouts/" + layoutId + "/pages/" + pageid, + dsl, + ).then(response => { + expect(response.status).equal(200); + cy.reload(); + }); + }); }); }); +Cypress.Commands.add("DeleteAppByApi", () => { + let currentURL; + let appId; + cy.url().then(url => { + currentURL = url; + const myRegexp = /applications(.*)/; + const match = myRegexp.exec(currentURL); + appId = match[1].split("/")[1]; + cy.log(appId + "appId"); + cy.request("DELETE", "api/v1/applications/" + appId).then(response => { + expect(response.status).equal(200); + }); + }); +}); + +Cypress.Commands.add("NavigateToDatasourceEditor", () => { + cy.get(datasourceEditor.datasourceEditorIcon).click({ force: true }); +}); + Cypress.Commands.add("getPluginFormsAndCreateDatasource", () => { cy.wait("@getPluginForm").should( "have.nested.property", diff --git a/app/client/cypress/support/index.js b/app/client/cypress/support/index.js index cc0b90d5d0..32be4a565c 100644 --- a/app/client/cypress/support/index.js +++ b/app/client/cypress/support/index.js @@ -80,6 +80,7 @@ before(function() { cy.route("PUT", "/api/v1/actions/*").as("saveQuery"); cy.LogintoApp(loginData.username, loginData.password); + // cy.SearchApp(inputData.appname) cy.generateUUID().then(id => { appId = id; cy.CreateApp(id); @@ -91,14 +92,21 @@ before(function() { cy.NavigateToWidgets(pageid); }); - beforeEach(function() { - Cypress.Cookies.preserveOnce("SESSION"); - }); - - after(function() { - // ---commenting Publish app and Delete page as of now--- // - //cy.Deletepage(pageid); - //cy.PublishtheApp(); - cy.DeleteApp(appId); + cy.fixture("example").then(function(data) { + this.data = data; }); }); + +beforeEach(function() { + Cypress.Cookies.preserveOnce("SESSION", "remember_token"); +}); + +after(function() { + // ---commenting Publish app and Delete page as of now--- // + + //cy.Deletepage(pageid); + //cy.PublishtheApp(); + //cy.DeleteApp(appId); + //-- Deleting the application by Api---// + cy.DeleteAppByApi(); +});