From 5e0cc4f87004556d04104d715b2d99606d65f528 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Sun, 27 Oct 2024 12:33:33 +0200 Subject: [PATCH 01/38] vp test: support esm test running on preview deploy --- .github/workflows/e2e_pr.yml | 9 +++++++++ test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e_pr.yml b/.github/workflows/e2e_pr.yml index 0ad95782..21fe50ce 100644 --- a/.github/workflows/e2e_pr.yml +++ b/.github/workflows/e2e_pr.yml @@ -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 diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index c198ffbf..ca8cc198 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -4,7 +4,7 @@ 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/'; /** * Console error test generated by LINKS object array data. */ @@ -12,8 +12,10 @@ 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 + * Navigate to ESM Imports examples page. + * 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; await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); await waitForPageToLoadWithTimeout(page, 5000); @@ -26,6 +28,11 @@ for (const link of ESM_LINKS) { * Testing number of links in page. */ vpTest('ESM page Link count test', async ({ page }) => { + /** + * Navigate to ESM Imports examples page. + * 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; await page.goto(ESM_URL); const expectedNumberOfLinks = 32; const numberOfLinks = await page.getByRole('link').count(); From a6edc9aa992ef444afffb6c1656dbbedf26f0595 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Sun, 27 Oct 2024 15:01:29 +0200 Subject: [PATCH 02/38] vp test: support esm test running on preview deploy increase timeout --- test/e2e/playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index c5a555fe..0739cef9 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -6,7 +6,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testMatch: /test\/e2e\/specs\/.*(\.spec.ts)/, - timeout: 45000, + timeout: 60000, /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ From 6409060d0a1c50c8553a9a872d2c973e6fdb1986 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Sun, 27 Oct 2024 15:09:54 +0200 Subject: [PATCH 03/38] vp test: support esm test running on preview deploy revert timeout --- test/e2e/playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index 0739cef9..c5a555fe 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -6,7 +6,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testMatch: /test\/e2e\/specs\/.*(\.spec.ts)/, - timeout: 60000, + timeout: 45000, /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ From 96b8aab126fd41be80b74398aa128828ff5e257a Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 11:29:21 +0200 Subject: [PATCH 04/38] vp test: adding waitFor function for checking if preview URL is ready --- .../specs/linksConsoleErrorsEsmPage.spec.ts | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index ca8cc198..badf9b77 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -5,17 +5,23 @@ import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWi import { validatePageErrors } from '../src/helpers/validatePageErrors'; 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; + +/** + * Wait for deploy URL to be available if PREVIEW_URL is set + */ +vpTest.beforeAll(async () => { + if (process.env.PREVIEW_URL) { + await waitForDeployPreviewUrl(ESM_URL); + } +}); /** * 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. - * 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; await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); await waitForPageToLoadWithTimeout(page, 5000); @@ -57,3 +63,27 @@ 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, maxAttempts: number = 10, delay: number = 5000): Promise { + console.log(`Waiting for deploy preview at ${url}`); + let attempts = 0; + + while (attempts < maxAttempts) { + try { + // Use fetch to check if the URL is available + const response = await fetch(url); + + if (response.ok) { + return; // URL is reachable, exit function + } else { + throw new Error(`Received status: ${response.status}`); + } + } catch (error) { + attempts++; + console.log(`Attempt ${attempts} failed. Retrying in ${delay / 1000} seconds`); + await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying + } + } +} From 105d9956687942d498f5888194b38b8331da0ab1 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 11:30:36 +0200 Subject: [PATCH 05/38] vp test: adding waitFor function for checking if preview URL is ready --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index badf9b77..1faec1d3 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -69,7 +69,6 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, delay: number = 5000): Promise { console.log(`Waiting for deploy preview at ${url}`); let attempts = 0; - while (attempts < maxAttempts) { try { // Use fetch to check if the URL is available @@ -78,11 +77,11 @@ async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, de if (response.ok) { return; // URL is reachable, exit function } else { - throw new Error(`Received status: ${response.status}`); + console.log(`Received status: ${response.status}`); } } catch (error) { attempts++; - console.log(`Attempt ${attempts} failed. Retrying in ${delay / 1000} seconds`); + (`Attempt ${attempts} failed. Retrying in ${delay / 1000} seconds`); await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying } } From 384f252be1c86ed9a8fdef42b2b04a05f24b514a Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 11:31:45 +0200 Subject: [PATCH 06/38] vp test: adding waitFor function for checking if preview URL is ready --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 1faec1d3..f366200e 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -81,7 +81,7 @@ async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, de } } catch (error) { attempts++; - (`Attempt ${attempts} failed. Retrying in ${delay / 1000} seconds`); + `Attempt ${attempts} failed. Retrying in ${delay / 1000} seconds`; await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying } } From a8cf2a3b88de158661fb40c106271d3e8fd24f34 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 12:53:26 +0200 Subject: [PATCH 07/38] vp test: modify changes --- .../specs/linksConsoleErrorsEsmPage.spec.ts | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index f366200e..c6ff8cbe 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -66,23 +66,18 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM /** * Waits for a deploy preview URL to become available by making repeated requests. */ -async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, delay: number = 5000): Promise { +async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, delay: number = 10000): Promise { console.log(`Waiting for deploy preview at ${url}`); let attempts = 0; while (attempts < maxAttempts) { - try { - // Use fetch to check if the URL is available - const response = await fetch(url); - - if (response.ok) { - return; // URL is reachable, exit function - } else { - console.log(`Received status: ${response.status}`); - } - } catch (error) { + // Use fetch to check if the URL is available + const response = await fetch(url); + if (response.ok) { + attempts++; + return; // URL is reachable, exit function + } else { + console.log(`Received status: ${response.status}`); attempts++; - `Attempt ${attempts} failed. Retrying in ${delay / 1000} seconds`; - await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying } } } From 4b68609c31d17d7f3918b1a2200057d341096836 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 12:55:45 +0200 Subject: [PATCH 08/38] vp test: modify changes --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index c6ff8cbe..e847e17d 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -73,11 +73,11 @@ async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, de // Use fetch to check if the URL is available const response = await fetch(url); if (response.ok) { - attempts++; return; // URL is reachable, exit function } else { console.log(`Received status: ${response.status}`); - attempts++; } + attempts++; + await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying } } From ede3ca138800e4f91df71d3e6d4effa08902c36e Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 13:02:17 +0200 Subject: [PATCH 09/38] vp test: modify waitForDeployPreviewUrl --- .../specs/linksConsoleErrorsEsmPage.spec.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index e847e17d..a1afec82 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -69,15 +69,21 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, delay: number = 10000): Promise { console.log(`Waiting for deploy preview at ${url}`); let attempts = 0; + while (attempts < maxAttempts) { - // Use fetch to check if the URL is available - const response = await fetch(url); - if (response.ok) { - return; // URL is reachable, exit function - } else { - console.log(`Received status: ${response.status}`); + try { + const response = await fetch(url); + + if (response.ok) { + console.log('Deploy preview is available!'); + return; // URL is reachable, exit function + } + console.error(`Received non-OK response: ${response.status}`); + } catch (error) { + console.error(`Attempt ${attempts + 1} failed: ${error.message}`); } attempts++; + console.log(`Retrying in ${delay / 1000} seconds...`); await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying } } From 0ac494e715613882b5fed4be1067693d303b08b9 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 13:03:27 +0200 Subject: [PATCH 10/38] vp test: modify waitForDeployPreviewUrl --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index a1afec82..12bc580c 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -78,12 +78,11 @@ async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, de console.log('Deploy preview is available!'); return; // URL is reachable, exit function } - console.error(`Received non-OK response: ${response.status}`); } catch (error) { console.error(`Attempt ${attempts + 1} failed: ${error.message}`); } attempts++; - console.log(`Retrying in ${delay / 1000} seconds...`); + console.log(`Retrying in ${delay / 1000} seconds.`); await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying } } From 38a291dbe74c5a4fd83aa0b6e2314da280455ae5 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 13:07:54 +0200 Subject: [PATCH 11/38] vp test: modify changes --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 12bc580c..fb6223f8 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -34,11 +34,6 @@ for (const link of ESM_LINKS) { * Testing number of links in page. */ vpTest('ESM page Link count test', async ({ page }) => { - /** - * Navigate to ESM Imports examples page. - * 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; await page.goto(ESM_URL); const expectedNumberOfLinks = 32; const numberOfLinks = await page.getByRole('link').count(); From 41a9c3f41a15ce6c68b02c7b894dcd3f9b5029cc Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 13:14:36 +0200 Subject: [PATCH 12/38] vp test: modify changes --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index fb6223f8..6663c8b4 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -68,7 +68,6 @@ async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, de while (attempts < maxAttempts) { try { const response = await fetch(url); - if (response.ok) { console.log('Deploy preview is available!'); return; // URL is reachable, exit function @@ -77,7 +76,6 @@ async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, de console.error(`Attempt ${attempts + 1} failed: ${error.message}`); } attempts++; - console.log(`Retrying in ${delay / 1000} seconds.`); await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying } } From e7c3d53b259b4576fe332a57f92e43bb916ae3f6 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 13:29:39 +0200 Subject: [PATCH 13/38] vp test: remove beforeAll --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 6663c8b4..8c8e6fb6 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -11,17 +11,20 @@ const ESM_URL = process.env.PREVIEW_URL || EDGE_ESM_URL; /** * Wait for deploy URL to be available if PREVIEW_URL is set */ -vpTest.beforeAll(async () => { +/*vpTest.beforeAll(async () => { if (process.env.PREVIEW_URL) { await waitForDeployPreviewUrl(ESM_URL); } -}); +});*/ /** * 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'); + if (process.env.PREVIEW_URL) { + await waitForDeployPreviewUrl(ESM_URL); + } await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); await waitForPageToLoadWithTimeout(page, 5000); @@ -34,6 +37,9 @@ for (const link of ESM_LINKS) { * Testing number of links in page. */ vpTest('ESM page Link count test', async ({ page }) => { + if (process.env.PREVIEW_URL) { + await waitForDeployPreviewUrl(ESM_URL); + } await page.goto(ESM_URL); const expectedNumberOfLinks = 32; const numberOfLinks = await page.getByRole('link').count(); From b73bfe124ee97e17b44e994fe7c1d936e176d34d Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 14:20:07 +0200 Subject: [PATCH 14/38] vp test: modify waitForDeployPreviewUrl function --- .../specs/linksConsoleErrorsEsmPage.spec.ts | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 8c8e6fb6..ae4064a3 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -1,4 +1,4 @@ -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'; @@ -7,23 +7,18 @@ import { validatePageErrors } from '../src/helpers/validatePageErrors'; 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; -/** - * Wait for deploy URL to be available if PREVIEW_URL is set - */ -/*vpTest.beforeAll(async () => { - if (process.env.PREVIEW_URL) { - await waitForDeployPreviewUrl(ESM_URL); - } -});*/ /** * 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'); + //Wait for deploy URL to be available if PREVIEW_URL is set if (process.env.PREVIEW_URL) { - await waitForDeployPreviewUrl(ESM_URL); + await waitForDeployPreviewUrl(ESM_URL, page); } await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); @@ -37,8 +32,9 @@ for (const link of ESM_LINKS) { * Testing number of links in page. */ vpTest('ESM page Link count test', async ({ page }) => { + //Wait for deploy URL to be available if PREVIEW_URL is set if (process.env.PREVIEW_URL) { - await waitForDeployPreviewUrl(ESM_URL); + await waitForDeployPreviewUrl(ESM_URL, page); } await page.goto(ESM_URL); const expectedNumberOfLinks = 32; @@ -67,21 +63,14 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM /** * Waits for a deploy preview URL to become available by making repeated requests. */ -async function waitForDeployPreviewUrl(url: string, maxAttempts: number = 10, delay: number = 10000): Promise { - console.log(`Waiting for deploy preview at ${url}`); - let attempts = 0; - - while (attempts < maxAttempts) { - try { - const response = await fetch(url); - if (response.ok) { - console.log('Deploy preview is available!'); - return; // URL is reachable, exit function - } - } catch (error) { - console.error(`Attempt ${attempts + 1} failed: ${error.message}`); +async function waitForDeployPreviewUrl(url: string, page: Page): Promise { + await expect(async () => { + if (isDeployReady) { + console.log('Deploy preview is already available, skipping check'); + return; // Skip checking if already confirmed as available } - attempts++; - await new Promise((resolve) => setTimeout(resolve, delay)); // Wait before retrying - } + const response = await page.request.get(url); + expect(response.status()).toBe(200); + isDeployReady = true; // Set flag to true when the URL is verified + }).toPass(); } From 064cd302d66309982633b77e59672690533a6617 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 14:24:01 +0200 Subject: [PATCH 15/38] vp test: modify waitForDeployPreviewUrl function --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index ae4064a3..6c07481a 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -66,7 +66,6 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM async function waitForDeployPreviewUrl(url: string, page: Page): Promise { await expect(async () => { if (isDeployReady) { - console.log('Deploy preview is already available, skipping check'); return; // Skip checking if already confirmed as available } const response = await page.request.get(url); From f69490ce58e43ee44106a37b171033610a5d0edf Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 14:30:24 +0200 Subject: [PATCH 16/38] vp test: modify waitForDeployPreviewUrl function --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 6c07481a..27f78072 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -16,8 +16,8 @@ let isDeployReady = false; 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'); - //Wait for deploy URL to be available if PREVIEW_URL is set - if (process.env.PREVIEW_URL) { + //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); @@ -32,8 +32,8 @@ for (const link of ESM_LINKS) { * Testing number of links in page. */ vpTest('ESM page Link count test', async ({ page }) => { - //Wait for deploy URL to be available if PREVIEW_URL is set - if (process.env.PREVIEW_URL) { + //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); @@ -66,6 +66,7 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM async function waitForDeployPreviewUrl(url: string, page: Page): Promise { await expect(async () => { if (isDeployReady) { + console.log('Deploy preview is already available, skipping check.'); return; // Skip checking if already confirmed as available } const response = await page.request.get(url); From 0903c8c0b4ad797f80a87035d81f7cf6e4af2ff4 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 14:37:17 +0200 Subject: [PATCH 17/38] vp test: modify waitForDeployPreviewUrl function adding a print --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 27f78072..81f70091 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -72,5 +72,6 @@ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { 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(); } From a9113234c44b62b6d679026ab1a988ecbb98e330 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 18:51:35 +0200 Subject: [PATCH 18/38] vp test: modify changes --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 81f70091..70138f26 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -32,10 +32,6 @@ for (const link of ESM_LINKS) { * Testing number of links in page. */ vpTest('ESM page Link count test', async ({ 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); const expectedNumberOfLinks = 32; const numberOfLinks = await page.getByRole('link').count(); From c3c769fce0e9a74de649020bdcbcd1230413c805 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 19:01:22 +0200 Subject: [PATCH 19/38] vp test: adding print to log + increasing timeout --- test/e2e/playwright.config.ts | 2 +- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index c5a555fe..0739cef9 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -6,7 +6,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testMatch: /test\/e2e\/specs\/.*(\.spec.ts)/, - timeout: 45000, + timeout: 60000, /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 70138f26..028aca50 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -65,6 +65,7 @@ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { 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 From 4475231e09089249c80ed9c0936c8bac9f1084c6 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 19:18:07 +0200 Subject: [PATCH 20/38] vp test: revert timeout --- test/e2e/playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index 0739cef9..c5a555fe 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -6,7 +6,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testMatch: /test\/e2e\/specs\/.*(\.spec.ts)/, - timeout: 60000, + timeout: 45000, /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ From 16875336511ab09f5831097f6d9f56aaa5431237 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 19:21:25 +0200 Subject: [PATCH 21/38] vp test: adding timeout --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 028aca50..d0f7596e 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -70,5 +70,5 @@ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { 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(); + }).toPass({ timeout: 30000 }); } From 95b9b42912a46a34ad8853ba4a134361a2903c84 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 19:29:00 +0200 Subject: [PATCH 22/38] vp test: adding test for is deploy URL ready --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index d0f7596e..4a5d08e8 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -10,6 +10,13 @@ const ESM_URL = process.env.PREVIEW_URL || EDGE_ESM_URL; // Flag to indicate if the deploy URL is ready let isDeployReady = false; +// Initial test block to check if deploy preview URL is ready +vpTest('Check deploy preview URL readiness for PR', async ({ page }) => { + if (process.env.PREVIEW_URL && !isDeployReady) { + await waitForDeployPreviewUrl(ESM_URL, page); + } +}); + /** * Console error test generated by LINKS object array data. */ @@ -17,9 +24,9 @@ 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'); //Wait for deploy URL to be available if PREVIEW_URL is set, and it is not available yet - if (process.env.PREVIEW_URL && !isDeployReady) { + /* 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); @@ -70,5 +77,5 @@ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { 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 }); + }).toPass(); } From f8ea78a2d88091c9857fb14b46b8fa72c293a8f9 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 19:34:50 +0200 Subject: [PATCH 23/38] vp test: revert test --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 4a5d08e8..028aca50 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -10,13 +10,6 @@ const ESM_URL = process.env.PREVIEW_URL || EDGE_ESM_URL; // Flag to indicate if the deploy URL is ready let isDeployReady = false; -// Initial test block to check if deploy preview URL is ready -vpTest('Check deploy preview URL readiness for PR', async ({ page }) => { - if (process.env.PREVIEW_URL && !isDeployReady) { - await waitForDeployPreviewUrl(ESM_URL, page); - } -}); - /** * Console error test generated by LINKS object array data. */ @@ -24,9 +17,9 @@ 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'); //Wait for deploy URL to be available if PREVIEW_URL is set, and it is not available yet - /* if (process.env.PREVIEW_URL && !isDeployReady) { + 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); From 21a560e8346df5a3024cdae6c90aa5c70dba21d4 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 19:53:16 +0200 Subject: [PATCH 24/38] vp test: change assertion --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 028aca50..fd8e1c45 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -16,7 +16,7 @@ let isDeployReady = false; 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'); - //Wait for deploy URL to be available if PREVIEW_URL is set, and it is not available yet + //Wait for deploy URL to be available if PREVIEW_URL is set if (process.env.PREVIEW_URL && !isDeployReady) { await waitForDeployPreviewUrl(ESM_URL, page); } @@ -66,8 +66,8 @@ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { 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); + //const response = await page.request.get(url); + expect(await page.waitForLoadState('networkidle')); isDeployReady = true; // Set flag to true when the URL is verified console.log('Deploy preview is now available!'); // Print to console when ready }).toPass(); From 34323b9dd5970bdfcead2474bda74c4ca398b9d5 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 28 Oct 2024 19:59:21 +0200 Subject: [PATCH 25/38] vp test: change assertion --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index fd8e1c45..b31b543d 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -66,8 +66,8 @@ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { 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(await page.waitForLoadState('networkidle')); + 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(); From ff388d8f628ad9c54ab1b0637dea037e1a7c602a Mon Sep 17 00:00:00 2001 From: shaylevi Date: Tue, 29 Oct 2024 12:31:52 +0200 Subject: [PATCH 26/38] vp test: modify waitForDeployPreviewUrl --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index b31b543d..38ea49e2 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -8,7 +8,6 @@ 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. @@ -17,8 +16,9 @@ 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'); //Wait for deploy URL to be available if PREVIEW_URL is set - if (process.env.PREVIEW_URL && !isDeployReady) { + if (process.env.PREVIEW_URL && !process.env.ESM_READY) { await waitForDeployPreviewUrl(ESM_URL, page); + process.env.ESM_READY = 'true'; } await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); @@ -61,14 +61,7 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM */ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { 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(); } From 744e67e66e90a5ecb7722cb9a52e3e10b04a4de1 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Tue, 29 Oct 2024 12:45:53 +0200 Subject: [PATCH 27/38] vp test: modify waitForDeployPreviewUrl assertion --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 38ea49e2..c9a7264f 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -7,7 +7,6 @@ import { validatePageErrors } from '../src/helpers/validatePageErrors'; 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 /** * Console error test generated by LINKS object array data. @@ -61,7 +60,7 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM */ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { await expect(async () => { - const response = await page.request.get(url); - expect(response.status()).toBe(200); + await page.goto(url); + expect(this.page.getByRole('link', { name: 'Analytics', exact: true })); }).toPass(); } From 513c68a2add9a4b43de0ccff34d765714dcad71c Mon Sep 17 00:00:00 2001 From: shaylevi Date: Tue, 29 Oct 2024 14:17:24 +0200 Subject: [PATCH 28/38] vp test: adding beforeEach and modify waitForDeployPreviewUrl --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index c9a7264f..f860bcef 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -7,6 +7,13 @@ import { validatePageErrors } from '../src/helpers/validatePageErrors'; 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; +// Ensure the deploy URL is ready before running the tests +vpTest.beforeEach(async ({ page }) => { + if (process.env.PREVIEW_URL && !process.env.ESM_READY) { + await waitForDeployPreviewUrl(ESM_URL, page); + process.env.ESM_READY = 'true'; + } +}); /** * Console error test generated by LINKS object array data. @@ -14,11 +21,6 @@ const ESM_URL = process.env.PREVIEW_URL || EDGE_ESM_URL; 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'); - //Wait for deploy URL to be available if PREVIEW_URL is set - if (process.env.PREVIEW_URL && !process.env.ESM_READY) { - await waitForDeployPreviewUrl(ESM_URL, page); - process.env.ESM_READY = 'true'; - } await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); await waitForPageToLoadWithTimeout(page, 5000); @@ -61,6 +63,7 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM async function waitForDeployPreviewUrl(url: string, page: Page): Promise { await expect(async () => { await page.goto(url); - expect(this.page.getByRole('link', { name: 'Analytics', exact: true })); + //Checking if the link is visible, so we will know that page was loaded + expect(this.page.getByRole('link', { name: 'Analytics', exact: true }).toBeVisible()); }).toPass(); } From c163e382705c4062a900d1f87b9128d491d92188 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Tue, 29 Oct 2024 14:28:19 +0200 Subject: [PATCH 29/38] vp test: modify waitForDeployPreviewUrl --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index f860bcef..f3d4a0a3 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -62,8 +62,9 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM */ async function waitForDeployPreviewUrl(url: string, page: Page): Promise { await expect(async () => { - await page.goto(url); - //Checking if the link is visible, so we will know that page was loaded - expect(this.page.getByRole('link', { name: 'Analytics', exact: true }).toBeVisible()); + console.log('Waiting for deploy preview to be ready...'); + const response = await page.request.get(url); + expect(response.status()).toBe(200); + console.log('Deploy preview is now available!'); // Print to console when ready }).toPass(); } From cc8de1c95edfe939fea51bf8d639baf0f255bfa9 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Wed, 30 Oct 2024 14:46:02 +0200 Subject: [PATCH 30/38] vp test: adding logs for debugging --- test/e2e/playwright.config.ts | 2 +- .../specs/linksConsoleErrorsEsmPage.spec.ts | 38 ++++++++------ test/e2e/testData/esmPageLinksData.ts | 50 +++++++++---------- 3 files changed, 49 insertions(+), 41 deletions(-) diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index c5a555fe..916e4434 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -6,7 +6,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testMatch: /test\/e2e\/specs\/.*(\.spec.ts)/, - timeout: 45000, + timeout: 90000, /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index f3d4a0a3..4af92f60 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -8,19 +8,27 @@ 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; // Ensure the deploy URL is ready before running the tests -vpTest.beforeEach(async ({ page }) => { - if (process.env.PREVIEW_URL && !process.env.ESM_READY) { - await waitForDeployPreviewUrl(ESM_URL, page); - process.env.ESM_READY = 'true'; - } -}); + +let retry = 0; /** * 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.only(`Test console errors on link ${link.name}`, async ({ page, request, consoleErrors, vpExamples }) => { vpTest.skip(link.name === 'Adaptive Streaming', 'Flaky on CI'); + console.log('process.env.PREVIEW_URL: ', process.env.PREVIEW_URL); + + if (process.env.PREVIEW_URL) { + await expect(async () => { + console.log('Waiting for deploy preview to be ready...', retry++); + const response = await request.get(process.env.PREVIEW_URL); + console.log('Returned status: ', response.status()); + console.log('Returned ok: ', response.ok()); + expect(response.status()).toBe(200); + }).toPass({ intervals: [1_000], timeout: 90000 }); + } + await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); await waitForPageToLoadWithTimeout(page, 5000); @@ -60,11 +68,11 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM /** * Waits for a deploy preview URL to become available by making repeated requests. */ -async function waitForDeployPreviewUrl(url: string, page: Page): Promise { - await expect(async () => { - console.log('Waiting for deploy preview to be ready...'); - const response = await page.request.get(url); - expect(response.status()).toBe(200); - console.log('Deploy preview is now available!'); // Print to console when ready - }).toPass(); -} +// async function waitForDeployPreviewUrl(url: string, page: Page): Promise { +// await expect(async () => { +// console.log('Waiting for deploy preview to be ready...'); +// const response = await page.request.get(url); +// expect(response.status()).toBe(200); +// console.log('Deploy preview is now available!'); // Print to console when ready +// }).toPass(); +// } diff --git a/test/e2e/testData/esmPageLinksData.ts b/test/e2e/testData/esmPageLinksData.ts index 6cb6fad6..b702e187 100644 --- a/test/e2e/testData/esmPageLinksData.ts +++ b/test/e2e/testData/esmPageLinksData.ts @@ -11,29 +11,29 @@ export const ESM_LINKS: ExampleLinkType[] = [ { name: 'Autoplay on Scroll', endpoint: 'autoplay-on-scroll' }, { name: 'Chapters', endpoint: 'chapters' }, { name: 'Cloudinary Analytics', endpoint: 'cloudinary-analytics' }, - { name: 'Codecs and formats', endpoint: 'codec-formats' }, - { name: 'Colors API', endpoint: 'colors' }, - { name: 'Components', endpoint: 'components' }, - { name: 'Custom Errors', endpoint: 'custom-cld-errors' }, - { name: 'Display Configurations', endpoint: 'ui-config' }, - { name: 'Debug', endpoint: 'debug' }, - { name: 'Floating Player', endpoint: 'floating-player' }, - { name: 'Fluid Layouts', endpoint: 'fluid' }, - { name: 'Force HLS Subtitles', endpoint: 'force-hls-subtitles' }, - { name: 'Highlights Graph', endpoint: 'highlights-graph' }, - { name: 'Interaction Area', endpoint: 'interaction-area' }, - { name: 'Multiple Players', endpoint: 'multiple-players' }, - { name: 'Playlist', endpoint: 'playlist' }, - { name: 'Playlist by Tag', endpoint: 'playlist-by-tag' }, - { name: 'Poster Options', endpoint: 'poster' }, - { name: 'Profiles', endpoint: 'profiles' }, - { name: 'Raw URL', endpoint: 'raw-url' }, - { name: 'Recommendations', endpoint: 'recommendations' }, - { name: 'Seek Thumbnails', endpoint: 'seek-thumbs' }, - { name: 'Shoppable Videos', endpoint: 'shoppable' }, - { name: 'Subtitles & Captions', endpoint: 'subtitles-and-captions' }, - { name: 'Video Transformations', endpoint: 'transformations' }, - { name: 'UI Config', endpoint: 'ui-config' }, - { name: 'VAST & VPAID Support', endpoint: 'vast-vpaid' }, - { name: 'VR/360 Videos', endpoint: '360' }, + // { name: 'Codecs and formats', endpoint: 'codec-formats' }, + // { name: 'Colors API', endpoint: 'colors' }, + // { name: 'Components', endpoint: 'components' }, + // { name: 'Custom Errors', endpoint: 'custom-cld-errors' }, + // { name: 'Display Configurations', endpoint: 'ui-config' }, + // { name: 'Debug', endpoint: 'debug' }, + // { name: 'Floating Player', endpoint: 'floating-player' }, + // { name: 'Fluid Layouts', endpoint: 'fluid' }, + // { name: 'Force HLS Subtitles', endpoint: 'force-hls-subtitles' }, + // { name: 'Highlights Graph', endpoint: 'highlights-graph' }, + // { name: 'Interaction Area', endpoint: 'interaction-area' }, + // { name: 'Multiple Players', endpoint: 'multiple-players' }, + // { name: 'Playlist', endpoint: 'playlist' }, + // { name: 'Playlist by Tag', endpoint: 'playlist-by-tag' }, + // { name: 'Poster Options', endpoint: 'poster' }, + // { name: 'Profiles', endpoint: 'profiles' }, + // { name: 'Raw URL', endpoint: 'raw-url' }, + // { name: 'Recommendations', endpoint: 'recommendations' }, + // { name: 'Seek Thumbnails', endpoint: 'seek-thumbs' }, + // { name: 'Shoppable Videos', endpoint: 'shoppable' }, + // { name: 'Subtitles & Captions', endpoint: 'subtitles-and-captions' }, + // { name: 'Video Transformations', endpoint: 'transformations' }, + // { name: 'UI Config', endpoint: 'ui-config' }, + // { name: 'VAST & VPAID Support', endpoint: 'vast-vpaid' }, + // { name: 'VR/360 Videos', endpoint: '360' }, ]; From 47e85adb3ede263fa70fd8e233562c4f5edc94e6 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Wed, 30 Oct 2024 14:46:49 +0200 Subject: [PATCH 31/38] vp test: adding logs for debugging --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index 4af92f60..f17a8658 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -1,4 +1,4 @@ -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'; From c31ebfbc1ad32dc14c76427be2a2d6f922ecf6e7 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Wed, 30 Oct 2024 14:49:20 +0200 Subject: [PATCH 32/38] vp test: adding logs for debugging --- test/e2e/playwright.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index 916e4434..d06c893c 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ - forbidOnly: !!process.env.CI, + forbidOnly: false, /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Opt out of parallel tests on CI. */ From dfdfa211b807589b7049d74293f8deac9df03464 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Wed, 30 Oct 2024 15:07:31 +0200 Subject: [PATCH 33/38] vp test: adding logs for debugging --- test/e2e/fixtures/vpTest.ts | 2 +- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/e2e/fixtures/vpTest.ts b/test/e2e/fixtures/vpTest.ts index 7eb5c2d4..6478bc6b 100644 --- a/test/e2e/fixtures/vpTest.ts +++ b/test/e2e/fixtures/vpTest.ts @@ -19,7 +19,7 @@ export const vpTest = test.extend({ vpExamples: [ async ({ page }, use) => { const vpExamplePage = new MainPage(page); - await vpExamplePage.goto(); + // await vpExamplePage.goto(); await use(vpExamplePage); }, { auto: true }, diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index f17a8658..bc2f64b6 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -29,6 +29,14 @@ for (const link of ESM_LINKS) { }).toPass({ intervals: [1_000], timeout: 90000 }); } + await expect(async () => { + console.log('Navigate to esm page'); + await page.goto(ESM_URL); + const linkLocator = page.getByRole('link', { name: link.name, exact: true }); + console.log('wait for link to be visible: ', linkLocator.isVisible()); + await expect(linkLocator).toBeVisible({ timeout: 1000 }); + }).toPass({ intervals: [1_000], timeout: 90000 }); + await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); await waitForPageToLoadWithTimeout(page, 5000); From f0e31f9f86205d1b12b17a4c8d5b2be70f64f21d Mon Sep 17 00:00:00 2001 From: shaylevi Date: Wed, 30 Oct 2024 15:16:19 +0200 Subject: [PATCH 34/38] vp test: adding logs for debugging --- test/e2e/playwright.config.ts | 2 +- .../specs/linksConsoleErrorsEsmPage.spec.ts | 27 +++++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index d06c893c..db122ea9 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -6,7 +6,7 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testMatch: /test\/e2e\/specs\/.*(\.spec.ts)/, - timeout: 90000, + timeout: 150000, /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index bc2f64b6..fa1cfb8c 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -9,34 +9,27 @@ const EDGE_ESM_URL = 'https://cld-vp-esm-pages.netlify.app/'; const ESM_URL = process.env.PREVIEW_URL || EDGE_ESM_URL; // Ensure the deploy URL is ready before running the tests -let retry = 0; +let PREVIEW_URL_LOADED = false; /** * Console error test generated by LINKS object array data. */ for (const link of ESM_LINKS) { - vpTest.only(`Test console errors on link ${link.name}`, async ({ page, request, consoleErrors, vpExamples }) => { + vpTest.only(`Test console errors on link ${link.name}`, async ({ page, consoleErrors, vpExamples }) => { vpTest.skip(link.name === 'Adaptive Streaming', 'Flaky on CI'); console.log('process.env.PREVIEW_URL: ', process.env.PREVIEW_URL); - if (process.env.PREVIEW_URL) { + if (process.env.PREVIEW_URL && !PREVIEW_URL_LOADED) { await expect(async () => { - console.log('Waiting for deploy preview to be ready...', retry++); - const response = await request.get(process.env.PREVIEW_URL); - console.log('Returned status: ', response.status()); - console.log('Returned ok: ', response.ok()); - expect(response.status()).toBe(200); - }).toPass({ intervals: [1_000], timeout: 90000 }); + console.log('Navigate to esm page'); + await page.goto(process.env.PREVIEW_URL); + const linkLocator = page.getByRole('link', { name: link.name, exact: true }); + console.log('wait for link to be visible: ', await linkLocator.isVisible()); + await expect(linkLocator).toBeVisible({ timeout: 3000 }); + PREVIEW_URL_LOADED = true; + }).toPass({ intervals: [1_000], timeout: 120000 }); } - await expect(async () => { - console.log('Navigate to esm page'); - await page.goto(ESM_URL); - const linkLocator = page.getByRole('link', { name: link.name, exact: true }); - console.log('wait for link to be visible: ', linkLocator.isVisible()); - await expect(linkLocator).toBeVisible({ timeout: 1000 }); - }).toPass({ intervals: [1_000], timeout: 90000 }); - await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); await waitForPageToLoadWithTimeout(page, 5000); From 44deeab33d64d69e90559c09a565e966b9d562c5 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Wed, 30 Oct 2024 15:46:36 +0200 Subject: [PATCH 35/38] vp test: modify waitForDeployPreviewUrl and revert debugging prints --- test/e2e/fixtures/vpTest.ts | 2 +- test/e2e/playwright.config.ts | 2 +- .../specs/linksConsoleErrorsEsmPage.spec.ts | 41 +++++++-------- test/e2e/testData/esmPageLinksData.ts | 50 +++++++++---------- 4 files changed, 44 insertions(+), 51 deletions(-) diff --git a/test/e2e/fixtures/vpTest.ts b/test/e2e/fixtures/vpTest.ts index 6478bc6b..7eb5c2d4 100644 --- a/test/e2e/fixtures/vpTest.ts +++ b/test/e2e/fixtures/vpTest.ts @@ -19,7 +19,7 @@ export const vpTest = test.extend({ vpExamples: [ async ({ page }, use) => { const vpExamplePage = new MainPage(page); - // await vpExamplePage.goto(); + await vpExamplePage.goto(); await use(vpExamplePage); }, { auto: true }, diff --git a/test/e2e/playwright.config.ts b/test/e2e/playwright.config.ts index db122ea9..cbb78353 100644 --- a/test/e2e/playwright.config.ts +++ b/test/e2e/playwright.config.ts @@ -10,7 +10,7 @@ export default defineConfig({ /* Run tests in files in parallel */ fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ - forbidOnly: false, + forbidOnly: !!process.env.CI, /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Opt out of parallel tests on CI. */ diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index fa1cfb8c..b2bb0ced 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -1,35 +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 { link } from 'node:fs'; 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; -// Ensure the deploy URL is ready before running the tests - +// Flag to indicate if the deploy preview URL is ready let PREVIEW_URL_LOADED = false; /** * Console error test generated by LINKS object array data. */ for (const link of ESM_LINKS) { - vpTest.only(`Test console errors on link ${link.name}`, async ({ page, consoleErrors, vpExamples }) => { + vpTest(`Test console errors on link ${link.name}`, async ({ page, consoleErrors, vpExamples }) => { vpTest.skip(link.name === 'Adaptive Streaming', 'Flaky on CI'); - console.log('process.env.PREVIEW_URL: ', process.env.PREVIEW_URL); - + //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 expect(async () => { - console.log('Navigate to esm page'); - await page.goto(process.env.PREVIEW_URL); - const linkLocator = page.getByRole('link', { name: link.name, exact: true }); - console.log('wait for link to be visible: ', await linkLocator.isVisible()); - await expect(linkLocator).toBeVisible({ timeout: 3000 }); - PREVIEW_URL_LOADED = true; - }).toPass({ intervals: [1_000], timeout: 120000 }); + await waitForDeployPreviewUrl(ESM_URL, page); } - await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); await waitForPageToLoadWithTimeout(page, 5000); @@ -66,14 +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. + * Waits for a deploy preview URL to become available by making repeated requests and check that link is visible. */ -// async function waitForDeployPreviewUrl(url: string, page: Page): Promise { -// await expect(async () => { -// console.log('Waiting for deploy preview to be ready...'); -// const response = await page.request.get(url); -// expect(response.status()).toBe(200); -// console.log('Deploy preview is now available!'); // Print to console when ready -// }).toPass(); -// } +async function waitForDeployPreviewUrl(url: string, page: Page): Promise { + console.log('Waiting for deploy preview to be ready...'); + 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 }); + PREVIEW_URL_LOADED = true; + }).toPass({ intervals: [1_000], timeout: 120000 }); +} diff --git a/test/e2e/testData/esmPageLinksData.ts b/test/e2e/testData/esmPageLinksData.ts index b702e187..6cb6fad6 100644 --- a/test/e2e/testData/esmPageLinksData.ts +++ b/test/e2e/testData/esmPageLinksData.ts @@ -11,29 +11,29 @@ export const ESM_LINKS: ExampleLinkType[] = [ { name: 'Autoplay on Scroll', endpoint: 'autoplay-on-scroll' }, { name: 'Chapters', endpoint: 'chapters' }, { name: 'Cloudinary Analytics', endpoint: 'cloudinary-analytics' }, - // { name: 'Codecs and formats', endpoint: 'codec-formats' }, - // { name: 'Colors API', endpoint: 'colors' }, - // { name: 'Components', endpoint: 'components' }, - // { name: 'Custom Errors', endpoint: 'custom-cld-errors' }, - // { name: 'Display Configurations', endpoint: 'ui-config' }, - // { name: 'Debug', endpoint: 'debug' }, - // { name: 'Floating Player', endpoint: 'floating-player' }, - // { name: 'Fluid Layouts', endpoint: 'fluid' }, - // { name: 'Force HLS Subtitles', endpoint: 'force-hls-subtitles' }, - // { name: 'Highlights Graph', endpoint: 'highlights-graph' }, - // { name: 'Interaction Area', endpoint: 'interaction-area' }, - // { name: 'Multiple Players', endpoint: 'multiple-players' }, - // { name: 'Playlist', endpoint: 'playlist' }, - // { name: 'Playlist by Tag', endpoint: 'playlist-by-tag' }, - // { name: 'Poster Options', endpoint: 'poster' }, - // { name: 'Profiles', endpoint: 'profiles' }, - // { name: 'Raw URL', endpoint: 'raw-url' }, - // { name: 'Recommendations', endpoint: 'recommendations' }, - // { name: 'Seek Thumbnails', endpoint: 'seek-thumbs' }, - // { name: 'Shoppable Videos', endpoint: 'shoppable' }, - // { name: 'Subtitles & Captions', endpoint: 'subtitles-and-captions' }, - // { name: 'Video Transformations', endpoint: 'transformations' }, - // { name: 'UI Config', endpoint: 'ui-config' }, - // { name: 'VAST & VPAID Support', endpoint: 'vast-vpaid' }, - // { name: 'VR/360 Videos', endpoint: '360' }, + { name: 'Codecs and formats', endpoint: 'codec-formats' }, + { name: 'Colors API', endpoint: 'colors' }, + { name: 'Components', endpoint: 'components' }, + { name: 'Custom Errors', endpoint: 'custom-cld-errors' }, + { name: 'Display Configurations', endpoint: 'ui-config' }, + { name: 'Debug', endpoint: 'debug' }, + { name: 'Floating Player', endpoint: 'floating-player' }, + { name: 'Fluid Layouts', endpoint: 'fluid' }, + { name: 'Force HLS Subtitles', endpoint: 'force-hls-subtitles' }, + { name: 'Highlights Graph', endpoint: 'highlights-graph' }, + { name: 'Interaction Area', endpoint: 'interaction-area' }, + { name: 'Multiple Players', endpoint: 'multiple-players' }, + { name: 'Playlist', endpoint: 'playlist' }, + { name: 'Playlist by Tag', endpoint: 'playlist-by-tag' }, + { name: 'Poster Options', endpoint: 'poster' }, + { name: 'Profiles', endpoint: 'profiles' }, + { name: 'Raw URL', endpoint: 'raw-url' }, + { name: 'Recommendations', endpoint: 'recommendations' }, + { name: 'Seek Thumbnails', endpoint: 'seek-thumbs' }, + { name: 'Shoppable Videos', endpoint: 'shoppable' }, + { name: 'Subtitles & Captions', endpoint: 'subtitles-and-captions' }, + { name: 'Video Transformations', endpoint: 'transformations' }, + { name: 'UI Config', endpoint: 'ui-config' }, + { name: 'VAST & VPAID Support', endpoint: 'vast-vpaid' }, + { name: 'VR/360 Videos', endpoint: '360' }, ]; From 3fca8c07f19495870fa4c8144a9b0319c48cfbbd Mon Sep 17 00:00:00 2001 From: shaylevi Date: Wed, 30 Oct 2024 20:01:27 +0200 Subject: [PATCH 36/38] vp test: modify waitForDeployPreviewUrl --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index b2bb0ced..abf1b507 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -3,7 +3,7 @@ import { vpTest } from '../fixtures/vpTest'; import { ESM_LINKS } from '../testData/esmPageLinksData'; import { waitForPageToLoadWithTimeout } from '../src/helpers/waitForPageToLoadWithTimeout'; import { validatePageErrors } from '../src/helpers/validatePageErrors'; -import { link } from 'node:fs'; +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. @@ -19,7 +19,7 @@ for (const link of ESM_LINKS) { 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 && !PREVIEW_URL_LOADED) { - await waitForDeployPreviewUrl(ESM_URL, page); + await waitForDeployPreviewUrl(link, page); } await page.goto(ESM_URL); await vpExamples.clickLinkByName(link.name); @@ -61,7 +61,7 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM /** * Waits for a deploy preview URL to become available by making repeated requests and check that link is visible. */ -async function waitForDeployPreviewUrl(url: string, page: Page): Promise { +async function waitForDeployPreviewUrl(link: ExampleLinkType, page: Page): Promise { console.log('Waiting for deploy preview to be ready...'); await expect(async () => { await page.goto(process.env.PREVIEW_URL); From b1286a06c783ccfd6a6ee7e6d3056747351b2471 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Thu, 31 Oct 2024 10:27:47 +0200 Subject: [PATCH 37/38] vp test: refactor based on review comments --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index abf1b507..a240a602 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -7,9 +7,9 @@ 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; +const ESM_URL = process.env.PREVIEW_URL ?? EDGE_ESM_URL; // Flag to indicate if the deploy preview URL is ready -let PREVIEW_URL_LOADED = false; +let isPreviewUrlLoaded = false; /** * Console error test generated by LINKS object array data. @@ -18,7 +18,7 @@ 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'); //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) { + if (process.env.PREVIEW_URL && !isPreviewUrlLoaded) { await waitForDeployPreviewUrl(link, page); } await page.goto(ESM_URL); @@ -67,6 +67,6 @@ async function waitForDeployPreviewUrl(link: ExampleLinkType, page: Page): Promi 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; + isPreviewUrlLoaded = true; }).toPass({ intervals: [1_000], timeout: 120000 }); } From 636a3ca241ffaaae845ac5c9bc01cdc6a9c5e8f8 Mon Sep 17 00:00:00 2001 From: shaylevi Date: Mon, 4 Nov 2024 09:23:53 +0200 Subject: [PATCH 38/38] vp test: remove console log print --- test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts index a240a602..5652d157 100644 --- a/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts +++ b/test/e2e/specs/linksConsoleErrorsEsmPage.spec.ts @@ -62,7 +62,6 @@ function handleCommonEsmBrowsersErrors(linkName: string, consoleErrors: ConsoleM * 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 { - console.log('Waiting for deploy preview to be ready...'); await expect(async () => { await page.goto(process.env.PREVIEW_URL); const linkLocator = page.getByRole('link', { name: link.name, exact: true });