Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .github/workflows/e2e_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- name: NPM Install
run: npm install

- name: Playwright Install
run: npx playwright install

- name: Extract PR Number
id: extract_pr_number
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
Expand Down
1 change: 1 addition & 0 deletions test/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { defineConfig, devices } from '@playwright/test';
*/
export default defineConfig({
testMatch: /test\/e2e\/specs\/.*(\.spec.ts)/,
globalSetup: './setup.ts',

timeout: 150000,
/* Run tests in files in parallel */
Expand Down
28 changes: 28 additions & 0 deletions test/e2e/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ExampleLinkType } from './types/exampleLinkType';
import { chromium, expect, Page } from '@playwright/test';
import { ExampleLinkName } from './testData/ExampleLinkNames';

async function globalSetup() {
if (process.env.PREVIEW_URL) {
const browser = await chromium.launch();
const page = await browser.newPage();
const link: ExampleLinkType = {
name: ExampleLinkName.AdaptiveStreaming,
endpoint: 'adaptive-streaming',
};
await waitForDeployPreviewUrl(link, page);
await browser.close();
}
}

/**
* 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> {
await expect(async () => {
await page.goto(process.env.PREVIEW_URL);
const linkLocator = page.getByRole('link', { name: link.name, exact: true });
await expect(linkLocator).toBeVisible({ timeout: 10000 });
}).toPass({ intervals: [1_000], timeout: 120000 });
}
export default globalSetup;
26 changes: 2 additions & 24 deletions test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import { ConsoleMessage, expect, Page } from '@playwright/test';
import { ConsoleMessage, expect } 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';
import { ExampleLinkName } from '../testData/ExampleLinkNames';

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
let isPreviewUrlLoaded = false;
import { ESM_URL } from '../testData/esmUrl';

/**
* 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, pomPages }) => {
vpTest.skip(link.name === 'Adaptive Streaming', 'Flaky on CI');
//Wait for deploy URL to be available if PREVIEW_URL is set, and it is not available yet
if (process.env.PREVIEW_URL && !isPreviewUrlLoaded) {
await waitForDeployPreviewUrl(link, page);
}
await page.goto(ESM_URL);
await pomPages.mainPage.clickLinkByName(link.name);
await waitForPageToLoadWithTimeout(page, 5000);
Expand Down Expand Up @@ -58,15 +48,3 @@ function handleCommonEsmBrowsersErrors(linkName: ExampleLinkName, consoleErrors:
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> {
await expect(async () => {
await page.goto(process.env.PREVIEW_URL);
const linkLocator = page.getByRole('link', { name: link.name, exact: true });
await expect(linkLocator).toBeVisible({ timeout: 10000 });
isPreviewUrlLoaded = true;
}).toPass({ intervals: [1_000], timeout: 120000 });
}
2 changes: 2 additions & 0 deletions test/e2e/testData/esmUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// On PR level it will use the preview deploy URL and locally it will use the latest EDGE.
export const ESM_URL = process.env.PREVIEW_URL ?? 'https://cld-vp-esm-pages.netlify.app/';