Skip to content

Playwright E2E tests for dapp wallet auth flow #36

Description

@Cbiux

Summary

Add Playwright E2E tests for the dapp wallet auth flow — connect, sign challenge, receive JWT, reach dashboard.

Unit tests cover Server crypto; this catches Front regressions (#11).


Setup

Directory: Front/e2e/

Tooling: @playwright/test

Mock strategy: Mock Freighter / Wallets Kit at browser level:

await page.addInitScript(() => {
  window.__MOCK_WALLET__ = {
    address: "GD4ELZEONXZANIWRJAED5JPBN7KJG6ZQ5AV46HRLZRTEFNKWJP3UFREL",
    signMessage: async () => "mock_base64_sig",
  };
});

Or use Playwright route interception on /api/auth/* with a running local API (npm run dev:server).


Test cases

Spec Asserts
auth-register.spec.ts /register → dashboard redirect, sessionStorage has token
auth-guard.spec.ts /dashboard without session → redirect /login
auth-logout.spec.ts Clear session → cannot access profile API

CI

Add job to .github/workflows/ci.yml:

e2e:
  runs-on: ubuntu-latest
  services:
    mysql: ...
  steps:
    - run: npm run dev:server &  # or test server
    - run: npx playwright test --prefix Front

Acceptance criteria

  • npx playwright test passes locally with Docker MySQL
  • Covers register + login happy path
  • Runs in CI (or documented skip if flaky without wallet mock)
  • Front/package.json scripts: test:e2e, test:e2e:ui

References

  • Auth flow: Front/components/wallet-auth-card.tsx
  • API client: Front/lib/api-client.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSPart of the GrantFox OSS programMaybe RewardedThis issue may receive a reward or bountyOfficial CampaignPart of an official ZCore campaignenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions