-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
chore: upgrade Playwright #15089
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
chore: upgrade Playwright #15089
Conversation
|
| await page.goto('/routing/hashes/a'); | ||
|
|
||
| await clicknav('[href="#hash-target"]'); | ||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a#hash-target`); |
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 don't think you should have to change these lines because clicknav does a waitForNavigation. If that's not working it's probably better to fix it inside clicknav so that there's a only a single location that needs to be updated
kit/packages/kit/test/utils.js
Line 36 in 85a57a0
| await Promise.all([page.waitForNavigation(options), element.click()]); |
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 even if we updated clicknav it would still have to be updated to accept the "expected URL" as the second parameter. waitForNavigation probably won't ever be reliable (see microsoft/playwright#20853).
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.
Ah, interesting! It's so dumb that they have an API that is discouraged and not deprecated at the same time 😝
Doing something along the lines of microsoft/playwright#20853 (comment) would make a lot of sense. We already do something similar with body.started:
kit/packages/kit/test/utils.js
Line 117 in 85a57a0
| await page.waitForSelector('body.started', { timeout: 15000 }); |
Perhaps we could change from a boolean body.started to a timestamp body.lastNav or something along those lines. It'd keep the API on the caller's side much simpler
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 don't think that'll work as it won't actually work for clientside navs (it relies on window being destroyed and recreated during the nav). That being said maybe it could wait on afterNavigation or something?
For now I'm adding waitForURL as an option to it, which will make it significantly more reliable in the case where you're going clicknav(/* I want to go to a location, and wait until I've arrived at that location */)
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.
Yeah, it looks like we probably have access to afterNavigate:
kit/packages/kit/test/utils.js
Line 20 in 85a57a0
| afterNavigate: () => page.evaluate(() => afterNavigate(() => {})), |
I'd really much prefer a solution using that as I think it'd be much easier to author tests that way. It's also something that I imagine could then be followed as a pattern in end user apps
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 don't actually think it'll work, unfortunately -- it has to be linked to a component lifecycle
packages/kit/test/apps/basics/test/cross-platform/client.test.js
Outdated
Show resolved
Hide resolved
packages/kit/test/apps/basics/test/cross-platform/client.test.js
Outdated
Show resolved
Hide resolved
Rich-Harris
left a comment
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.
LGTM pending a full bank of green lights
| await page.goto('/routing/hashes/a'); | ||
|
|
||
| await clicknav('[href="#preload"]'); | ||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a#preload`); |
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'm not entirely sure we should remove these expect lines. perhaps the current waitForURL implementation checks that, but I'd like to fix this up so that we don't use waitForURL and I'm afraid it'd be easy to miss that we're no longer expecting anything while making that change
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 we're asserting that we've arrived at a URL, waitForURL is superior to expect(page.url()).toBe(...). It throws a helpful message after the configured timeout if the URL is never arrived at, and the test fails. It's not an explicit expect, but with Playwright you don't always end up with one -- like in this case, we're just making sure the URL actually has been updated to what we expected it to be.
134ce49
into
main
please god fix my tests
edit: he has indeed
So after a full day of infuriation:
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits