@avalix/chroma 0.0.0

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 (2) hide show
  1. package/README.md +135 -0
  2. package/package.json +55 -0
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # @avalix/chroma
2
+
3
+ End-to-end testing library for Polkadot wallet interactions using Playwright.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @avalix/chroma @playwright/test
9
+ ```
10
+
11
+ **Note**: `@playwright/test` is a peer dependency and must be installed separately to avoid conflicts.
12
+
13
+ ## Quick Start
14
+
15
+ ### Using Default Polkadot JS Wallet
16
+
17
+ ```typescript
18
+ import { test, expect } from '@avalix/chroma'
19
+
20
+ test('should connect wallet and sign transaction', async ({ page, importAccount, authorize, approveTx }) => {
21
+ // Import a test account
22
+ await importAccount({
23
+ seed: 'bottom drive obey lake curtain smoke basket hold race lonely fit walk',
24
+ name: 'Test Account'
25
+ })
26
+
27
+ // Navigate to your dApp
28
+ await page.goto('http://localhost:3000')
29
+
30
+ // Connect wallet
31
+ await page.click('button:has-text("Connect Wallet")')
32
+ await authorize()
33
+
34
+ // Perform transaction
35
+ await page.click('button:has-text("Send Transaction")')
36
+ await approveTx()
37
+
38
+ // Verify transaction success
39
+ await expect(page.locator('.transaction-success')).toBeVisible()
40
+ })
41
+ ```
42
+
43
+ ### Using Different Wallets
44
+
45
+ ```typescript
46
+ import { createWalletTest, expect } from '@avalix/chroma'
47
+
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
59
+ const customTest = createWalletTest({
60
+ walletType: 'polkadot-js',
61
+ walletConfig: {
62
+ customPath: './my-custom-extension'
63
+ }
64
+ })
65
+
66
+ polkadotTest('test with Polkadot JS', async ({ page, walletType, walletConfig, importAccount }) => {
67
+ console.log('Using wallet:', walletType) // 'polkadot-js'
68
+ // ... your test code
69
+ })
70
+ ```
71
+
72
+ ## Features
73
+
74
+ - ๐Ÿ” **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
78
+ - ๐Ÿ”— **dApp Authorization**: Connect wallet to decentralized applications
79
+
80
+ ## API Reference
81
+
82
+ ### Test Fixtures
83
+
84
+ #### `importAccount(options: WalletAccount)`
85
+ Import a wallet account using seed phrase.
86
+
87
+ ```typescript
88
+ await importAccount({
89
+ seed: 'your twelve word seed phrase here...',
90
+ name: 'My Test Account',
91
+ password: 'securePassword123'
92
+ })
93
+ ```
94
+
95
+ #### `authorize()`
96
+ Authorize the dApp to connect with the wallet.
97
+
98
+ ```typescript
99
+ await authorize()
100
+ ```
101
+
102
+ #### `approveTx(options?)`
103
+ Approve a transaction with the wallet password.
104
+
105
+ ```typescript
106
+ await approveTx({ password: 'myPassword' })
107
+ ```
108
+
109
+ ### Utility Functions
110
+
111
+ #### `downloadAndExtractPolkadotExtension(targetDir?)`
112
+ Download and extract Polkadot JS extension to specified directory.
113
+
114
+ ```typescript
115
+ import { downloadAndExtractPolkadotExtension } from '@chroma/core'
116
+
117
+ // Download to custom directory
118
+ const extensionPath = await downloadAndExtractPolkadotExtension('./my-extensions')
119
+
120
+ // Download to default directory (./extensions)
121
+ const extensionPath = await downloadAndExtractPolkadotExtension()
122
+ ```
123
+
124
+ ## Configuration
125
+
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.
127
+
128
+ ## Requirements
129
+
130
+ - Node.js 18+
131
+ - Playwright
132
+
133
+ ## License
134
+
135
+ MIT
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@avalix/chroma",
3
+ "version": "0.0.0",
4
+ "description": "End-to-end testing library for Polkadot wallet interactions",
5
+ "type": "module",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "main": "./dist/index.js",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": "./dist/index.js",
14
+ "./package.json": "./package.json"
15
+ },
16
+ "scripts": {
17
+ "build": "tsdown",
18
+ "dev": "tsdown --watch"
19
+ },
20
+ "keywords": [
21
+ "polkadot",
22
+ "wallet",
23
+ "testing",
24
+ "e2e",
25
+ "playwright",
26
+ "automation",
27
+ "blockchain"
28
+ ],
29
+ "author": "Avalix Labs",
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/avalix-labs/chroma.git",
34
+ "directory": "packages/chroma"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/avalix-labs/chroma/issues"
38
+ },
39
+ "homepage": "https://github.com/avalix-labs/chroma#readme",
40
+ "devDependencies": {
41
+ "@types/node": "^24.3.3",
42
+ "@types/unzipper": "^0.10.10",
43
+ "@playwright/test": "^1.55.0",
44
+ "tsdown": "latest"
45
+ },
46
+ "dependencies": {
47
+ "unzipper": "^0.12.3"
48
+ },
49
+ "peerDependencies": {
50
+ "@playwright/test": "^1.55.0"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ }
55
+ }