-
Notifications
You must be signed in to change notification settings - Fork 24
test(demo-wallet): redesign e2e suite — UI mocks + TON Connect mock-dApp #485
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
Open
lesyuk
wants to merge
6
commits into
main
Choose a base branch
from
feat/TON-1701-demo-wallet-e2e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1e5e86f
test(demo-wallet): redesign e2e suite — UI mocks + TON Connect mock-d…
lesyuk 4350db4
ci(demo-wallet): scope default e2e to ui-tests; run mock-dApp suite; …
lesyuk 57a25f8
refactor(demo-wallet e2e): address review — drop redundant minter sui…
lesyuk 7f883ea
docs(demo-wallet e2e): add README (structure, configs, mock-first, Te…
lesyuk e0f07ee
test(demo-wallet e2e): review round-2 fixes + §18 paste/queue/guards …
lesyuk bbaaf89
test(demo-wallet e2e): scrub internal QA refs from public code; wrap …
lesyuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| /** | ||
| * Copyright (c) TonTech. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| */ | ||
|
|
||
| import path from 'path'; | ||
| import { fileURLToPath } from 'url'; | ||
|
|
||
| import { config } from 'dotenv'; | ||
| import { defineConfig, devices } from '@playwright/test'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
|
||
| // Fully mock-first two-tab TON Connect config: pairs the SELF-CONTAINED QA Mock dApp | ||
| // (tab 1, :5175 — `e2e/mock-dapp/`, raw @tonconnect/sdk) with the redesigned demo-wallet | ||
| // (tab 2, :5173). The dApp drives connect / sendTransaction / signData / signMessage over | ||
| // the real TON Connect bridge; the wallet runs with on-chain broadcast suppressed | ||
| // (VITE_DISABLE_NETWORK_SEND) and the manifest domain check disabled | ||
| // (VITE_DISABLE_MANIFEST_DOMAIN_CHECK). Self-contained: it starts both tabs' servers itself. | ||
| config({ quiet: true }); | ||
|
|
||
| const workersCount = process.env.WORKERS_COUNT ? parseInt(process.env.WORKERS_COUNT) : undefined; | ||
| const timeout = process.env.TIMEOUT ? parseInt(process.env.TIMEOUT) : 60_000; | ||
| const headless = | ||
| process.env.ENABLE_HEADLESS === 'true' ? true : process.env.ENABLE_HEADLESS === 'false' ? false : undefined; | ||
|
|
||
| // `127.0.0.1` (NOT `localhost`): WalletKit's manifest `isValidHost` guard rejects dot-less | ||
| // hosts before fetching, regardless of `disableManifestDomainCheck` — see the mock-dApp's | ||
| // main.ts / packages/walletkit/src/utils/url.ts. `127.0.0.1` has dots and passes. | ||
| const APP_URL = process.env.MOCK_DAPP_URL ?? 'http://127.0.0.1:5175/'; | ||
| // Guard against a dot-less host: WalletKit's manifest `isValidHost` rejects `localhost` | ||
| // (no dot) before fetching the manifest, regardless of `disableManifestDomainCheck`, so the | ||
| // connect handshake would fail with a confusing "App manifest not found". Use a dotted host | ||
| // (e.g. 127.0.0.1). See e2e/mock-dapp/main.ts / packages/walletkit/src/utils/url.ts. | ||
| if (new URL(APP_URL).hostname === 'localhost') { | ||
| throw new Error( | ||
| `MOCK_DAPP_URL must use a dotted host (e.g. http://127.0.0.1:5175/), not 'localhost': ` + | ||
| `WalletKit's manifest isValidHost guard rejects dot-less hosts. Got: ${APP_URL}`, | ||
| ); | ||
| } | ||
| const WALLET_SOURCE = process.env.E2E_WALLET_SOURCE ?? 'http://localhost:5173/'; | ||
|
|
||
| // Absolute path to the mock-dApp vite config — robust to the cwd vite is launched from. | ||
| const MOCK_DAPP_VITE_CONFIG = path.resolve(__dirname, 'e2e/mock-dapp/vite.config.ts'); | ||
|
|
||
| // Start the mock-dApp (tab 1) unless an external MOCK_DAPP_URL is supplied. | ||
| const mockDappServer = process.env.MOCK_DAPP_URL | ||
| ? [] | ||
| : [ | ||
| { | ||
| command: `pnpm --filter demo-wallet exec vite --config ${MOCK_DAPP_VITE_CONFIG}`, | ||
| url: 'http://127.0.0.1:5175/', | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 120_000, | ||
| }, | ||
| ]; | ||
|
|
||
| // Start the demo-wallet (tab 2) unless it is served elsewhere. Network send + manifest | ||
| // domain check are disabled so the wallet signs/responds over the bridge without broadcasting | ||
| // and accepts the localhost mock-dApp manifest. | ||
| const walletServer = WALLET_SOURCE.includes('localhost:5173') | ||
| ? [ | ||
| { | ||
| command: | ||
| 'VITE_DISABLE_NETWORK_SEND=true VITE_DISABLE_MANIFEST_DOMAIN_CHECK=true pnpm --filter demo-wallet dev', | ||
| url: 'http://localhost:5173/', | ||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 120_000, | ||
| }, | ||
| ] | ||
| : []; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './e2e/mock-dapp-tests', | ||
| timeout, | ||
| expect: { timeout }, | ||
| fullyParallel: false, | ||
| forbidOnly: !!process.env.CI, | ||
| // The handshake + requests ride the real TON Connect bridge; CI retries absorb transient | ||
| // bridge/timing hiccups (same retry policy as the appkit-minter gasless two-tab gate). | ||
| retries: process.env.CI ? 2 : 0, | ||
| workers: workersCount ?? 1, | ||
| reporter: [['list'], ['allure-playwright']], | ||
| use: { | ||
| baseURL: APP_URL, | ||
| screenshot: 'only-on-failure', | ||
| trace: 'retain-on-failure', | ||
| permissions: ['clipboard-read', 'clipboard-write'], | ||
| launchOptions: { | ||
| args: [ | ||
| '--no-sandbox', | ||
| '--disable-setuid-sandbox', | ||
| '--disable-dev-shm-usage', | ||
| '--no-first-run', | ||
| '--disable-infobars', | ||
| '--disable-blink-features=AutomationControlled', | ||
| ], | ||
| }, | ||
| headless, | ||
| }, | ||
| projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }], | ||
| webServer: [...mockDappServer, ...walletServer], | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # demo-wallet E2E | ||
|
|
||
| Playwright end-to-end tests for the demo-wallet. The suite is **mock-first**: it runs against | ||
| mocked wallet data and never spends real funds, so it is safe to run on every push. | ||
|
|
||
| ## Layout | ||
|
|
||
| | Path | What | | ||
| |------|------| | ||
| | `ui-tests/` | UI specs (onboarding, dashboard, assets, NFT, history, send, swap, staking, amount formatting). Mock-first — wallet data is stubbed via `page.route`. Web-only flows opt into the `webOnly` fixture and skip in extension mode. | | ||
| | `mocks/walletApi.ts` | `page.route` mocks for the wallet's API (Toncenter v3 + rates), plus transfer-emulation / seqno helpers used by the TON Connect transaction flow. | | ||
| | `mock-dapp/` | A **self-contained TON Connect dApp** test fixture (raw `@tonconnect/sdk`) served by Vite on `127.0.0.1:5175`. It exposes connect / sendTransaction / signData / signMessage behind buttons and surfaces every result into DOM test ids. Not product code. | | ||
| | `mock-dapp-tests/` | Two-tab TON Connect specs: the mock dApp (tab 1) drives the redesigned wallet (tab 2) over the real bridge. Each asserts the modal copy + actions and the protocol response. | | ||
| | `ton-connect/` | Drivers for the mock-dApp suite — `MockDapp.ts` (dApp page object) and `mockDappFixture.ts` (two-tab fixture). | | ||
| | `demo-wallet/DemoWallet.ts` | The wallet page object (onboarding, the four TON Connect request modals, internal send). | | ||
| | `pages/`, `qa/` | Wallet page objects and low-level helpers (context launch, extension id, etc.). | | ||
|
|
||
| ## Configs | ||
|
|
||
| | Config | Runs | Servers | | ||
| |--------|------|---------| | ||
| | `e2e.config.ts` (default, `pnpm e2e`) | `ui-tests/**` only | demo-wallet dev server | | ||
| | `e2e.mockdapp.config.ts` | `mock-dapp-tests/**` | mock dApp `:5175` + demo-wallet `:5173` | | ||
|
|
||
| The default config `testIgnore`s the two-tab suite (it has its own servers) and the quarantined | ||
| runner specs (see below), so `pnpm e2e` is just the fast mock-first UI suite. | ||
|
|
||
| ## Running locally | ||
|
|
||
| ```bash | ||
| # Build the workspace deps the app needs (the full `pnpm build` is not required): | ||
| pnpm --filter @ton/walletkit build && pnpm --filter @demo/wallet-core build | ||
|
|
||
| cd apps/demo-wallet | ||
|
|
||
| # UI suite (headless): | ||
| ENABLE_HEADLESS=true pnpm e2e | ||
|
|
||
| # TON Connect two-tab mock-dApp suite: | ||
| ENABLE_HEADLESS=true npx playwright test --config e2e.mockdapp.config.ts | ||
| ``` | ||
|
|
||
| `WALLET_MNEMONIC` (a throwaway test seed) is read from `apps/demo-wallet/.env` (gitignored). | ||
| Kill stray dev servers on `:5173` / `:5175` before re-running. | ||
|
|
||
| ## How the TON Connect suite stays fund-free | ||
|
|
||
| `sendTransaction` / `signMessage` would normally need a funded wallet and would broadcast | ||
| on-chain. The suite avoids both: | ||
|
|
||
| - **Mocked balance** (`mockWalletApi`) so the wallet's balance guard lets the request through | ||
| and the modal renders. | ||
| - **`VITE_DISABLE_NETWORK_SEND=true`** — the wallet signs and returns the response to the dApp | ||
| over the bridge but skips the on-chain broadcast. No funds move. | ||
|
|
||
| The connect handshake and every request ride the real TON Connect bridge. | ||
| `VITE_DISABLE_MANIFEST_DOMAIN_CHECK=true` lets the wallet accept the local mock-dApp manifest | ||
| (served from `127.0.0.1`, which must be dotted — `localhost` is rejected by the manifest host | ||
| guard). | ||
|
|
||
| ## Allure / TestOps | ||
|
|
||
| - The reporter is `allure-playwright`. Cases are matched to TestOps by a **stable `historyId`** | ||
| (the describe chain + test title, set in a shared `beforeEach`), so there is no manual | ||
| `@allureId` pinning: new tests auto-create a case on launch close and survive line shifts and | ||
| file moves. | ||
| - Wrap logical operations in `allure.step('…')` (see `DemoWallet.ts`) so the TestOps execution | ||
| reads as named steps rather than raw Playwright actions. | ||
| - Upload runs in CI only, via secrets — no TestOps endpoint or token lives in this repo. | ||
|
|
||
| ## Quarantined specs | ||
|
|
||
| `connect.spec.ts`, `signData.spec.ts`, `localSendTransaction.spec.ts` and `sendTransaction/**` | ||
| drive an external test-runner backend that is currently unavailable. They are excluded via | ||
| `testIgnore` in `e2e.config.ts` to keep CI within its time budget; re-enable them once that | ||
| backend is restored. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Run the dedicated TON Connect config in CI.
apps/demo-wallet/e2e.config.tsnow ignores**/ton-connect/**, but this step only runs the default config pluse2e.mockdapp.config.ts. That leavesapps/demo-wallet/e2e/ton-connect/connect.spec.tsunexecuted in CI.Suggested change
set +e xvfb-run pnpm e2e; r1=$? - xvfb-run pnpm exec playwright test --config e2e.mockdapp.config.ts; r2=$? - exit $(( r1 || r2 )) + xvfb-run pnpm exec playwright test --config e2e.tonconnect.config.ts; r2=$? + xvfb-run pnpm exec playwright test --config e2e.mockdapp.config.ts; r3=$? + exit $(( r1 || r2 || r3 ))📝 Committable suggestion
🤖 Prompt for AI Agents