From 98ad97753b0f8b9b08fae069103d0bb96f450bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNandanAnantharamu=E2=80=9D?= <“nandan@thinkify.io”> Date: Tue, 29 Oct 2024 19:49:56 +0530 Subject: [PATCH] test: fixed datepicker skipped tests set 2 --- .../Binding/DatePicker_Text_spec.js | 23 ++++++++----------- .../Widgets/Datepicker/DatePicker2_spec.js | 2 +- app/client/cypress/limited-tests.txt | 3 ++- app/client/cypress/locators/FormWidgets.json | 3 ++- app/client/cypress/support/commands.js | 12 +++++++--- app/client/cypress/support/widgetCommands.js | 2 +- 6 files changed, 25 insertions(+), 20 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/Binding/DatePicker_Text_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Binding/DatePicker_Text_spec.js index 037e637f8cd..13f28fdad2b 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Binding/DatePicker_Text_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Binding/DatePicker_Text_spec.js @@ -14,7 +14,7 @@ describe( _.agHelper.AddDsl("uiBindDsl"); }); // Skipping tests due to issue - https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=0717892d43684c40bae4e2c87b8308cb&pm=s - it.skip("1. DatePicker-Text, Validate selectedDate functionality", function () { + it("1. DatePicker-Text, Validate selectedDate functionality", function () { /** * Bind DatePicker1 to Text for "selectedDate" */ @@ -25,9 +25,8 @@ describe( * Set the Calender for today's date in DatePicker1 */ cy.openPropertyPane("datepickerwidget"); - cy.get(formWidgetsPage.defaultDate).click(); - cy.ClearDateFooter(); - cy.SetDateToToday(); + cy.get(formWidgetsPage.datepickerWidget).first().click(); + cy.get(formWidgetsPage.datepickerFooter).contains("Today").click(); cy.getDate(1, "YYYY-MM-DD").then((date) => { cy.log("retured date" + date); @@ -43,15 +42,14 @@ describe( cy.get(publishPage.datepickerWidget + commonlocators.inputField) .eq(0) .click(); - cy.ClearDateFooter(); - cy.setDate(1, "ddd MMM DD YYYY"); + cy.setDate(1, "ddd MMM DD YYYY", "v1"); cy.get(commonlocators.labelTextStyle).should("contain", nextDay); }); cy.get(commonlocators.backToEditor).click(); }); - it.skip("2. DatePicker1-text: Change the date in DatePicker1 and Validate the same in text widget", function () { + it("2. DatePicker1-text: Change the date in DatePicker1 and Validate the same in text widget", function () { cy.openPropertyPane("textwidget"); /** @@ -75,9 +73,9 @@ describe( */ cy.openPropertyPane("datepickerwidget"); cy.get(formWidgetsPage.defaultDate).click(); - cy.ClearDateFooter(); - cy.setDate(1, "ddd MMM DD YYYY"); - // cy.get(commonlocators.onDateSelectedField).click(); + cy.get(formWidgetsPage.dayPickerToday).click(); + cy.get(formWidgetsPage.defaultDate).click(); + cy.setDate(1); /** *Validate the date in text widget @@ -89,7 +87,7 @@ describe( }); }); - it.skip("3. Validate the Date is not changed in DatePicker2", function () { + it("3. Validate the Date is not changed in DatePicker2", function () { cy.log("dateDp2:" + dateDp2); cy.get(formWidgetsPage.datepickerWidget + commonlocators.inputField) .eq(1) @@ -124,7 +122,7 @@ describe( _.deployMode.NavigateBacktoEditor(); }); - it.skip("5. Checks if on deselection of date triggers the onDateSelected action or not.", function () { + it("5. Checks if on deselection of date triggers the onDateSelected action or not.", function () { /** * bind datepicker to show a message "Hello" on date selected */ @@ -135,7 +133,6 @@ describe( * checking if on selecting the date triggers the message */ cy.get(formWidgetsPage.datepickerWidget).first().click(); - cy.ClearDateFooter(); cy.SetDateToToday(); cy.get(commonlocators.toastmsg).contains("hello"); diff --git a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Datepicker/DatePicker2_spec.js b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Datepicker/DatePicker2_spec.js index af2714ccb72..74292b291b1 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Widgets/Datepicker/DatePicker2_spec.js +++ b/app/client/cypress/e2e/Regression/ClientSide/Widgets/Datepicker/DatePicker2_spec.js @@ -22,7 +22,7 @@ describe( it("DatePicker-Date Name validation", function () { // changing the date to today cy.get(formWidgetsPage.defaultDate).click(); - cy.SetDateToToday(); + cy.get(formWidgetsPage.dayPickerToday).click(); //changing the Button Name cy.widgetText( diff --git a/app/client/cypress/limited-tests.txt b/app/client/cypress/limited-tests.txt index 31c0c0253fe..3fda832e804 100644 --- a/app/client/cypress/limited-tests.txt +++ b/app/client/cypress/limited-tests.txt @@ -1,5 +1,6 @@ # To run only limited tests - give the spec names in below format: -cypress/e2e/Regression/ClientSide/Templates/Fork_Template_spec.js +cypress/e2e/Regression/ClientSide/Widgets/Datepicker/DatePicker2_spec.js +cypress/e2e/Regression/ClientSide/Binding/DatePicker_Text_spec.js # For running all specs - uncomment below: #cypress/e2e/**/**/* diff --git a/app/client/cypress/locators/FormWidgets.json b/app/client/cypress/locators/FormWidgets.json index db603de7b8c..43462381c2d 100644 --- a/app/client/cypress/locators/FormWidgets.json +++ b/app/client/cypress/locators/FormWidgets.json @@ -78,5 +78,6 @@ "minDateTextArea" : ".t--property-control-mindate .CodeMirror textarea", "minDateInput" : ".t--property-control-mindate .ads-v2-input__input-section-input", "datePickerInput": ".t--widget-datepickerwidget2 .bp3-input", - "dayPickerNextButton": ".DayPicker-NavButton--next" + "dayPickerNextButton": ".DayPicker-NavButton--next", + "dayPickerToday": ".ads-v2-datepicker__calender-today" } diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 19c28a5b372..f9a2a09e576 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -524,9 +524,15 @@ Cypress.Commands.add("getDate", (date, dateFormate) => { return eDate; }); -Cypress.Commands.add("setDate", (date) => { - const expDate = dayjs().add(date, "days").format("dddd, MMMM DD"); - cy.get(`.react-datepicker__day[aria-label^="Choose ${expDate}"]`).click(); +Cypress.Commands.add("setDate", (date, dateFormate, ver = "v2") => { + if (ver == "v2") { + const expDate = dayjs().add(date, "days").format("dddd, MMMM DD"); + cy.get(`.react-datepicker__day[aria-label^="Choose ${expDate}"]`).click(); + } else if (ver == "v1") { + const expDate = dayjs().add(date, "days").format(dateFormate); + const sel = `.DayPicker-Day[aria-label=\"${expDate}\"]`; + cy.get(sel).click(); + } }); Cypress.Commands.add("validateDisableWidget", (widgetCss, disableCss) => { diff --git a/app/client/cypress/support/widgetCommands.js b/app/client/cypress/support/widgetCommands.js index fd0772748f6..4ff5489802e 100644 --- a/app/client/cypress/support/widgetCommands.js +++ b/app/client/cypress/support/widgetCommands.js @@ -837,7 +837,7 @@ Cypress.Commands.add("selectWidgetForReset", (value) => { }); Cypress.Commands.add("SetDateToToday", () => { - cy.get(".react-datepicker .react-datepicker__day--today").click({ + cy.get(".DayPicker-Day--today").click({ force: true, }); agHelper.AssertAutoSave();