Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI : Add visual regression testing workflow based on Playwright and Argos. #511

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

asr2003
Copy link

@asr2003 asr2003 commented Feb 13, 2025

No description provided.

Copy link

netlify bot commented Feb 13, 2025

Deploy Preview for permitio-docs ready!

Name Link
🔨 Latest commit 074ddbf
🔍 Latest deploy log https://app.netlify.com/sites/permitio-docs/deploys/67ae35efdf196f0008669ef9
😎 Deploy Preview https://deploy-preview-511--permitio-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@asr2003
Copy link
Author

asr2003 commented Feb 13, 2025

@gemanor @filipermit Here's the PR and can you approve workflow? It had passed for me locally and lets see here in upstream

@gemanor
Copy link
Collaborator

gemanor commented Feb 14, 2025

Let me connect the Argos app to the repository, so we can run it on a fork

Copy link

argos-ci bot commented Feb 14, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 🔘 Orphan build (Review) 281 added Feb 14, 2025, 10:43 AM

Copy link
Collaborator

@gemanor gemanor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, left some comments.

You also need to add the following to the .gitignore so it will make it available for local testing:

# Playwright
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
screenshots


- name: Upload screenshots to Argos
env:
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to remove it, see if we can run the workflow without it

run: yarn playwright install --with-deps chromium

- name: Build the website
run: yarn docusaurus build
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why yarn and not npm/npx?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho npm would better suit our case here.
image
source: https://www.syncfusion.com/blogs/post/pnpm-vs-npm-vs-yarn

Comment on lines +1 to +12
iframe,
.avatar__photo,
img[src$='.gif'],
.DocSearch-Button-Keys > kbd,
[class*='playgroundPreview'] {
visibility: hidden;
}

.theme-last-updated,
.docusaurus-mermaid-container {
display: none;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please implement the recommendation from the comment in the issue (for video, for example)

Suggested change
iframe,
.avatar__photo,
img[src$='.gif'],
.DocSearch-Button-Keys > kbd,
[class*='playgroundPreview'] {
visibility: hidden;
}
.theme-last-updated,
.docusaurus-mermaid-container {
display: none;
}
/* Iframes can load lazily */
iframe,
/* Avatars can be flaky due to using external sources: GitHub/Unavatar */
.avatar__photo,
/* Gifs load lazily and are animated */
img[src$='.gif'],
/* Algolia keyboard shortcuts appear with a little delay */
.DocSearch-Button-Keys>kbd,
/* The live playground preview can often display dates/counters */
[class*='playgroundPreview'] {
visibility: hidden;
}
/* Different docs last-update dates can alter layout */
.theme-last-updated,
/* Mermaid diagrams are rendered client-side and produce layout shifts */
.docusaurus-mermaid-container {
display: none;
}
/* Videos are laggy and the loading spinner is shown as change on Argos */
video {
visibility: hidden;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this from docs/utils since it's only used for tests.

It's only 17 lines, so I'd say it's ok to leave it at screenshot.spec.ts

Alternatively, you can create a tests folder to put screenshot.css, screenshot.spec.ts and this helper.

Copy link

@ologbonowiwi ologbonowiwi Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a specific reason for using typescript here?

I haven't seen ts anywhere else in the codebase, so it's safer to assume we should keep it JavaScript-only (as it does not offer any advantage other than code completion—which can be achieved via JSDocs—for a simple implementation like this).

I know technically playwright handles the TS overhead (transpilation, etc), but I'm afraid this will confuse future testers; should they be done in JS or TS? If they're done outside of playwright scope (e.g unit/integration tests) we'd need to add tsc and typescript to the repo.

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: current

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current v23 will be gone in April and can introduce bugs that bjork the pipeline.

personally I'd go with v22/22, but if you find a lts option for this, that would be fantastic too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants