Skip to content

Conversation

@rin-st
Copy link
Member

@rin-st rin-st commented Sep 3, 2025

E2e tests for user registration + gh action.

Testing wallet: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266


To initialize playwright run in your nextjs folder (only first time)

yarn next:playwright-install

Build wallet cache. It couldn't install metamask extension (11.9.1) with latest versions of playwright/synpress so I used older versions, which use a bit older chromium and MM works fine with it

yarn next:cache-synpress

docs: https://docs.synpress.io/docs/setup-playwright


To run tests locally

yarn next:test
from root folder or yarn next:test-ui if you want to see and analyze how it looks

There's one bug though, when running yarn next:test you can meet the error Error: Cache for 08a20e3c7fc77e6ae298 does not exist. Create it first!. In that case you need to rename your cache folder name to that "does not exist" cache packages/nextjs/.cache-synpress/<cache-folder>. In my case it's 532f685e346606c2a803 to 08a20e3c7fc77e6ae298

Since the testing user is registered, to make the test work again you need to run remove user from db or run yarn db:seed

fixes: #313

@vercel
Copy link

vercel bot commented Sep 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
speedrunethereum-v2 Ready Ready Preview Comment Nov 4, 2025 8:34am

@rin-st
Copy link
Member Author

rin-st commented Oct 15, 2025

And playwright is not able to input password in metamask popup extension, can you please try once?

For me it works as expected

Also another things which we can ignore is, we get this in CI:

There was a typo in NEXTAUTH vars, fixed! b652ffc

So currently we only have an issue with zerion api key, but I think we can skip it for now

Run xvfb-run yarn next:test
  xvfb-run yarn next:test
  shell: /usr/bin/bash -e {0}
  env:
    CI: true
    NODE_ENV: test
    POSTGRES_URL: ***localhost:5432/postgres
    NEXTAUTH_SECRET: 1234567890
    NEXTAUTH_URL: http://localhost:3000
    ZERION_API_KEY: test_api_key_for_ci
    PLAYWRIGHT_TEST_BASE_URL: http://localhost:3000

Running 1 test using 1 worker

[WebServer] Error checking side quest contractDeployed for user 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266: Error: Failed to fetch transactions from Zerion: Unauthorized
[WebServer]     at d (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:669)
[WebServer]     at async Object.check (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:1316)
[WebServer]     at async e (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:10724)
[WebServer]     at async h (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:11309)
[WebServer]     at async (.next/server/app/api/users/register/route.js:1:4173)
[WebServer] Error fetching side quests snapshot: Error: Failed to fetch transactions from Zerion: Unauthorized
[WebServer]     at d (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:669)
[WebServer]     at async Object.check (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:1316)
[WebServer]     at async e (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:10724)
[WebServer]     at async h (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:11309)
[WebServer]     at async (.next/server/app/api/users/register/route.js:1:4173)
[WebServer] Error in background processing for user 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266: Error: Failed to fetch transactions from Zerion: Unauthorized
[WebServer]     at d (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:669)
[WebServer]     at async Object.check (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:1316)
[WebServer]     at async e (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:10724)
[WebServer]     at async h (.next/server/app/api/users/[address]/update-onchain-data/route.js:1:11309)
[WebServer]     at async (.next/server/app/api/users/register/route.js:1:4173)
  ✓  1 [chromium] › 01_user_onboarding.spec.ts:10:3 › User Onboarding Flow › Should complete full user onboarding flow: connect wallet, register user, and verify address display (19.9s)
Warning: packages/nextjs/[chromium] › 01_user_onboarding.spec.ts took 19.9s
Notice:   1 passed (25.7s)

  Slow test file: [chromium] › 01_user_onboarding.spec.ts (19.9s)
  Consider splitting slow test files to speed up parallel execution
  1 passed (25.7s)

@technophile-04
Copy link
Member

technophile-04 commented Oct 20, 2025

Ohh thanks @rin-st!! I just tried locally again and lol it started working for me as well (myabe I re-downloaded the playwright browser).

Also another last thing sorry 😅, I was talking with Carlos, and he observed it takes a lot of time for CI to run :

image

Maybe there is a better way to cache this Playwright browser install? Maybe we find something here?

microsoft/playwright#7249

Also here in their setup it took only 55 sec:
https://playwright.dev/docs/ci-intro#opening-the-workflows

@rin-st
Copy link
Member Author

rin-st commented Oct 20, 2025

Good point, added cache step 1c4be91

image

Action:
https://github.com/BuidlGuidl/SpeedRunEthereum-v2/actions/runs/18653348316/job/53177104497

Also as an option we can install only chromium browser since we disabled tests for others. But I think it's not necessary right now

Copy link
Member

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

microsoft/playwright#7249 (comment)

Like here they said, it not recommended to cache the browser...Shall we try with just Chromium and see how long it takes? (ideally, maybe we should run for diff types of browser) But I think we can go more robust in the future 🙌

If it still takes a very long time for only Chromium, then we could go with the cache. What do you think?

But this is already looking great! Thanks Rinat!!

@rin-st
Copy link
Member Author

rin-st commented Oct 21, 2025

Updated! Tried two times and lol it took only 7 and 10 sec

Copy link
Member

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

Updated! Tried two times and lol it took only 7 and 10 sec

NOICEE this is what we wanted! This is looking great! TYSM Rinat 🙏

@carletex
Copy link
Member

love this, thank you all! Let me play with it a bit before merging (maybe next week)

@carletex
Copy link
Member

carletex commented Nov 3, 2025

Hey guys! Followed all the steps, and running the test locally (i tried a few times) I always get this error

image

I can see it opening the mm extension, putting the pass, go to the homepage.... and then it just stays there for a while (with not visual movement) until it throws the error.

Any ideas?

@rin-st
Copy link
Member Author

rin-st commented Nov 3, 2025

Could you try to run yarn next:test-ui and then run it (click inner play button). It seems for some reason you don't have modal or metamask button. What do you see when you click on the actions before selected?

image

@technophile-04
Copy link
Member

technophile-04 commented Nov 3, 2025

Ohh I think it has something to with palywright browsers version.

For me it was working perfectly fine but then i uninstalled the playwright browser using:

npx playwright@latest uninstall --all

And then install it again via yarn next:playwright-browser and it started failing for me (maybe Carlos is also using the latest failing browser?)

I can see it opening the mm extension, putting the pass, go to the homepage.... and then it just stays there for a while (with not visual movement) until it throws the error.

For me it connects the wallet, I see the connected address and then get stuck (not doing the signature)

Error
❯ yarn next:test

Running 1 test using 1 worker

  ✘  1 … Onboarding Flow › Should complete full user onboarding flow: connect wallet, register user, and verify address display (41.1s)


  1) [chromium] › 01_user_onboarding.spec.ts:10:3 › User Onboarding Flow › Should complete full user onboarding flow: connect wallet, register user, and verify address display

    TimeoutError: locator.waitFor: Timeout 30000ms exceeded.
    Call log:
      - waiting for getByTestId('register-user-tooltip') to be visible


      31 |
      32 |     // Step 2: Verify wallet connection and registration prompt
    > 33 |     await page.getByTestId("register-user-tooltip").waitFor({
         |                                                     ^
      34 |       state: "visible",
      35 |       timeout: 30000,
      36 |     });

        at SpeedRunEthereum-v2/packages/nextjs/test/01_user_onboarding.spec.ts:33:53

    attachment #1: screenshot (image/png) ──────────────────────────────────────────────────────────
    test-results/01_user_onboarding-User-On-8ee17--and-verify-address-display-chromium/test-failed-1.png
    ────────────────────────────────────────────────────────────────────────────────────────────────

    attachment #2: screenshot (image/png) ──────────────────────────────────────────────────────────
    test-results/01_user_onboarding-User-On-8ee17--and-verify-address-display-chromium/test-failed-2.png
    ────────────────────────────────────────────────────────────────────────────────────────────────

  Slow test file: [chromium] › 01_user_onboarding.spec.ts (41.1s)
  Consider splitting slow test files to speed up parallel execution
  1 failed
    [chromium] › 01_user_onboarding.spec.ts:10:3 › User Onboarding Flow › Should complete full user onboarding flow: connect wallet, register user, and verify address display

To open last HTML report run:

  yarn playwright show-report

And If I run with yarn next:test-ui I get this:

Screenshot 2025-11-03 at 5 51 31 PM

@rin-st
Copy link
Member Author

rin-st commented Nov 3, 2025

And then install it again via yarn next:playwright-browser and it started failing for me (maybe Carlos is also using the latest failing browser?)

For me it still works 🤷‍♂️

For me it connects the wallet, I see the connected address and then get stuck (not doing the signature)

Your error is different (// Step 2). I think it's because you forgot to do yarn db:seed before running tests again

@technophile-04
Copy link
Member

technophile-04 commented Nov 3, 2025

Ohh it just worked for me!

@carletex Can you try this steps once:

Uninstall playwright browser:

npx playwright@latest uninstall --all

Install playrwright browser:

yarn next:playwright-install

Cache Synpress:

yarn next:cache-synpress

Mv cached id to correct path:

mv packages/nextjs/.cache-synpress/532f685e346606c2a803 packages/nextjs/.cache-synpress/08a20e3c7fc77e6ae298

Seed the DB:

yar db:seed

Run the test:

yarn next:test

Copy link
Member

@carletex carletex left a comment

Choose a reason for hiding this comment

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

Thanks guys!! Got it working after your feedback.

I uninstalled the browsers and installed them again... and the everything started working properly. I had to increase the timeout, but that is just my laptop (faster as a 🐌 haha)

image

this is great stuff, can't wait to add more tests!

This reverts commit 93f5da2.
Copy link
Member

@carletex carletex left a comment

Choose a reason for hiding this comment

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

Merginnnng!

Thanks all

@carletex carletex merged commit 5f1c20e into main Nov 4, 2025
4 checks passed
@carletex carletex deleted the e2e-tests-init branch November 4, 2025 09:48
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.

Gh action for testing

4 participants