@broccolo1d/playwright 0.1.1 → 0.1.3

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/LICENSE +21 -0
  2. package/README.md +100 -0
  3. package/package.json +27 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 brocolli-test contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # `@broccolo1d/playwright`
2
+
3
+ Playwright fixtures for wallet-backed dapp QA.
4
+
5
+ This package extends `@playwright/test` with wallet fixtures while keeping dapp-specific selectors, routes, test data, and assertions in the consuming app repository. It depends on `@broccolo1d/wallet-browser` for browser launch, guardrails, network assertions, prompt drivers, and artifact helpers.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add -D @broccolo1d/playwright @playwright/test
11
+ ```
12
+
13
+ The package is ESM-only and requires Node.js `>=22 <23`.
14
+
15
+ ## Configure
16
+
17
+ ```ts
18
+ // playwright.config.ts
19
+ import { defineWalletQaConfig } from '@broccolo1d/playwright';
20
+
21
+ export default defineWalletQaConfig({
22
+ use: {
23
+ walletConfig: {
24
+ useRealWallet: false,
25
+ artifactDir: '.wallet-artifacts/playwright'
26
+ }
27
+ }
28
+ });
29
+ ```
30
+
31
+ `useRealWallet` defaults to `false`. Enable it only in burner/testnet jobs that provide wallet extension/profile configuration through explicit options or ignored environment config.
32
+
33
+ ## Write a dapp-owned test
34
+
35
+ ```ts
36
+ // tests/wallet.spec.ts
37
+ import { expect, test } from '@broccolo1d/playwright';
38
+
39
+ test('connects through wallet policy', async ({ page, wallet, walletArtifacts }) => {
40
+ await page.goto('http://127.0.0.1:5173');
41
+
42
+ await wallet.connect({
43
+ requestConnection: async () => page.getByRole('button', { name: /connect/i }).click(),
44
+ expectedAccount: '0x0000000000000000000000000000000000000000',
45
+ expectedChainId: 11155111,
46
+ origin: 'http://127.0.0.1:5173'
47
+ });
48
+
49
+ await walletArtifacts.screenshot('connected');
50
+ await expect(page.getByText(/connected/i)).toBeVisible();
51
+ });
52
+ ```
53
+
54
+ ```ts
55
+ // playwright.config.ts
56
+ import { defineWalletQaConfig, type MetaMaskNetworkDriver, type WalletPromptDriver } from '@broccolo1d/playwright';
57
+
58
+ const expectedAccount = '0x0000000000000000000000000000000000000000';
59
+
60
+ // Replace these fake drivers with explicit prompt/network automation in real wallet jobs.
61
+ const prompt: WalletPromptDriver = {
62
+ async approveConnection() {}
63
+ };
64
+
65
+ const network: MetaMaskNetworkDriver = {
66
+ async getChainId() { return 11155111; },
67
+ async getAccounts() { return [expectedAccount]; },
68
+ async switchChain() {},
69
+ async addEthereumChain() {}
70
+ };
71
+
72
+ export default defineWalletQaConfig({
73
+ use: {
74
+ walletConfig: {
75
+ useRealWallet: false,
76
+ artifactDir: '.wallet-artifacts/playwright',
77
+ prompt,
78
+ network
79
+ }
80
+ }
81
+ });
82
+ ```
83
+
84
+ ## Fixtures
85
+
86
+ - `walletConfig`: per-test wallet QA configuration.
87
+ - `walletContext`: browser context used by the test.
88
+ - `walletPage`: page used by the test.
89
+ - `wallet`: connect/assert/masking helper.
90
+ - `walletArtifacts`: screenshot and JSON manifest writer under the configured local artifact directory.
91
+
92
+ ## Fail-closed behavior
93
+
94
+ `wallet.connect` requires expected account and chain ID. It also requires one of `requestConnection`, `walletConfig.dapp`, or `walletConfig.dappSelectors` to trigger the dapp connection flow.
95
+
96
+ Real prompt approval is not implicit. A configured prompt driver is required for wallet prompts. A configured network driver is required for chain/account assertions. Without those drivers, the fixtures throw instead of pretending that a wallet action succeeded.
97
+
98
+ ## Artifact handling
99
+
100
+ `walletArtifacts` writes local screenshots and JSON under `.wallet-artifacts/playwright` by default. Treat those files as sensitive until reviewed. Do not commit traces, screenshots, videos, profiles, reports, or manifests generated from burner-wallet runs unless they have been scrubbed and intentionally promoted to public docs.
package/package.json CHANGED
@@ -1,8 +1,31 @@
1
1
  {
2
2
  "name": "@broccolo1d/playwright",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
+ "description": "Playwright fixtures for policy-gated browser-wallet dapp QA.",
4
5
  "private": false,
5
6
  "type": "module",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/BROCCOLO1D/brocolli-test#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/BROCCOLO1D/brocolli-test.git",
12
+ "directory": "packages/playwright"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/BROCCOLO1D/brocolli-test/issues"
16
+ },
17
+ "keywords": [
18
+ "playwright",
19
+ "metamask",
20
+ "wallet",
21
+ "dapp",
22
+ "qa",
23
+ "ethereum",
24
+ "fixtures"
25
+ ],
26
+ "engines": {
27
+ "node": ">=22.0.0 <23.0.0"
28
+ },
6
29
  "main": "./dist/index.js",
7
30
  "types": "./dist/index.d.ts",
8
31
  "exports": {
@@ -14,13 +37,15 @@
14
37
  },
15
38
  "files": [
16
39
  "dist/",
40
+ "README.md",
41
+ "LICENSE",
17
42
  "package.json"
18
43
  ],
19
44
  "peerDependencies": {
20
45
  "@playwright/test": "^1.59.1"
21
46
  },
22
47
  "dependencies": {
23
- "@broccolo1d/wallet-browser": "^0.1.1"
48
+ "@broccolo1d/wallet-browser": "^0.1.3"
24
49
  },
25
50
  "devDependencies": {
26
51
  "@playwright/test": "1.59.1",