Skip to content
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 #711

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5e0cc4f
vp test: support esm test running on preview deploy
ShayLevi Oct 27, 2024
a6edc9a
vp test: support esm test running on preview deploy increase timeout
ShayLevi Oct 27, 2024
6409060
vp test: support esm test running on preview deploy revert timeout
ShayLevi Oct 27, 2024
96b8aab
vp test: adding waitFor function for checking if preview URL is ready
ShayLevi Oct 28, 2024
105d995
vp test: adding waitFor function for checking if preview URL is ready
ShayLevi Oct 28, 2024
384f252
vp test: adding waitFor function for checking if preview URL is ready
ShayLevi Oct 28, 2024
a8cf2a3
vp test: modify changes
ShayLevi Oct 28, 2024
4b68609
vp test: modify changes
ShayLevi Oct 28, 2024
ede3ca1
vp test: modify waitForDeployPreviewUrl
ShayLevi Oct 28, 2024
0ac494e
vp test: modify waitForDeployPreviewUrl
ShayLevi Oct 28, 2024
38a291d
vp test: modify changes
ShayLevi Oct 28, 2024
41a9c3f
vp test: modify changes
ShayLevi Oct 28, 2024
e7c3d53
vp test: remove beforeAll
ShayLevi Oct 28, 2024
b73bfe1
vp test: modify waitForDeployPreviewUrl function
ShayLevi Oct 28, 2024
064cd30
vp test: modify waitForDeployPreviewUrl function
ShayLevi Oct 28, 2024
f69490c
vp test: modify waitForDeployPreviewUrl function
ShayLevi Oct 28, 2024
0903c8c
vp test: modify waitForDeployPreviewUrl function adding a print
ShayLevi Oct 28, 2024
a911323
vp test: modify changes
ShayLevi Oct 28, 2024
c3c769f
vp test: adding print to log + increasing timeout
ShayLevi Oct 28, 2024
4475231
vp test: revert timeout
ShayLevi Oct 28, 2024
1687533
vp test: adding timeout
ShayLevi Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/e2e_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ jobs:
- name: NPM Install
run: npm install

- name: Extract PR Number
id: extract_pr_number
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV

- name: Set Deploy Preview URL
run: echo "PREVIEW_URL=https://deploy-preview-${{ env.PR_NUMBER }}--cld-vp-esm-pages.netlify.app" >> $GITHUB_ENV

- name: E2E tests
run: npm run test:e2e
env:
PREVIEW_URL: ${{ env.PREVIEW_URL }}

- name: Upload report to artifact
uses: actions/upload-artifact@v4
Expand Down
32 changes: 27 additions & 5 deletions test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
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';

const ESM_URL = 'https://cld-vp-esm-pages.netlify.app/';
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 URL is ready
let isDeployReady = false;

/**
* 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 && !isDeployReady) {
await waitForDeployPreviewUrl(ESM_URL, page);
}
await page.goto(ESM_URL);
await vpExamples.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
Expand Down Expand Up @@ -50,3 +56,19 @@ 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.
*/
async function waitForDeployPreviewUrl(url: string, page: Page): Promise<void> {
await expect(async () => {
if (isDeployReady) {
console.log('Deploy preview is already available, skipping check.');
return; // Skip checking if already confirmed as available
}
console.log('Waiting for deploy preview to be ready...');
const response = await page.request.get(url);
expect(response.status()).toBe(200);
isDeployReady = true; // Set flag to true when the URL is verified
console.log('Deploy preview is now available!'); // Print to console when ready
}).toPass({ timeout: 30000 });
}
Loading