-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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: fix datepicker tests #37042
test: fix datepicker tests #37042
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -524,10 +524,9 @@ Cypress.Commands.add("getDate", (date, dateFormate) => { | |||||||||||||
return eDate; | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
Cypress.Commands.add("setDate", (date, dateFormate) => { | ||||||||||||||
const expDate = dayjs().add(date, "days").format(dateFormate); | ||||||||||||||
const sel = `.DayPicker-Day[aria-label=\"${expDate}\"]`; | ||||||||||||||
cy.get(sel).click(); | ||||||||||||||
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(); | ||||||||||||||
Comment on lines
+527
to
+529
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider making the date format configurable. The hardcoded date format "dddd, MMMM DD" reduces flexibility. Consider keeping the format parameter to support different date formats across tests. -Cypress.Commands.add("setDate", (date) => {
+Cypress.Commands.add("setDate", (date, dateFormat = "dddd, MMMM DD") => {
const expDate = dayjs()
.add(date, "days")
- .format("dddd, MMMM DD");
+ .format(dateFormat);
cy.get(`.react-datepicker__day[aria-label^="Choose ${expDate}"]`).click();
}); 📝 Committable suggestion
Suggested change
|
||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
Cypress.Commands.add("validateDisableWidget", (widgetCss, disableCss) => { | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Update required:
setDate
command usage is inconsistent with implementationThe current implementation of
setDate
only accepts a single parameter for days offset, but there are multiple occurrences in the codebase where it's called with two parameters. This needs to be fixed:DatePicker_With_Switch_spec.js
: UsessetDate(1, "ddd MMM DD YYYY")
DatePicker_Text_spec.js
: Two instances usingsetDate(1, "ddd MMM DD YYYY")
These calls need to be updated to match the current implementation which only accepts the days offset parameter.
🔗 Analysis chain
Verify the impact of simplified setDate command.
The setDate command has been simplified to use a single parameter. Ensure this change is consistent with the command implementation.
Let me check the implementation of the
setDate
command to verify if the simplified usage is correct.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 889
Script:
Length of output: 941