Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fixed datepicker skipped tests set 2 #37126

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
*/
Expand All @@ -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);
Expand All @@ -43,15 +42,15 @@ describe(
cy.get(publishPage.datepickerWidget + commonlocators.inputField)
.eq(0)
.click();
cy.ClearDateFooter();
cy.setDate(1, "ddd MMM DD YYYY");
cy.SetDateToToday();
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");

/**
Expand All @@ -75,9 +74,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
Expand All @@ -89,7 +88,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)
Expand Down Expand Up @@ -124,7 +123,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
*/
Expand All @@ -135,7 +134,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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add explicit element readiness check before click.

Add visibility check before clicking to ensure element is ready for interaction.

- cy.get(formWidgetsPage.dayPickerToday).click();
+ cy.get(formWidgetsPage.dayPickerToday)
+   .should('be.visible')
+   .click();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cy.get(formWidgetsPage.dayPickerToday).click();
cy.get(formWidgetsPage.dayPickerToday)
.should('be.visible')
.click();


//changing the Button Name
cy.widgetText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ describe(
cy.closePropertyPane();
});
// Skipping tests due to issue - https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=0717892d43684c40bae4e2c87b8308cb&pm=s
it.skip("Date Widget with Reset widget being switch widget", function () {
it("Date Widget with Reset widget being switch widget", function () {
EditorNavigation.SelectEntityByName("DatePicker1", EntityType.Widget);

cy.get(formWidgetsPage.datePickerInput).click();
_.agHelper.GetNClick(widgetsPage.todayText)
cy.get(formWidgetsPage.defaultDate).click();
_.agHelper.GetNClick('.ads-v2-datepicker__calender-today');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Refactor selectors and remove redundant interactions

  1. Replace the class selector .ads-v2-datepicker__calender-today with a data-* attribute
  2. Remove redundant clicks on defaultDate element

Apply this refactor:

  cy.get(formWidgetsPage.datePickerInput).click();
  _.agHelper.GetNClick(widgetsPage.todayText)
- cy.get(formWidgetsPage.defaultDate).click();
- _.agHelper.GetNClick('.ads-v2-datepicker__calender-today');
  cy.get(formWidgetsPage.defaultDate).click();

Committable suggestion was skipped due to low confidence.

cy.get(formWidgetsPage.defaultDate).click();
cy.SetDateToToday();
cy.setDate(1, "ddd MMM DD YYYY");
const nextDay = dayjs().format("DD/MM/YYYY");
cy.log(nextDay);
Expand All @@ -51,18 +54,10 @@ describe(
cy.get(widgetsPage.switchWidgetInactive).should("be.visible");
});

it.skip("DatePicker-Date change and validate switch widget status", function () {
it("DatePicker-Date change and validate switch widget status", function () {
cy.get(widgetsPage.datepickerInput).click({ force: true });
cy.SetDateToToday();
cy.get(widgetsPage.switchWidgetActive).should("be.visible");
cy.get(".t--toast-action span")
.last()
.invoke("text")
.then((text) => {
const toasttext = text;
cy.log(toasttext);
expect(text.trim()).to.equal(toasttext.trim());
});
_.agHelper.GetNClick(widgetsPage.todayText)
_.agHelper.AssertClassExists('.bp3-switch', 't--switch-widget-active')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove force click and update selectors

  1. Remove force: true and handle any visibility issues properly
  2. Replace class selectors with data-* attributes for better test stability

Apply these changes:

- cy.get(widgetsPage.datepickerInput).click({ force: true });
+ cy.get(widgetsPage.datepickerInput).should('be.visible').click();
  _.agHelper.GetNClick(widgetsPage.todayText)
- _.agHelper.AssertClassExists('.bp3-switch', 't--switch-widget-active')
+ _.agHelper.AssertClassExists('[data-testid="switch-widget"]', 't--switch-widget-active')

Committable suggestion was skipped due to low confidence.

});
},
);
Expand Down
Loading
Loading