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

chore(visual-regression): add script to update ground truths #29204

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

Conversation

thetaPC
Copy link
Contributor

@thetaPC thetaPC commented Mar 22, 2024

Issue number: N/A


What is the current behavior?

Devs would have to manually generate the ground truths from their desired base branch. This causes a dev to checkout the base branch and pull the latest screenshots. They would then return to their working branch and start the E2E tests.

What is the new behavior?

A script has been created to automate this process using Docker as mentioned in the design doc:

  • It will ask the user a set a questions like if which component they want to test

Does this introduce a breaking change?

  • Yes
  • No

Other information

How to test:

  1. Make a change to a desired component
  2. Run npm run test.e2e.script
  3. Answer the questions
  4. Verify that the tests fail due to visual changes
  5. Re-run the command as many times as necessary in order to try different routes based on different answers

@github-actions github-actions bot added the package: core @ionic/core package label Mar 22, 2024
@thetaPC thetaPC marked this pull request as ready for review March 28, 2024 15:49
@thetaPC thetaPC requested a review from a team as a code owner March 28, 2024 15:49
@thetaPC thetaPC requested review from amandaejohnston and removed request for a team March 28, 2024 15:49
Copy link
Contributor

@amandaejohnston amandaejohnston left a comment

Choose a reason for hiding this comment

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

Thank you!

@thetaPC
Copy link
Contributor Author

thetaPC commented Apr 1, 2024

Also adding Liam and Brandy as reviewers since they've worked on the visual regression changes.

Copy link
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

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

I am running into the following error when running this branch locally:

$ npm run test.e2e.script

> @ionic/[email protected] test.e2e.script
> sh src/utils/test/playwright/e2e-script.sh

Do you want to update your local ground truths? (y/n)
y
Enter the base branch name (default: main):


Updating the base branch...

From https://github.com/ionic-team/ionic-framework
 * branch                  main       -> FETCH_HEAD
Successfully rebased and updated refs/heads/visual-regression-script.

Building core...

....

Enter the component or path you want to test (e.g. chip, src/components/chip). Or leave empty to test all components:
chip

Updating local ground truths...
fatal: invalid reference: origin/

Running e2e tests...

Copy link

vercel bot commented Apr 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ionic-framework ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2024 6:42pm

@thetaPC
Copy link
Contributor Author

thetaPC commented May 2, 2024

@brandyscarney ready for review

Copy link
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

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

This is looking really good! I added a few comments. I am not sure if they should block this being merged. Let me know your thoughts!


// Ask user if they want to open the Playwright report.
const shouldOpenReport = await confirm({
message: 'Do you want to open the Playwright report?',
Copy link
Member

Choose a reason for hiding this comment

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

The command doesn't end when you say "Yes" here unless you do a cmd + C which prints an error:

Screenshot 2024-05-07 at 6 49 23 PM

// User chose to open the Playwright report.
if (shouldOpenReport) {
await execAsync('npx playwright show-report').catch(() => {
console.error('Error: Failed to open the Playwright report or user closed the report');
Copy link
Member

Choose a reason for hiding this comment

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

This error doesn't seem to print when I close the report

else {
// Update the local ground truths for all components.
await execAsync(`git checkout origin/${baseBranch} -- src/components/*/test/*/*.e2e.ts-snapshots/*-linux.png`).catch((error) => {
updateGroundTruth.stop('Failed to update local ground truths');
Copy link
Member

Choose a reason for hiding this comment

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

Trying to update the ground truths from a branch that doesn't have some screenshots causes errors:

Screenshot 2024-05-07 at 7 02 30 PM

I'm not sure if this is expected or something we want to catch.

}

// User chose to open the Playwright report.
if (shouldOpenReport) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we print the npx playwright show-report command if they say "No" in case they want to view it later?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants