From 31ca9461999f1abc134bc748a3709ed898ab922c Mon Sep 17 00:00:00 2001 From: rashminagarajp Date: Fri, 15 May 2020 17:50:09 +0530 Subject: [PATCH] ressolved comments --- app/client/cypress/fixtures/example.json | 3 +- .../Binding/Bind_DatePicker_Text_spec.js | 50 ++++++++++++++----- .../Binding/Bind_tableApi_spec.js | 19 ++++--- .../FormWidgets/DatePicker_spec.js | 14 ++++-- app/client/cypress/locators/ApiEditor.json | 3 +- app/client/cypress/locators/FormWidgets.json | 3 +- .../cypress/locators/commonlocators.json | 3 +- app/client/cypress/support/commands.js | 36 ++++++++++--- app/client/cypress/support/index.js | 2 + 9 files changed, 99 insertions(+), 34 deletions(-) diff --git a/app/client/cypress/fixtures/example.json b/app/client/cypress/fixtures/example.json index 47dc71d630..ad78f8329c 100644 --- a/app/client/cypress/fixtures/example.json +++ b/app/client/cypress/fixtures/example.json @@ -15,5 +15,6 @@ "DatepickerLable": "date", "RichTextEditorName": "RichtextEditor", "HtmlText": "This is the initialcontent

This is a Heading

This is a paragraph.

", - "RichTexteditorBody": "Here is the text area to edit html" + "RichTexteditorBody": "Here is the text area to edit html", + "userApi": "http://postgrest.appsmith.com:3000" } \ No newline at end of file diff --git a/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_DatePicker_Text_spec.js b/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_DatePicker_Text_spec.js index 5712db5d26..064e0065d1 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_DatePicker_Text_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_DatePicker_Text_spec.js @@ -4,31 +4,55 @@ const widgetsPage = require("../../../locators/Widgets.json"); const dsl = require("../../../fixtures/uibindingdsl.json"); describe("Binding the Datepicker and Text Widget", function() { + let nextDay; + let dateDp2; before(() => { cy.addDsl(dsl); }); - it("Bind the date picker in text widget", function() { + it("DatePicker1-text: Change the date in DatePicker1 and Validate the same in text widget", function() { cy.openPropertyPane("textwidget"); - //Changing the text on the text widget - cy.testCodeMirror("{{DatePicker1.defaultDate}}"); + /** + * Bind the datepicker1 to text widget + */ + cy.testJsontext("text", "{{DatePicker1.defaultDate}}"); cy.get(commonlocators.editPropCrossButton).click(); - }); - it("Change the date in datePicker1 and validate the same in text widget", function() { - // changing the date to today + /** + * Fetching the date on DatePicker2 + */ + + cy.get(formWidgetsPage.datepickerWidget + " .bp3-input") + .eq(1) + .invoke("val") + .then(val => { + dateDp2 = val; + cy.log(dateDp2); + }); + + /** + * Changing date on datepicker1 to current date +1 + */ + cy.openPropertyPane("datepickerwidget"); cy.SetDateToToday(); - - //Changing date on date picker1 to current date +1 - cy.get(".DayPicker-Day[aria-selected='true'] + div").click(); - cy.get(".t--property-control-ondateselected").click(); + cy.get(formWidgetsPage.nextDayBtn).click(); + cy.get(commonlocators.onDateSelectedField).click(); cy.get(commonlocators.editPropCrossButton).click(); - //Validate the changes in text widget - const nd = Cypress.moment() + /** + *Validate the date in text widget + */ + + nextDay = Cypress.moment() .add(1, "days") .format("YYYY-MM-DD"); - cy.get(commonlocators.labelTextStyle).should("contain", nd); + cy.get(commonlocators.labelTextStyle).should("contain", nextDay); + }); + + it("Validate the Date is not changed in DatePicker2", function() { + cy.get(formWidgetsPage.datepickerWidget + " .bp3-input") + .eq(1) + .should("have.value", dateDp2); }); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_tableApi_spec.js b/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_tableApi_spec.js index e67b1d391c..ea60db8e6b 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_tableApi_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/Binding/Bind_tableApi_spec.js @@ -1,6 +1,7 @@ const commonlocators = require("../../../locators/commonlocators.json"); const dsl = require("../../../fixtures/tableWidgetDsl.json"); const pages = require("../../../locators/Pages.json"); +const apiPage = require("../../../locators/ApiEditor.json"); let apiData; describe("Test Create Api and Bind to Table widget", function() { @@ -14,11 +15,10 @@ describe("Test Create Api and Bind to Table widget", function() { }); it("Test_Add users api and execute api", function() { - // localStorage.setItem("ApiPaneV2", "ApiPaneV2"); cy.NavigateToApiEditor(); cy.testCreateApiButton(); - cy.createApi("http://postgrest.appsmith.com:3000", "users"); - cy.get(".CodeMirror-code span.cm-string.cm-property") + cy.createApi(this.data.userApi, "users"); + cy.get(apiPage.responseBody) .contains("name") .siblings("span") .invoke("text") @@ -27,14 +27,19 @@ describe("Test Create Api and Bind to Table widget", function() { apiData = text; cy.log("val1:" + apiData); }); - }); - - it("Test_Validate the Api data is updated on Table widget", function() { + }); + + it("Test_Validate the Api data is updated on Table widget", function() { cy.get(pages.pagesIcon).click({ force: true }); cy.openPropertyPane("tablewidget"); - cy.testCodeMirror("{{Api1.data}}"); + cy.testJsontext("tabledata", "{{Api1.data}}"); cy.wait("@updateLayout"); cy.get(commonlocators.editPropCrossButton).click(); + + /** + * readTabledata--> is to read the table contents + * @param --> "row num" and "col num" + */ cy.readTabledata("0", "1").then(tabData => { expect(apiData).to.eq(`\"${tabData}\"`); }); 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 6e73493a56..84f6e4af7a 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/FormWidgets/DatePicker_spec.js @@ -8,16 +8,24 @@ describe("DatePicker Widget Functionality", function() { }); it("DatePicker Widget Functionality", function() { - - // changing the date to today + cy.openPropertyPane("datepickerwidget"); + // changing the date to today cy.SetDateToToday(); + //changing the Button Name + cy.widgetText( + this.data.Datepickername, + formWidgetsPage.datepickerWidget, + formWidgetsPage.datepickerWidget + " pre", + ); + //Checking the edit props for DatePicker and also the properties of DatePicker widget cy.testCodeMirror(this.data.DatepickerLable); + cy.wait("@updateLayout"); // change the date to next day cy.get(".t--property-control-defaultdate input").click(); - cy.get(".DayPicker-Day[aria-selected='true'] + div").click(); + cy.get(formWidgetsPage.nextDayBtn).click(); const nd = Cypress.moment() .add(1, "days") .format("DD/MM/YYYY"); diff --git a/app/client/cypress/locators/ApiEditor.json b/app/client/cypress/locators/ApiEditor.json index 3ae8fd7d0d..1d5244da53 100644 --- a/app/client/cypress/locators/ApiEditor.json +++ b/app/client/cypress/locators/ApiEditor.json @@ -11,5 +11,6 @@ "addToPageBtnsId": ".t--addToPageButtons", "ApiHomePage": ".t--apiHomePage", "formActionButtons": ".t--formActionButtons", - "dataSourceField": ".t--dataSourceField" + "dataSourceField": ".t--dataSourceField", + "responseBody":".CodeMirror-code span.cm-string.cm-property" } diff --git a/app/client/cypress/locators/FormWidgets.json b/app/client/cypress/locators/FormWidgets.json index fdcef1d862..4783153c1b 100644 --- a/app/client/cypress/locators/FormWidgets.json +++ b/app/client/cypress/locators/FormWidgets.json @@ -8,5 +8,6 @@ "filepickerWidget":".t--draggable-filepickerwidget", "formWidget":".t--draggable-formwidget", "richTextEditorWidget":".t--draggable-richtexteditorwidget", - "richEditorOnTextChange":".t--property-control-ontextchange" + "richEditorOnTextChange":".t--property-control-ontextchange", + "nextDayBtn": ".DayPicker-Day[aria-selected='true'] + div.DayPicker-Day" } \ No newline at end of file diff --git a/app/client/cypress/locators/commonlocators.json b/app/client/cypress/locators/commonlocators.json index 4b48c96a7a..6ad4bd819a 100644 --- a/app/client/cypress/locators/commonlocators.json +++ b/app/client/cypress/locators/commonlocators.json @@ -12,6 +12,7 @@ "bodyTextStyle":".bp3-running-text span", "headingTextStyle":".bp3-heading span", "editWidgetName":".bp3-editable-text", - "dropDownIcon":".t--property-control-textstyle span.bp3-icon-chevron-down" + "dropDownIcon":".t--property-control-textstyle span.bp3-icon-chevron-down", + "onDateSelectedField":".t--property-control-ondateselected" } \ No newline at end of file diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 829955056a..bf676e2c18 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -376,15 +376,37 @@ Cypress.Commands.add("testCodeMirror", value => { parseSpecialCharSequences: false, }); // cy.wait("@updateLayout"); - // commenting below line's, hence which effets the text area which is having js fun - /*cy.get(".CodeMirror textarea") + cy.get(".CodeMirror textarea") .first() - .should("have.value", value); */ + .should("have.value", value); }); }); +Cypress.Commands.add("testJsontext", (endp, value) => { + cy.get(".t--property-control-" + endp + " .CodeMirror textarea") + .first() + .focus({ force: true }) + .type("{uparrow}", { force: true }) + .type("{ctrl}{shift}{downarrow}", { force: true }); + cy.focused().then($cm => { + if ($cm.val() !== "") { + cy.get(".CodeMirror textarea") + .first() + .clear({ + force: true, + }); + cy.wait("@updateLayout"); + } + cy.get(".CodeMirror textarea") + .first() + .type(value, { + force: true, + parseSpecialCharSequences: false, + }); + }); +}); + Cypress.Commands.add("SetDateToToday", () => { - cy.openPropertyPane("datepickerwidget"); cy.get(".t--property-control-defaultdate input").click(); cy.get(".bp3-datepicker-footer span") .contains("Today") @@ -659,9 +681,9 @@ Cypress.Commands.add("createApi", (url, parameters) => { force: true, }); cy.get(".CodeMirror.CodeMirror-empty textarea") - .first() - .click({ force: true }) - .type(parameters, { force: true }); + .first() + .click({ force: true }) + .type(parameters, { force: true }); cy.SaveAPI(); cy.get(ApiEditor.formActionButtons).should("be.visible"); cy.get(ApiEditor.ApiRunBtn).should("not.be.disabled"); diff --git a/app/client/cypress/support/index.js b/app/client/cypress/support/index.js index 32be4a565c..a7b4d1359e 100644 --- a/app/client/cypress/support/index.js +++ b/app/client/cypress/support/index.js @@ -98,6 +98,8 @@ before(function() { }); beforeEach(function() { + cy.server(); + cy.route("PUT", "/api/v1/layouts/*/pages/*").as("updateLayout"); Cypress.Cookies.preserveOnce("SESSION", "remember_token"); });