@avalix/chroma 0.0.4 โ†’ 0.0.6

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.
Files changed (3) hide show
  1. package/README.md +102 -27
  2. package/dist/index.js +1 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  End-to-end testing library for Polkadot wallet interactions using Playwright.
4
4
 
5
+ > **Current Status**: This library currently supports **Polkadot JS Extension** only. Support for other wallets like Talisman is planned for future releases.
6
+
5
7
  ## Installation
6
8
 
7
9
  ```bash
@@ -12,7 +14,7 @@ npm install @avalix/chroma @playwright/test
12
14
 
13
15
  ## Quick Start
14
16
 
15
- ### Using Default Polkadot JS Wallet
17
+ ### Basic Usage
16
18
 
17
19
  ```typescript
18
20
  import { expect, test } from '@avalix/chroma'
@@ -21,7 +23,8 @@ test('should connect wallet and sign transaction', async ({ page, importAccount,
21
23
  // Import a test account
22
24
  await importAccount({
23
25
  seed: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk',
24
- name: 'Test Account'
26
+ name: 'Test Account',
27
+ password: 'securePassword123'
25
28
  })
26
29
 
27
30
  // Navigate to your dApp
@@ -33,58 +36,91 @@ test('should connect wallet and sign transaction', async ({ page, importAccount,
33
36
 
34
37
  // Perform transaction
35
38
  await page.click('button:has-text("Send Transaction")')
36
- await approveTx()
39
+ await approveTx({ password: 'securePassword123' })
37
40
 
38
41
  // Verify transaction success
39
42
  await expect(page.locator('.transaction-success')).toBeVisible()
40
43
  })
41
44
  ```
42
45
 
43
- ### Using Different Wallets
46
+ ### Custom Configuration
44
47
 
45
48
  ```typescript
46
49
  import { createWalletTest, expect } from '@avalix/chroma'
47
50
 
48
- // Create test with Polkadot JS wallet (default)
49
- const polkadotTest = createWalletTest({
50
- walletType: 'polkadot-js'
51
- })
52
-
53
- // Create test with Talisman wallet (coming soon)
54
- const talismanTest = createWalletTest({
55
- walletType: 'talisman'
56
- })
57
-
58
- // Create test with custom extension path
51
+ // Create test with custom configuration
59
52
  const customTest = createWalletTest({
60
53
  walletType: 'polkadot-js',
61
54
  walletConfig: {
62
55
  customPath: './my-custom-extension'
63
- }
56
+ },
57
+ headless: false,
58
+ slowMo: 100
64
59
  })
65
60
 
66
- polkadotTest('test with Polkadot JS', async ({ page, walletType, walletConfig, importAccount }) => {
67
- console.log('Using wallet:', walletType) // 'polkadot-js'
68
- // ... your test code
61
+ customTest('test with custom config', async ({ page, importAccount, authorize }) => {
62
+ // Your test code here
63
+ await importAccount({
64
+ seed: 'your seed phrase here...',
65
+ name: 'My Test Account'
66
+ })
67
+ // ... rest of your test
69
68
  })
70
69
  ```
71
70
 
72
71
  ## Features
73
72
 
74
73
  - ๐Ÿ” **Automatic Extension Setup**: Downloads and configures Polkadot JS extension automatically
75
- - ๐Ÿงช **Wallet Fixtures**: Ready-to-use fixtures for wallet operations
76
- - ๐Ÿ“ **Account Management**: Import accounts with seed phrases
77
- - โœ… **Transaction Approval**: Approve transactions with password
74
+ - ๐Ÿงช **Test Fixtures**: Ready-to-use Playwright fixtures for wallet operations
75
+ - ๐Ÿ“ **Account Management**: Import accounts with seed phrases and custom names
76
+ - โœ… **Transaction Approval**: Approve transactions with password authentication
78
77
  - ๐Ÿ”— **dApp Authorization**: Connect wallet to decentralized applications
78
+ - โš™๏ธ **Configurable**: Custom extension paths, headless mode, and slow motion settings
79
79
 
80
80
  ## API Reference
81
81
 
82
+ ### Core Functions
83
+
84
+ #### `test` (Default Test Function)
85
+ Pre-configured test function with Polkadot JS extension.
86
+
87
+ ```typescript
88
+ import { test } from '@avalix/chroma'
89
+
90
+ test('my wallet test', async ({ page, importAccount, authorize, approveTx }) => {
91
+ // Test implementation
92
+ })
93
+ ```
94
+
95
+ #### `createWalletTest(options?: ChromaTestOptions)`
96
+ Create a custom test function with specific configuration.
97
+
98
+ ```typescript
99
+ import { createWalletTest } from '@avalix/chroma'
100
+
101
+ const customTest = createWalletTest({
102
+ walletType: 'polkadot-js', // Currently only 'polkadot-js' is supported
103
+ walletConfig: {
104
+ customPath: './custom-extension', // Optional: path to custom extension
105
+ downloadUrl: 'https://...' // Optional: custom download URL
106
+ },
107
+ headless: true, // Optional: run in headless mode
108
+ slowMo: 150 // Optional: slow motion delay in ms (default: 150)
109
+ })
110
+ ```
111
+
82
112
  ### Test Fixtures
83
113
 
84
114
  #### `importAccount(options: WalletAccount)`
85
115
  Import a wallet account using seed phrase.
86
116
 
87
117
  ```typescript
118
+ interface WalletAccount {
119
+ seed: string
120
+ name?: string // Default: 'Test Account'
121
+ password?: string // Default: 'h3llop0lkadot!'
122
+ }
123
+
88
124
  await importAccount({
89
125
  seed: 'your twelve word seed phrase here...',
90
126
  name: 'My Test Account',
@@ -93,7 +129,7 @@ await importAccount({
93
129
  ```
94
130
 
95
131
  #### `authorize()`
96
- Authorize the dApp to connect with the wallet.
132
+ Authorize the dApp to connect with the wallet. Call this after triggering wallet connection from your dApp.
97
133
 
98
134
  ```typescript
99
135
  await authorize()
@@ -104,6 +140,9 @@ Approve a transaction with the wallet password.
104
140
 
105
141
  ```typescript
106
142
  await approveTx({ password: 'myPassword' })
143
+
144
+ // Or use default password
145
+ await approveTx()
107
146
  ```
108
147
 
109
148
  ### Utility Functions
@@ -112,23 +151,59 @@ await approveTx({ password: 'myPassword' })
112
151
  Download and extract Polkadot JS extension to specified directory.
113
152
 
114
153
  ```typescript
115
- import { downloadAndExtractPolkadotExtension } from '@chroma/core'
154
+ import { downloadAndExtractPolkadotExtension } from '@avalix/chroma'
116
155
 
117
156
  // Download to custom directory
118
157
  const extensionPath = await downloadAndExtractPolkadotExtension('./my-extensions')
119
158
 
120
- // Download to default directory (./extensions)
159
+ // Download to default directory (./.chroma)
121
160
  const extensionPath = await downloadAndExtractPolkadotExtension()
122
161
  ```
123
162
 
163
+ ### TypeScript Types
164
+
165
+ ```typescript
166
+ import type {
167
+ ChromaTestOptions,
168
+ WalletAccount,
169
+ WalletConfig,
170
+ WalletFixtures,
171
+ WalletType
172
+ } from '@avalix/chroma'
173
+ ```
174
+
124
175
  ## Configuration
125
176
 
126
- The extension will be automatically downloaded to `./extensions` directory in your project root. You can customize this by passing a different path to the download function.
177
+ ### Default Directory
178
+ The Polkadot JS extension will be automatically downloaded to `./.chroma` directory in your project root. You can customize this by:
179
+
180
+ 1. Using `downloadAndExtractPolkadotExtension('./custom-path')`
181
+ 2. Using `createWalletTest()` with `walletConfig.customPath`
182
+
183
+ ### Browser Settings
184
+ - **Headless Mode**: Disabled by default for better debugging
185
+ - **Slow Motion**: 150ms delay between actions (configurable)
186
+ - **Extension Loading**: Automatically loads only the Polkadot JS extension
187
+
188
+ ## Supported Wallets
189
+
190
+ | Wallet | Status | Version |
191
+ |--------|--------|---------|
192
+ | Polkadot JS Extension | โœ… Supported | v0.61.7 |
193
+ | Talisman | โณ Planned | - |
194
+ | SubWallet | โณ Planned | - |
127
195
 
128
196
  ## Requirements
129
197
 
130
198
  - Node.js 18+
131
- - Playwright
199
+ - @playwright/test ^1.55.0
200
+
201
+ ## Contributing
202
+
203
+ This project is in active development. Currently focusing on:
204
+ - Polkadot JS Extension support
205
+ - Core testing fixtures
206
+ - Documentation improvements
132
207
 
133
208
  ## License
134
209
 
package/dist/index.js CHANGED
@@ -68,6 +68,7 @@ function createWalletTest(options = {}) {
68
68
  const extensionPath = await getExtensionPath(walletType, finalWalletConfig);
69
69
  const context = await chromium.launchPersistentContext("", {
70
70
  headless,
71
+ channel: "chromium",
71
72
  args: [`--load-extension=${extensionPath}`, `--disable-extensions-except=${extensionPath}`],
72
73
  slowMo
73
74
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@avalix/chroma",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "description": "End-to-end testing library for Polkadot wallet interactions",
6
6
  "author": "Avalix Labs",
7
7
  "license": "MIT",