-
Notifications
You must be signed in to change notification settings - Fork 24
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
Me 18059 esm tests over preview build #727
Changes from 36 commits
5e0cc4f
a6edc9a
6409060
96b8aab
105d995
384f252
a8cf2a3
4b68609
ede3ca1
0ac494e
38a291d
41a9c3f
e7c3d53
b73bfe1
064cd30
f69490c
0903c8c
a911323
c3c769f
4475231
1687533
95b9b42
f8ea78a
21a560e
34323b9
ff388d8
744e67e
513c68a
c163e38
cc8de1c
47e85ad
c31ebfb
dfdfa21
f0e31f9
44deeab
3fca8c0
b1286a0
636a3ca
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 | ||||
---|---|---|---|---|---|---|
@@ -1,19 +1,26 @@ | ||||||
import { ConsoleMessage, expect } from '@playwright/test'; | ||||||
import { ConsoleMessage, expect, Page } from '@playwright/test'; | ||||||
import { vpTest } from '../fixtures/vpTest'; | ||||||
import { ESM_LINKS } from '../testData/esmPageLinksData'; | ||||||
import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout'; | ||||||
import { validatePageErrors } from '../src/helpers/validatePageErrors'; | ||||||
import { ExampleLinkType } from '../types/exampleLinkType'; | ||||||
|
||||||
const EDGE_ESM_URL = 'https://cld-vp-esm-pages.netlify.app/'; | ||||||
// On PR level it will use the preview deploy URL and locally it will use the latest EDGE. | ||||||
const ESM_URL = process.env.PREVIEW_URL || EDGE_ESM_URL; | ||||||
// Flag to indicate if the deploy preview URL is ready | ||||||
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.
Suggested change
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. Changed. Thanks. |
||||||
let PREVIEW_URL_LOADED = false; | ||||||
|
||||||
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. since this is a changing variable i think it is better to name it like 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. Changed. Thanks |
||||||
const ESM_URL = 'https://cld-vp-esm-pages.netlify.app/'; | ||||||
/** | ||||||
* Console error test generated by LINKS object array data. | ||||||
*/ | ||||||
for (const link of ESM_LINKS) { | ||||||
vpTest(`Test console errors on link ${link.name}`, async ({ page, consoleErrors, vpExamples }) => { | ||||||
vpTest.skip(link.name === 'Adaptive Streaming', 'Flaky on CI'); | ||||||
/** | ||||||
* Navigate to ESM Imports examples page | ||||||
*/ | ||||||
//Wait for deploy URL to be available if PREVIEW_URL is set, and it is not available yet | ||||||
if (process.env.PREVIEW_URL && !PREVIEW_URL_LOADED) { | ||||||
await waitForDeployPreviewUrl(link, page); | ||||||
} | ||||||
await page.goto(ESM_URL); | ||||||
await vpExamples.clickLinkByName(link.name); | ||||||
await waitForPageToLoadWithTimeout(page, 5000); | ||||||
|
@@ -50,3 +57,16 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM | |||||
validatePageErrors(consoleErrors, [], ['the server responded with a status of 404']); | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
* Waits for a deploy preview URL to become available by making repeated requests and check that link is visible. | ||||||
*/ | ||||||
async function waitForDeployPreviewUrl(link: ExampleLinkType, page: Page): Promise<void> { | ||||||
console.log('Waiting for deploy preview to be ready...'); | ||||||
await expect(async () => { | ||||||
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.
Suggested change
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. The print was added to get indication that we're waiting for the preview and not just wait long time without any indication which can feel like something is stuck. 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. Print was removed |
||||||
await page.goto(process.env.PREVIEW_URL); | ||||||
const linkLocator = page.getByRole('link', { name: link.name, exact: true }); | ||||||
await expect(linkLocator).toBeVisible({ timeout: 10000 }); | ||||||
PREVIEW_URL_LOADED = true; | ||||||
}).toPass({ intervals: [1_000], timeout: 120000 }); | ||||||
} |
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.
Why did you have to increase the timeout?
(just curious why you needed this 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.
Ok i see now it is for the deployment preview to be loaded
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.
Yes. The page can take some time to be loaded so the timeout was increased.