Skip to content

Commit f1ac068

Browse files
Merge release into main
2 parents 49f0b22 + c835705 commit f1ac068

File tree

1,108 files changed

+20277
-160023
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,108 files changed

+20277
-160023
lines changed

.cursor/skills/e2e/SKILL.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
---
2+
name: e2e
3+
description: Add E2E tests for new coins or update existing Playwright tests for ledger-live-desktop. Use when the user wants to add send/receive e2e tests for a new cryptocurrency, update test configurations, or work with Speculos device simulator.
4+
---
5+
6+
# E2E Desktop Testing Agent
7+
8+
This agent guides you through adding or updating E2E tests for ledger-live-desktop using Playwright and Speculos.
9+
10+
## When to Use
11+
12+
- Adding send/receive e2e tests for a new coin
13+
- Updating existing test configurations
14+
- Working with Speculos device simulator
15+
- Troubleshooting e2e test issues
16+
17+
---
18+
19+
## Project Structure
20+
21+
- `e2e/desktop/tests/specs/` — test scenarios (`.spec.ts`)
22+
- `e2e/desktop/tests/page/` — Page Objects with reusable actions
23+
- `e2e/desktop/tests/utils/` — CLI utilities, Speculos helpers
24+
- `libs/ledger-live-common/src/e2e/` — shared e2e enums and families
25+
26+
---
27+
28+
## Environment Setup
29+
30+
Before running tests, ensure these environment variables are set:
31+
32+
```bash
33+
export COINAPPS=/path/to/coin-apps
34+
export SEED="your 24 words seed phrase here"
35+
export SPECULOS_IMAGE_TAG=ghcr.io/ledgerhq/speculos:master
36+
# SPECULOS_DEVICE valid values: nanoS, nanoSP, nanoX, stax, flex, nanoGen5
37+
export SPECULOS_DEVICE=nanoSP
38+
export MOCK=0
39+
```
40+
41+
---
42+
43+
## Adding New Coin E2E Test
44+
45+
When the user wants to add e2e tests for a new coin, follow these steps and **ask for required information at each step**:
46+
47+
### Step 1: Add Network enum
48+
49+
**File:** `libs/ledger-live-common/src/e2e/enum/Network.ts`
50+
51+
```typescript
52+
NEWCOIN = "NewCoin",
53+
```
54+
55+
### Step 2: Add AppInfos
56+
57+
**File:** `libs/ledger-live-common/src/e2e/enum/AppInfos.ts`
58+
59+
```typescript
60+
static readonly NEWCOIN = new AppInfos("NewCoin");
61+
```
62+
63+
### Step 3: Add Currency
64+
65+
**File:** `libs/ledger-live-common/src/e2e/enum/Currency.ts`
66+
67+
**Ask user for:** name, ticker, currency_id
68+
69+
```typescript
70+
static readonly NEWCOIN = new Currency("NewCoin", "TICKER", "currency_id", AppInfos.NEWCOIN, [Network.NEWCOIN]);
71+
```
72+
73+
### Step 4: Add Accounts
74+
75+
**File:** `libs/ledger-live-common/src/e2e/enum/Account.ts`
76+
77+
**Ask user for:** account derivation path (BIP44)
78+
79+
```typescript
80+
static readonly NEWCOIN_1 = new Account(Currency.NEWCOIN, "NewCoin 1", 0, "44'/xxx'/0'/0/0");
81+
static readonly NEWCOIN_2 = new Account(Currency.NEWCOIN, "NewCoin 2", 1, "44'/xxx'/0'/0/1");
82+
```
83+
84+
### Step 5: Add family file (if new family)
85+
86+
**File:** `libs/ledger-live-common/src/e2e/families/newcoin.ts`
87+
88+
**Ask user:** "Does this coin belong to an existing family (evm, bitcoin, cosmos...)?"
89+
90+
- If YES → reuse existing family file
91+
- If NO → create new file with device button/screen steps for signing
92+
93+
```typescript
94+
import { Transaction } from "../models/Transaction";
95+
import { getSendEvents, containsSubstringInEvent } from "../speculos";
96+
// implement sendNewCoin function
97+
```
98+
99+
### Step 6: Add to speculos.ts
100+
101+
**File:** `libs/ledger-live-common/src/e2e/speculos.ts`
102+
103+
**6a. Add to `specs` object:**
104+
105+
```typescript
106+
Newcoin: {
107+
currency: getCryptoCurrencyById("newcoin"),
108+
appQuery: {
109+
model: getSpeculosModel(),
110+
appName: "Newcoin",
111+
},
112+
dependencies: [],
113+
},
114+
```
115+
116+
**6b. Add to `signSendTransaction` switch:**
117+
118+
```typescript
119+
case Currency.NEWCOIN.id:
120+
await sendNewCoin(tx);
121+
break;
122+
```
123+
124+
### Step 7: Add test case to spec
125+
126+
**File:** `e2e/desktop/tests/specs/send.tx.spec.ts`
127+
128+
**Ask user for:** valid unique xray ticket number
129+
130+
```typescript
131+
{
132+
transaction: new Transaction(Account.NEWCOIN_1, Account.NEWCOIN_2, "0.001"),
133+
xrayTicket: "B2CQA-XXXX",
134+
},
135+
```
136+
137+
### Step 8: Rebuild dependencies
138+
139+
```bash
140+
pnpm build:lld:deps
141+
```
142+
143+
### Step 9: Test on all devices
144+
145+
**REQUIRED:** Run the test on all supported device models before considering it complete:
146+
147+
| Device | Model ID | Description |
148+
| ------ | ---------- | ------------------ |
149+
| LNS | `nanoS` | Ledger Nano S |
150+
| LNSP | `nanoSP` | Ledger Nano S Plus |
151+
| LNX | `nanoX` | Ledger Nano X |
152+
| STAX | `stax` | Ledger Stax |
153+
| FLEX | `flex` | Ledger Flex |
154+
| NG5 | `nanoGen5` | Ledger NG5 |
155+
156+
Run tests for each device using the `SPECULOS_MODEL` environment variable:
157+
158+
```bash
159+
SPECULOS_MODEL=nanoS DISABLE_TRANSACTION_BROADCAST=1 pnpm test:desktop e2e:playwright specs/folder/file.spec.ts
160+
SPECULOS_MODEL=nanoSP DISABLE_TRANSACTION_BROADCAST=1 pnpm test:desktop e2e:playwright specs/folder/file.spec.ts
161+
SPECULOS_MODEL=nanoX DISABLE_TRANSACTION_BROADCAST=1 pnpm test:desktop e2e:playwright specs/folder/file.spec.ts
162+
SPECULOS_MODEL=stax DISABLE_TRANSACTION_BROADCAST=1 pnpm test:desktop e2e:playwright specs/folder/file.spec.ts
163+
SPECULOS_MODEL=flex DISABLE_TRANSACTION_BROADCAST=1 pnpm test:desktop e2e:playwright specs/folder/file.spec.ts
164+
SPECULOS_MODEL=nanoGen5 DISABLE_TRANSACTION_BROADCAST=1 pnpm test:desktop e2e:playwright specs/folder/file.spec.ts
165+
```
166+
167+
**Note:** Each device may have different button layouts and screen flows. Ensure the family file handles device-specific interactions correctly.
168+
169+
---
170+
171+
## Test Configuration Reference
172+
173+
```typescript
174+
test.use({
175+
userdata: "skip-onboarding",
176+
speculosApp: transaction.accountToDebit.currency.speculosApp,
177+
cliCommands: [liveDataWithRecipientAddressCommand(transaction)],
178+
});
179+
```
180+
181+
- **Userdata:** `skip-onboarding`, `1AccountBTC1AccountETH`
182+
- **Speculos:** `Account.currency.speculosApp`
183+
- **CLI commands:** `liveDataCommand`, `liveDataWithAddressCommand`, `liveDataWithRecipientAddressCommand`
184+
185+
---
186+
187+
## Commands
188+
189+
- **Install:** `pnpm i`
190+
- **Build deps:** `pnpm build:lld:deps`
191+
- **Build testing:** `pnpm desktop build:testing`
192+
- **Run test:** `DISABLE_TRANSACTION_BROADCAST=1 pnpm e2e:desktop test:playwright specs/folder/file.spec.ts`
193+
- **Debug:** `PWDEBUG=1 DISABLE_TRANSACTION_BROADCAST=1 pnpm e2e:desktop test:playwright specs/folder/file.spec.ts`
194+
195+
---
196+
197+
## Best Practices
198+
199+
- **Never use hardcoded timeouts** (e.g., `page.waitForTimeout(1000)`)
200+
- Use `@step` decorator in Page Objects
201+
- Access methods via `app` fixture (e.g., `app.layout`, `app.send`, `app.speculos`)
202+
- **MANDATORY:** Test on all 6 device models (LNS, LNSP, LNX, STAX, FLEX, NG5) before marking tests complete

0 commit comments

Comments
 (0)