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

feat(lab): scaffolds a basic UI test #1581

Closed
wants to merge 1 commit into from
Closed

feat(lab): scaffolds a basic UI test #1581

wants to merge 1 commit into from

Conversation

arein
Copy link
Member

@arein arein commented Dec 17, 2023

Breaking Changes

N/A

Changes

  • feat(lab): scaffolds a basic UI test

Next: #1582

Associated Issues

closes #...

Copy link

vercel bot commented Dec 17, 2023

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

Name Status Preview Updated (UTC)
web3modal-gallery ✅ Ready (Inspect) Visit Preview Dec 18, 2023 10:22am
web3modal-laboratory ✅ Ready (Inspect) Visit Preview Dec 18, 2023 10:22am
web3modal-react-wagmi-ex ✅ Ready (Inspect) Visit Preview Dec 18, 2023 10:22am
web3modal-vue-wagmi-ex ✅ Ready (Inspect) Visit Preview Dec 18, 2023 10:22am

Copy link
Member

@chris13524 chris13524 left a comment

Choose a reason for hiding this comment

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

1 more thing 🙏

@@ -5,7 +5,11 @@
"scripts": {
"dev:laboratory": "next dev",
"build:laboratory": "next build",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"playwright:start": "turbo run build; npm run dev:laboratory",
Copy link
Member

@chris13524 chris13524 Dec 17, 2023

Choose a reason for hiding this comment

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

Since I don't have turbo installed, I can't run npm run playwright:test locally. We should make a npm run turbo-build -> turbo run build script and call that here instead

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I can remove the turbo run build from the command. Would that address your concern?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can run npm run build instead

Copy link
Member

Choose a reason for hiding this comment

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

@arein the script is broken now; you can't run npm run build in the lab directory; that script does not exist. turbo run build worked because it recurses into the parent directory.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right actually. For everything to work properly / build packages etc. Set up and commands should be ran from the monorepo root. Similarly something like npm run laboratory should be ran from there. Doing otherwise i.e. running from individual packages could have unexpected side effects probably

Copy link
Member Author

Choose a reason for hiding this comment

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

ok fixed

Copy link
Contributor

@xzilja xzilja left a comment

Choose a reason for hiding this comment

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

This sets everything up nicely, but does not include new approach we discussed with Jon, Sven and others for v3 testing.

Due to fast moving pace and changes, we'd need to spend substantial amount of time on re-updating tests if they are based on granular checks i.e. like you check for All Wallets.

Road forward with v3 that will keep us moving fast while providing good feedback on breaking something is through playwrights visual diff tests

More context here https://playwright.dev/docs/test-snapshots

TL;DR these are extremely cheap to set up dev time wise for existing and upcoming features while providing really good feedback on breaking changes i.e. if something is off, pixels will be off as well (missing notification. modal not open etc.). Updating these will be easy as well, i.e. if something changed and it was expected, we just update reference screenshot.

@arein Could you please switch from using "All Wallets" detection in the test, to one using screenshot diffing i.e. snap of open modal.

.github/workflows/ui_tests.yml Show resolved Hide resolved
use: { ...devices['Desktop Firefox'] }
}

