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();