-
-
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
Changes from all commits
ff08ba3
895ab46
7b5899c
03d937e
28cb818
e6e3334
ef0ef30
85ac507
fe67356
54e9645
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,15 +14,14 @@ test.describe('a11y', () => { | |||||||
|
|
||||||||
| await page.goto('/accessibility/a'); | ||||||||
|
|
||||||||
| await clicknav('[href="/accessibility/b"]'); | ||||||||
| expect(await page.innerHTML('h1')).toBe('b'); | ||||||||
| await clicknav('[href="/accessibility/b"]', { waitForURL: '/accessibility/b' }); | ||||||||
| expect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BODY'); | ||||||||
| await page.keyboard.press(tab); | ||||||||
|
|
||||||||
| expect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BUTTON'); | ||||||||
| expect(await page.evaluate(() => (document.activeElement || {}).textContent)).toBe('focus me'); | ||||||||
|
|
||||||||
| await clicknav('[href="/accessibility/a"]'); | ||||||||
| await clicknav('[href="/accessibility/a"]', { waitForURL: '/accessibility/a' }); | ||||||||
| expect(await page.innerHTML('h1')).toBe('a'); | ||||||||
| expect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('BODY'); | ||||||||
|
|
||||||||
|
|
@@ -36,7 +35,9 @@ test.describe('a11y', () => { | |||||||
| test('applies autofocus after a navigation', async ({ page, clicknav }) => { | ||||||||
| await page.goto('/accessibility/autofocus/a'); | ||||||||
|
|
||||||||
| await clicknav('[href="/accessibility/autofocus/b"]'); | ||||||||
| await clicknav('[href="/accessibility/autofocus/b"]', { | ||||||||
| waitForURL: '/accessibility/autofocus/b' | ||||||||
| }); | ||||||||
| expect(await page.innerHTML('h1')).toBe('b'); | ||||||||
| expect(await page.evaluate(() => (document.activeElement || {}).nodeName)).toBe('INPUT'); | ||||||||
| }); | ||||||||
|
|
@@ -388,14 +389,14 @@ test.describe('Scrolling', () => { | |||||||
| await page.goto('/anchor'); | ||||||||
| await page.locator('#scroll-anchor').click(); | ||||||||
| const originalScrollY = /** @type {number} */ (await page.evaluate(() => scrollY)); | ||||||||
| await clicknav('#routing-page'); | ||||||||
| await page.goBack(); | ||||||||
| await clicknav('#routing-page', { waitForURL: '/routing/hashes/target' }); | ||||||||
|
|
||||||||
| await expect(page).toHaveURL('/anchor#last-anchor-2'); | ||||||||
| await page.goBack(); | ||||||||
| await page.waitForURL('/anchor#last-anchor-2'); | ||||||||
| expect(await page.evaluate(() => scrollY)).toEqual(originalScrollY); | ||||||||
|
|
||||||||
| await page.goBack(); | ||||||||
| await expect(page).toHaveURL('/anchor'); | ||||||||
| await page.waitForURL('/anchor'); | ||||||||
| expect(await page.evaluate(() => scrollY)).toEqual(0); | ||||||||
| }); | ||||||||
|
|
||||||||
|
|
@@ -734,14 +735,10 @@ test.describe('Prefetching', () => { | |||||||
| test('same route hash links work more than once', async ({ page, clicknav, baseURL }) => { | ||||||||
| await page.goto('/routing/hashes/a'); | ||||||||
|
|
||||||||
| await clicknav('[href="#preload"]'); | ||||||||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a#preload`); | ||||||||
|
|
||||||||
| await clicknav('[href="/routing/hashes/a"]'); | ||||||||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a`); | ||||||||
| await clicknav('[href="#preload"]', { waitForURL: `${baseURL}/routing/hashes/a#preload` }); | ||||||||
|
|
||||||||
| await clicknav('[href="#preload"]'); | ||||||||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a#preload`); | ||||||||
| await clicknav('[href="/routing/hashes/a"]', { waitForURL: `${baseURL}/routing/hashes/a` }); | ||||||||
| await clicknav('[href="#preload"]', { waitForURL: `${baseURL}/routing/hashes/a#preload` }); | ||||||||
| }); | ||||||||
|
|
||||||||
| test('does not rerun load on calls to duplicate preload hash route', async ({ app, page }) => { | ||||||||
|
|
@@ -802,19 +799,19 @@ test.describe('Routing', () => { | |||||||
| expect(await page.textContent('#page-url-hash')).toBe('#target'); | ||||||||
| }); | ||||||||
|
|
||||||||
| test('page.url.hash is correctly set on navigation', async ({ page }) => { | ||||||||
| test('page.url.hash is correctly set on navigation', async ({ page, clicknav }) => { | ||||||||
| await page.goto('/routing/hashes/pagestate'); | ||||||||
| expect(await page.textContent('#window-hash')).toBe(''); | ||||||||
| expect(await page.textContent('#page-url-hash')).toBe(''); | ||||||||
| await page.locator('[href="#target"]').click(); | ||||||||
| expect(await page.textContent('#window-hash')).toBe('#target'); | ||||||||
| expect(await page.textContent('#page-url-hash')).toBe('#target'); | ||||||||
| await page.locator('[href="/routing/hashes/pagestate"]').click(); | ||||||||
| await expect(page.locator('#window-hash')).toHaveText(''); | ||||||||
| await expect(page.locator('#page-url-hash')).toHaveText(''); | ||||||||
| await clicknav('[href="#target"]'); | ||||||||
| await expect(page.locator('#window-hash')).toHaveText('#target'); | ||||||||
| await expect(page.locator('#page-url-hash')).toHaveText('#target'); | ||||||||
| await clicknav('[href="/routing/hashes/pagestate"]'); | ||||||||
| await expect(page.locator('#window-hash')).toHaveText('#target'); // hashchange doesn't fire for these | ||||||||
| await expect(page.locator('#page-url-hash')).toHaveText(''); | ||||||||
| await page.goBack(); | ||||||||
| expect(await page.textContent('#window-hash')).toBe('#target'); | ||||||||
| expect(await page.textContent('#page-url-hash')).toBe('#target'); | ||||||||
| await expect(page.locator('#window-hash')).toHaveText('#target'); | ||||||||
| await expect(page.locator('#page-url-hash')).toHaveText('#target'); | ||||||||
| }); | ||||||||
|
|
||||||||
| test('clicking on a hash link focuses the associated element', async ({ page }) => { | ||||||||
|
|
@@ -832,12 +829,14 @@ test.describe('Routing', () => { | |||||||
| baseURL | ||||||||
| }) => { | ||||||||
| await page.goto('/data-sveltekit/reload/hash'); | ||||||||
| await page.locator('a[href="#example"]').click(); | ||||||||
| expect(page.url()).toBe(`${baseURL}/data-sveltekit/reload/hash#example`); | ||||||||
| await clicknav('a[href="/data-sveltekit/reload/hash/new"]'); | ||||||||
| expect(page.url()).toBe(`${baseURL}/data-sveltekit/reload/hash/new`); | ||||||||
| await clicknav('a[href="#example"]', { | ||||||||
| waitForURL: `${baseURL}/data-sveltekit/reload/hash#example` | ||||||||
| }); | ||||||||
| await clicknav('a[href="/data-sveltekit/reload/hash/new"]', { | ||||||||
| waitForURL: `${baseURL}/data-sveltekit/reload/hash/new` | ||||||||
| }); | ||||||||
| await page.goBack(); | ||||||||
| expect(page.url()).toBe(`${baseURL}/data-sveltekit/reload/hash#example`); | ||||||||
| await page.waitForURL(`${baseURL}/data-sveltekit/reload/hash#example`); | ||||||||
| await expect(page.getByRole('textbox')).toBeVisible(); | ||||||||
| }); | ||||||||
|
|
||||||||
|
|
@@ -862,11 +861,9 @@ test.describe('Routing', () => { | |||||||
| await page.goto('/routing/hashes/a'); | ||||||||
|
|
||||||||
| await page.locator('[href="#hash-target"]').click(); | ||||||||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a#hash-target`); | ||||||||
| await page.waitForURL(`${baseURL}/routing/hashes/a#hash-target`); | ||||||||
|
|
||||||||
| await clicknav('[href="/routing/hashes/b"]'); | ||||||||
| expect(await page.textContent('h1')).toBe('b'); | ||||||||
|
|
||||||||
| await expect(page.locator('h1')).toHaveText('b'); | ||||||||
| await page.goBack(); | ||||||||
| await expect(page.locator('h1')).toHaveText('a'); | ||||||||
|
|
@@ -879,14 +876,16 @@ test.describe('Routing', () => { | |||||||
| }) => { | ||||||||
| await page.goto('/routing/hashes/a'); | ||||||||
|
|
||||||||
| await clicknav('[href="#hash-target"]'); | ||||||||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a#hash-target`); | ||||||||
|
Member
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. I don't think you should have to change these lines because kit/packages/kit/test/utils.js Line 36 in 85a57a0
Contributor
Author
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. I think even if we updated
Member
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. 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 kit/packages/kit/test/utils.js Line 117 in 85a57a0
Perhaps we could change from a boolean
Contributor
Author
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. I don't think that'll work as it won't actually work for clientside navs (it relies on For now I'm adding
Member
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. Yeah, it looks like we probably have access to kit/packages/kit/test/utils.js Line 20 in 85a57a0
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
Contributor
Author
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. I don't actually think it'll work, unfortunately -- it has to be linked to a component lifecycle |
||||||||
| await clicknav('[href="#hash-target"]', { | ||||||||
| waitForURL: `${baseURL}/routing/hashes/a#hash-target` | ||||||||
| }); | ||||||||
|
|
||||||||
| await clicknav('[href="#replace-state"]'); | ||||||||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a#replace-state`); | ||||||||
| await clicknav('[href="#replace-state"]', { | ||||||||
| waitForURL: `${baseURL}/routing/hashes/a#replace-state` | ||||||||
| }); | ||||||||
|
|
||||||||
| await page.goBack(); | ||||||||
| expect(page.url()).toBe(`${baseURL}/routing/hashes/a`); | ||||||||
| await page.waitForURL(`${baseURL}/routing/hashes/a`); | ||||||||
| }); | ||||||||
|
|
||||||||
| test('does not normalize external path', async ({ page, start_server }) => { | ||||||||
|
|
||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
expectlines. perhaps the currentwaitForURLimplementation checks that, but I'd like to fix this up so that we don't usewaitForURLand I'm afraid it'd be easy to miss that we're no longer expecting anything while making that changeThere 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,
waitForURLis superior toexpect(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 explicitexpect, 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.