-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Migrate 'datepicker' e2e tests to Playwright #57545
Conversation
await expect( | ||
page.getByRole( 'button', { name: 'Change date' } ) | ||
).toContainText( /^[A-Za-z]+\s\d{1,2},\s\d{1,4}/ ); |
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.
@kevin940726, @WunderBart, what do you think about this assertion? Would it suffice? 😅
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.
I think it might be easier to just parse the date 😆. Something like...
const dateString = await page.getByRole( 'button', { name: 'Change date' } ).textContent();
const date = new Date( dateString );
expect( date ).toEqual( datePickerDate );
We can keep the regex to test the format once if we want to.
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.
Thanks for the example; I'll try it out later.
P.S. My understanding of this test is that they just assert that the date label switches from Immediately
to an actual date. In my opinion, it shouldn't really matter if the date string matches.
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.
Tried the suggested path, but Date
fails to parse the string returned by a locator.
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.
Judged from the test case, I think it's also asserting that the date in the datepicker is the same as the one shown on the button. Not sure if it matters though!
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.
I believe unit tests cover exact date assertions for the date-time
components. Doing something similar usually ends up in ugly e2e test code 😅
Should we land the current migration version or try to make date assertions happen?
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.
If it's already covered by unit tests then absolutely! TBH, I think all of these cases can be tested in unit/integration tests 😆. I was just being conservative 😅.
Size Change: 0 B Total Size: 1.69 MB ℹ️ View Unchanged
|
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.
💯
Thanks for the feedback and review, @kevin940726 🙇 |
What?
Part of #38851.
PR migrates
datepicker.test.js
e2e tests to Playwright.Why?
See #38851.
Testing Instructions