Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/e2e_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ jobs:
run: |
pnpm build
cd apps/demo-wallet
xvfb-run pnpm e2e
# 1) Default config: mock-first ui-tests only (see e2e.config.ts testIgnore).
# 2) Self-contained two-tab TON Connect mock-dApp suite (starts mock-dApp :5175 +
# demo-wallet :5173 with broadcast/manifest checks disabled). Aggregate exit codes
# so both runs execute and both report into allure-results.
set +e
xvfb-run pnpm e2e; r1=$?
xvfb-run pnpm exec playwright test --config e2e.mockdapp.config.ts; r2=$?
exit $(( r1 || r2 ))
Comment on lines +90 to +97

Copy link
Copy Markdown

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.ts now ignores **/ton-connect/**, but this step only runs the default config plus e2e.mockdapp.config.ts. That leaves apps/demo-wallet/e2e/ton-connect/connect.spec.ts unexecuted 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# 1) Default config: mock-first ui-tests only (see e2e.config.ts testIgnore).
# 2) Self-contained two-tab TON Connect mock-dApp suite (starts mock-dApp :5175 +
# demo-wallet :5173 with broadcast/manifest checks disabled). Aggregate exit codes
# so both runs execute and both report into allure-results.
set +e
xvfb-run pnpm e2e; r1=$?
xvfb-run pnpm exec playwright test --config e2e.mockdapp.config.ts; r2=$?
exit $(( r1 || r2 ))
# 1) Default config: mock-first ui-tests only (see e2e.config.ts testIgnore).
# 2) Self-contained two-tab TON Connect mock-dApp suite (starts mock-dApp :5175 +
# demo-wallet :5173 with broadcast/manifest checks disabled). Aggregate exit codes
# so both runs execute and both report into allure-results.
set +e
xvfb-run pnpm e2e; r1=$?
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 ))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/e2e_web.yml around lines 90 - 97, The CI step is missing
the dedicated TON Connect test suite because it only runs the default e2e config
and e2e.mockdapp.config.ts, while e2e.config.ts now excludes ton-connect specs.
Update this workflow step to also invoke the dedicated TON Connect Playwright
config so apps/demo-wallet/e2e/ton-connect/connect.spec.ts runs in CI, and keep
the existing exit-code aggregation behavior in the same shell block.

env:
WALLET_MNEMONIC: ${{ secrets.WALLET_MNEMONIC }}
# VITE_BRIDGE_URL: 'http://localhost:8081/bridge'
Expand Down
19 changes: 19 additions & 0 deletions apps/demo-wallet/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ const headless =

export default defineConfig({
testDir: './e2e',
// Specs that need their own Playwright config (extra webServer tabs) or an external backend
// must NOT run under this default single-server config — otherwise they hang/fail and, with
// `--retries=3`, blow the 30-min CI budget. After these exclusions the default run is the
// mock-first `e2e/ui-tests/**` suite only.
testIgnore: [
// The mock-first two-tab TON Connect suite runs via its dedicated config, which starts
// the extra dApp tab itself: e2e.mockdapp.config.ts (mock-dApp :5175). See e2e_web.yml
// for the mock-dApp suite's CI step. (`e2e/ton-connect/` holds only the suite's driver
// files — MockDapp.ts / mockDappFixture.ts — which aren't *.spec.ts, so nothing is
// collected from there under this default config.)
'**/mock-dapp-tests/**',
// QUARANTINED (temporary): these drive the external allure-test-runner backend, which is
// currently returning 500 on every case lookup → 3× retries × ~1 min each → CI timeout.
// Re-enable once the runner backend is restored.
'**/e2e/connect.spec.ts',
'**/e2e/signData.spec.ts',
'**/e2e/localSendTransaction.spec.ts',
'**/e2e/sendTransaction/**',
],
timeout: timeout,
expect: {
timeout: timeout,
Expand Down
106 changes: 106 additions & 0 deletions apps/demo-wallet/e2e.mockdapp.config.ts
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/',
Comment thread
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],
});
76 changes: 76 additions & 0 deletions apps/demo-wallet/e2e/README.md
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.
Loading
Loading