@avalix/chroma 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  End-to-end testing library for Polkadot wallet interactions using Playwright.
4
4
 
5
- > **⚠️ Active Development**: This library is currently under active development. The API may change and breaking changes can occur between versions. Please pin your version and review changelogs carefully when updating.
6
-
7
5
  ## Installation
8
6
 
9
7
  ```bash
@@ -27,7 +25,7 @@ This will download the wallet extensions (Polkadot JS and Talisman) to `./.chrom
27
25
  ```json
28
26
  {
29
27
  "scripts": {
30
- "prepare": "chroma download-extensions"
28
+ "test:prepare": "chroma download-extensions"
31
29
  }
32
30
  }
33
31
  ```
@@ -36,258 +34,60 @@ This will download the wallet extensions (Polkadot JS and Talisman) to `./.chrom
36
34
 
37
35
  ## Quick Start
38
36
 
39
- ### Basic Usage
40
-
41
37
  ```typescript
42
- import { expect, test } from '@avalix/chroma'
38
+ import { createWalletTest, expect } from '@avalix/chroma'
43
39
 
44
- test('should connect wallet and sign transaction', async ({ page, wallets }) => {
40
+ const test = createWalletTest({
41
+ wallets: [{ type: 'polkadot-js' }]
42
+ })
43
+
44
+ test('connect wallet and sign transaction', async ({ page, wallets }) => {
45
45
  const polkadotJs = wallets['polkadot-js']
46
46
 
47
- // Import a test account
48
47
  await polkadotJs.importMnemonic({
49
48
  seed: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk',
50
49
  name: 'Test Account',
51
50
  password: 'securePassword123'
52
51
  })
53
52
 
54
- // Navigate to your dApp
55
53
  await page.goto('http://localhost:3000')
56
-
57
- // Connect wallet
58
54
  await page.click('button:has-text("Connect Wallet")')
59
55
  await polkadotJs.authorize()
60
56
 
61
- // Perform transaction
62
57
  await page.click('button:has-text("Send Transaction")')
63
58
  await polkadotJs.approveTx({ password: 'securePassword123' })
64
59
 
65
- // Verify transaction success
66
60
  await expect(page.locator('.transaction-success')).toBeVisible()
67
61
  })
68
62
  ```
69
63
 
70
- ### Custom Configuration
71
-
72
- ```typescript
73
- import { createWalletTest, expect } from '@avalix/chroma'
74
-
75
- const customTest = createWalletTest({
76
- wallets: [{ type: 'polkadot-js' }],
77
- headless: false,
78
- slowMo: 100
79
- })
80
-
81
- customTest('test with custom config', async ({ page, wallets }) => {
82
- const polkadotJs = wallets['polkadot-js']
83
-
84
- await polkadotJs.importMnemonic({
85
- seed: 'your seed phrase here...',
86
- name: 'My Test Account'
87
- })
88
- await page.goto('http://localhost:3000')
89
- await polkadotJs.authorize()
90
- })
91
- ```
92
-
93
64
  ### Multiple Wallets
94
65
 
95
66
  ```typescript
96
- import { createWalletTest, expect } from '@avalix/chroma'
67
+ import { createWalletTest } from '@avalix/chroma'
97
68
 
98
- // Test with multiple wallet extensions
99
- const multiWalletTest = createWalletTest({
100
- wallets: [
101
- { type: 'polkadot-js' },
102
- { type: 'talisman' }
103
- ],
104
- headless: false,
105
- slowMo: 150
69
+ const test = createWalletTest({
70
+ wallets: [{ type: 'polkadot-js' }, { type: 'talisman' }]
106
71
  })
107
72
 
108
- multiWalletTest('test with multiple wallets', async ({ page, wallets }) => {
73
+ test('multi-wallet test', async ({ page, wallets }) => {
109
74
  const polkadotJs = wallets['polkadot-js']
110
75
  const talisman = wallets.talisman
111
76
 
112
- // Import to Polkadot JS
113
- await polkadotJs.importMnemonic({
114
- seed: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk',
115
- name: 'Alice'
116
- })
117
-
118
- // Import to Talisman using Ethereum private key
119
- await talisman.importEthPrivateKey({
120
- privateKey: '0x...',
121
- name: 'Bob'
122
- })
77
+ await polkadotJs.importMnemonic({ seed: '...', name: 'Alice' })
78
+ await talisman.importEthPrivateKey({ privateKey: '0x...', name: 'Bob' })
123
79
 
124
80
  await page.goto('http://localhost:3000')
125
-
126
- // Use specific wallet
127
81
  await polkadotJs.authorize()
128
- await polkadotJs.approveTx()
129
82
  })
130
83
  ```
131
84
 
132
85
  ## Features
133
86
 
134
- - 🔐 **Easy Extension Setup**: Simple command to download wallet extensions
135
- - 🧪 **Test Fixtures**: Ready-to-use Playwright fixtures for wallet operations
136
- - 📝 **Account Management**: Import accounts with seed phrases and custom names
137
- - **Transaction Approval**: Approve transactions with password authentication
138
- - 🔗 **dApp Authorization**: Connect wallet to decentralized applications
139
- - 🔀 **Multi-Wallet Support**: Test with multiple wallet extensions simultaneously
140
- - ⚙️ **Configurable**: Custom extension paths, headless mode, and slow motion settings
141
-
142
- ## API Reference
143
-
144
- ### Core Functions
145
-
146
- #### `test` (Default Test Function)
147
- Pre-configured test function with Polkadot JS extension.
148
-
149
- ```typescript
150
- import { test } from '@avalix/chroma'
151
-
152
- test('my wallet test', async ({ page, wallets }) => {
153
- const polkadotJs = wallets['polkadot-js']
154
-
155
- await polkadotJs.importMnemonic({ seed: '...' })
156
- await polkadotJs.authorize()
157
- })
158
- ```
159
-
160
- #### `createWalletTest(options?: ChromaTestOptions)`
161
- Create a custom test function with specific configuration. Supports single and multi-wallet modes.
162
-
163
- ```typescript
164
- import { createWalletTest } from '@avalix/chroma'
165
-
166
- // Single wallet (default)
167
- const test = createWalletTest()
168
-
169
- // Single wallet with custom config
170
- const customTest = createWalletTest({
171
- wallets: [{ type: 'polkadot-js' }],
172
- headless: false,
173
- slowMo: 150
174
- })
175
-
176
- // Multiple wallets
177
- const multiTest = createWalletTest({
178
- wallets: [
179
- { type: 'polkadot-js' },
180
- { type: 'talisman' }
181
- ]
182
- })
183
-
184
- // Usage
185
- test('example', async ({ page, wallets }) => {
186
- const polkadotJs = wallets['polkadot-js']
187
-
188
- await polkadotJs.importMnemonic({ seed: '...' })
189
- await polkadotJs.authorize()
190
- await polkadotJs.approveTx()
191
- })
192
- ```
193
-
194
- ### Test Fixtures
195
-
196
- #### `page`
197
- Playwright page instance with wallet extension(s) loaded.
198
-
199
- #### `wallets`
200
- Typed object containing wallet instances for each configured wallet. Provides full TypeScript autocomplete.
201
-
202
- ```typescript
203
- // Base wallet instance (common methods)
204
- interface BaseWalletInstance {
205
- extensionId: string
206
- importMnemonic: (options: WalletAccount) => Promise<void>
207
- authorize: (options?: { accountName?: string }) => Promise<void>
208
- approveTx: (options?: { password?: string }) => Promise<void>
209
- }
210
-
211
- // Polkadot-JS wallet instance
212
- interface PolkadotJsWalletInstance extends BaseWalletInstance {
213
- type: 'polkadot-js'
214
- }
215
-
216
- // Talisman wallet instance (with additional methods)
217
- interface TalismanWalletInstance extends BaseWalletInstance {
218
- type: 'talisman'
219
- importEthPrivateKey: (options: { privateKey: string, name?: string, password?: string }) => Promise<void>
220
- }
221
-
222
- // Note: Talisman currently does not support importMnemonic - use importEthPrivateKey instead
223
-
224
- // Wallets collection - each wallet has its specific type
225
- interface Wallets {
226
- 'polkadot-js': PolkadotJsWalletInstance
227
- 'talisman': TalismanWalletInstance
228
- }
229
-
230
- interface WalletAccount {
231
- seed: string
232
- name?: string // Default: 'Test Account'
233
- password?: string // Default: 'h3llop0lkadot!'
234
- }
235
- ```
236
-
237
- **Usage:**
238
-
239
- ```typescript
240
- test('example', async ({ page, wallets }) => {
241
- const polkadotJs = wallets['polkadot-js'] // Type: PolkadotJsWalletInstance
242
-
243
- // Import mnemonic (available on all wallets)
244
- await polkadotJs.importMnemonic({
245
- seed: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk',
246
- name: 'Test Account',
247
- password: 'securePassword123'
248
- })
249
-
250
- await page.goto('http://localhost:3000')
251
- await polkadotJs.authorize()
252
- await polkadotJs.approveTx({ password: 'securePassword123' })
253
- })
254
-
255
- // Talisman-specific features
256
- test('talisman example', async ({ page, wallets }) => {
257
- const talisman = wallets.talisman // Type: TalismanWalletInstance
258
-
259
- // Talisman-specific method: import Ethereum private key
260
- await talisman.importEthPrivateKey({
261
- privateKey: '0x...',
262
- name: 'My Account',
263
- password: 'mypassword'
264
- })
265
-
266
- // Common methods also available
267
- await talisman.authorize({ accountName: 'My Account' })
268
- await talisman.approveTx()
269
- })
270
- ```
271
-
272
- ## Configuration
273
-
274
- ### Extension Download
275
- Run the download command to get the required wallet extensions:
276
-
277
- ```bash
278
- npx chroma download-extensions
279
- ```
280
-
281
- Extensions will be downloaded to `./.chroma` directory in your project root. Add this directory to your `.gitignore`:
282
-
283
- ```gitignore
284
- .chroma/
285
- ```
286
-
287
- ### Browser Settings
288
- - **Headless Mode**: Disabled by default for better debugging
289
- - **Slow Motion**: 150ms delay between actions (configurable)
290
- - **Extension Loading**: Automatically loads configured wallet extensions
87
+ - **Easy Extension Setup** - Download wallet extensions with a single command
88
+ - **Multi-Wallet Support** - Test with multiple wallet extensions simultaneously
89
+ - **TypeScript Support** - Full type safety and autocomplete
90
+ - **VS Code Integration** - Works with [Playwright Test for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright)
291
91
 
292
92
  ## Supported Chains
293
93
 
@@ -301,23 +101,16 @@ Extensions will be downloaded to `./.chroma` directory in your project root. Add
301
101
 
302
102
  | Wallet | Status | Version |
303
103
  |--------|--------|---------|
304
- | Polkadot JS Extension | ✅ Supported | v0.61.7 |
305
- | Talisman | ✅ Supported | v3.0.5 |
104
+ | Polkadot JS Extension | ✅ Supported | v0.62.6 |
105
+ | Talisman | ✅ Supported | v3.1.13 |
306
106
  | SubWallet | ⏳ Planned | - |
107
+ | MetaMask | ⏳ Planned | - |
307
108
 
308
109
  ## Requirements
309
110
 
310
- - Node.js 18+
111
+ - Node.js 24+
311
112
  - @playwright/test ^1.55.0
312
113
 
313
- ## Contributing
314
-
315
- This project is in active development. Currently focusing on:
316
- - Polkadot JS Extension and Talisman support
317
- - Core testing fixtures
318
- - Additional wallet integrations
319
- - Documentation improvements
320
-
321
114
  ## License
322
115
 
323
116
  MIT