Skip to content

Commit

Permalink
ci: fix screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-cardenas-coding committed Apr 1, 2024
1 parent 533aabb commit 12b77e6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/visual-comparison.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config: PlaywrightTestConfig = {
toHaveScreenshot: {
maxDiffPixels: 100,
},
timeout: 30000,
},
reporter: [["html", { open: "never" }]],
webServer: {
Expand Down
4 changes: 3 additions & 1 deletion visuals/screenshot.api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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);
});
23 changes: 3 additions & 20 deletions visuals/screenshot.docs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
});

0 comments on commit 12b77e6

Please sign in to comment.