/* Test against mobile viewports. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Either needs a TODO or to be removed if unused

@@ -5,7 +5,11 @@
"scripts": {
"dev:laboratory": "next dev",
"build:laboratory": "next build",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"playwright:start": "turbo run build; npm run dev:laboratory",
Copy link
Contributor

Choose a reason for hiding this comment

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

You are right actually. For everything to work properly / build packages etc. Set up and commands should be ran from the monorepo root. Similarly something like npm run laboratory should be ran from there. Doing otherwise i.e. running from individual packages could have unexpected side effects probably

@arein
Copy link
Member Author

arein commented Dec 18, 2023

You are right actually. For everything to work properly / build packages etc. Set up and commands should be ran from the monorepo root. Similarly something like npm run laboratory should be ran from there. Doing otherwise i.e. running from individual packages could have unexpected side effects probably

What's actually requested?
As a developer I must be able to run e2e tests from monorepo root?

This sets everything up nicely, but does not include new approach we discussed with Jon, Sven and others for v3 testing.
Due to fast moving pace and changes, we'd need to spend substantial amount of time on re-updating tests if they are based on granular checks i.e. like you check for All Wallets.
Road forward with v3 that will keep us moving fast while providing good feedback on breaking something is through playwrights visual diff tests
More context here https://playwright.dev/docs/test-snapshots
TL;DR these are extremely cheap to set up dev time wise for existing and upcoming features while providing really good feedback on breaking changes i.e. if something is off, pixels will be off as well (missing notification. modal not open etc.). Updating these will be easy as well, i.e. if something changed and it was expected, we just update reference screenshot.
@arein Could you please switch from using "All Wallets" detection in the test, to one using screenshot diffing i.e. snap of open modal.

I'm scaffolding everything here @0xasimetriq specifically to avoid comments like these. I am not actually testing anything here. The All Wallets is just a placeholder tests. I don't see how this setup cannot be used later for actual diffs

@@ -5,7 +5,12 @@
"scripts": {
"dev:laboratory": "next dev",
"build:laboratory": "next build",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
"build:all": "turbo run build",
Copy link
Contributor

Choose a reason for hiding this comment

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

Turborepo and monorepo wide commands should not be ran from here. There is global npm run build command that does exactly this in the root, can that be reused? It also sets up clean builds properly for all packages.

You will likely need to move playwright commands and test dependencies to monorepo root as well and just target tests inside laboratory folder.

@chris13524
Copy link
Member

Due to fast moving pace and changes, we'd need to spend substantial amount of time on re-updating tests if they are based on granular checks i.e. like you check for All Wallets.

Road forward with v3 that will keep us moving fast while providing good feedback on breaking something is through playwrights visual diff tests

Taking full advantage of Playwright will involve a lot more than screenshots; every edge case should have a test case and needing to update something trivial like "All Wallets" will be the least of your concerns when changing stuff around.

@xzilja
Copy link
Contributor

xzilja commented Dec 18, 2023

You are right actually. For everything to work properly / build packages etc. Set up and commands should be ran from the monorepo root. Similarly something like npm run laboratory should be ran from there. Doing otherwise i.e. running from individual packages could have unexpected side effects probably

What's actually requested? As a developer I must be able to run e2e tests from monorepo root?

This sets everything up nicely, but does not include new approach we discussed with Jon, Sven and others for v3 testing.
Due to fast moving pace and changes, we'd need to spend substantial amount of time on re-updating tests if they are based on granular checks i.e. like you check for All Wallets.
Road forward with v3 that will keep us moving fast while providing good feedback on breaking something is through playwrights visual diff tests
More context here https://playwright.dev/docs/test-snapshots
TL;DR these are extremely cheap to set up dev time wise for existing and upcoming features while providing really good feedback on breaking changes i.e. if something is off, pixels will be off as well (missing notification. modal not open etc.). Updating these will be easy as well, i.e. if something changed and it was expected, we just update reference screenshot.
@arein Could you please switch from using "All Wallets" detection in the test, to one using screenshot diffing i.e. snap of open modal.

I'm scaffolding everything here @0xasimetriq specifically to avoid comments like these. I am not actually testing anything here. The All Wallets is just a placeholder tests. I don't see how this setup cannot be used later for actual diffs

So for Q1, right now there seems to be a build:all setup in laboratory using global turborepo command. This should not be the case case, build depends on all packages, so it should be only ran and set up in root of the monorepo. I left separate suggestion about moving playwright tests to root as well.

For Q2, we should scaffold screenshot diffing flow in this pr as well, a simple single screenshot check for now will be sufficient. Idea is to have devs be able to start with this scaffold right away right, so without them needing to add this logic in. Otherwise this scaffold is likely incomplete imho.

@xzilja xzilja closed this Dec 18, 2023
@arein arein mentioned this pull request Dec 18, 2023
@xzilja
Copy link
Contributor

xzilja commented Dec 18, 2023

Due to fast moving pace and changes, we'd need to spend substantial amount of time on re-updating tests if they are based on granular checks i.e. like you check for All Wallets.
Road forward with v3 that will keep us moving fast while providing good feedback on breaking something is through playwrights visual diff tests

Taking full advantage of Playwright will involve a lot more than screenshots; every edge case should have a test case and needing to update something trivial like "All Wallets" will be the least of your concerns when changing stuff around.

Yes, but remember this is ui product so majority of issues will bubble up to ui, which is why screenshot diffing is great here. I.e if you set an option to disable metamask, all you have to do is screenshot that and it should not be there, if it is, then we made a regression. This applies to almost every config / action in web3modal, if something is wrong it will result in a different visual to what is expected (even text in error notifications for example)

@chris13524
Copy link
Member

Yes, but remember this is ui product so majority of issues will bubble up to ui, which is why screenshot diffing is great here. I.e if you set an option to disable metamask, all you have to do is screenshot that and it should not be there, if it is, then we made a regression. This applies to almost every config / action in web3modal, if something is wrong it will result in a different visual to what is expected (even text in error notifications for example)

Yes, but I feel like this is the easy way out and is easier to mess up. There's 1 command that will reset all of the screenshots. So say you have a new feature that adds a new wallet to the list of wallets, and you reset all of the screenshots. You get your new wallet, but you also removed MetaMask without realizing it. Simply the screenshot checks will not detect this problem.

Now since the screenshots are committed and reviewed, hopefully someone will notice that the one called "MetaMask exists" does indeed still contain a MetaMask.

I guess my point is that it's easier to mess up an image than an explicit code removal/modifiction of the MetaMask test case.

I haven't used these snapshots before, so maybe I'll see the light :D

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.

None yet

3 participants