From 12b77e63acc6903d0f8db02e523cfc8d12970715 Mon Sep 17 00:00:00 2001 From: Karl Cardenas Date: Mon, 1 Apr 2024 08:41:57 -0700 Subject: [PATCH] ci: fix screenshots --- .github/workflows/visual-comparison.yaml | 2 +- playwright.config.ts | 1 + visuals/screenshot.api.spec.ts | 4 +++- visuals/screenshot.docs.spec.ts | 23 +++-------------------- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/visual-comparison.yaml b/.github/workflows/visual-comparison.yaml index aba0f2576b..31b3e28f81 100644 --- a/.github/workflows/visual-comparison.yaml +++ b/.github/workflows/visual-comparison.yaml @@ -119,7 +119,7 @@ jobs: run: ./scripts/screenshot_artifacts.sh - name: Take screenshots with Playwright - run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} + run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} || exit 0 - name: Upload blob report to GitHub Actions Artifacts uses: actions/upload-artifact@v4 diff --git a/playwright.config.ts b/playwright.config.ts index b9ca554b81..26dfa81892 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -14,6 +14,7 @@ const config: PlaywrightTestConfig = { toHaveScreenshot: { maxDiffPixels: 100, }, + timeout: 30000, }, reporter: [["html", { open: "never" }]], webServer: { diff --git a/visuals/screenshot.api.spec.ts b/visuals/screenshot.api.spec.ts index e8dd1dcf36..3481cbec45 100644 --- a/visuals/screenshot.api.spec.ts +++ b/visuals/screenshot.api.spec.ts @@ -12,7 +12,6 @@ test.describe.configure({ mode: "parallel" }); function isApiDocsPathname(pathname: string, excludeList: string[]): boolean { if (excludeList.includes(pathname)) { - console.log(`Excluding ${pathname}`); return false; } // return false if the pathname does not start with /api/ @@ -37,5 +36,8 @@ function screenshotPathname(pathname: string) { test.describe("API docs screenshots", () => { const pathnames = extractSitemapPathnames(sitemapPath).filter((pathname) => isApiDocsPathname(pathname, excludeList)); + console.log(`Taking screenshots of ${pathnames.length} API docs pages`); + console.log("Excluded pages: ", excludeList); + pathnames.forEach(screenshotPathname); }); diff --git a/visuals/screenshot.docs.spec.ts b/visuals/screenshot.docs.spec.ts index 78dd60bf1b..ae8d0b2763 100644 --- a/visuals/screenshot.docs.spec.ts +++ b/visuals/screenshot.docs.spec.ts @@ -23,17 +23,8 @@ function isVersionedDocsPathname(pathname: string, excludeList: string[]): boole return true; } -// function chunkArray(array: string[], parts: number): string[][] { -// let result: string[][] = []; -// for (let i = parts; i > 0; i--) { -// result.push(array.splice(0, Math.ceil(array.length / i))); -// } -// return result; -// } - function screenshotPathname(pathname: string) { test(`pathname ${pathname}`, async ({ page }) => { - console.log(`Taking screenshot of ${pathname}`); const url = siteUrl + pathname; await page.goto(url); await page.waitForFunction(WaitForDocusaurusHydration); @@ -44,20 +35,12 @@ function screenshotPathname(pathname: string) { }); } -// test.describe("cookie-banner is visible", () => { -// test("cookie-banner is visible", async ({ page }) => { -// await page.goto(siteUrl); -// await page.waitForFunction(WaitForDocusaurusHydration); -// await page.waitForLoadState("domcontentloaded"); -// await page.addStyleTag({ content: stylesheet }); -// await expect(page).toHaveScreenshot({ fullPage: true }); -// await expect(page.getByTestId("#usercentrics-root")).toBeVisible(); -// }); -// }); - test.describe("Docs screenshots", () => { const pathnames = extractSitemapPathnames(sitemapPath).filter((pathname) => isVersionedDocsPathname(pathname, excludeList) ); + console.log(`Taking screenshots of ${pathnames.length} Docs pages`); + console.log("Excluded pages: ", excludeList); + pathnames.forEach(screenshotPathname); });