Skip to content

Commit 4e65a9b

Browse files
kdaviduikclaudepi-mono
committed
feat: add manual browser testing for the built bundle
Adds test-manual/index.html that loads the locally built bundle (lib/buybutton.umd.js) and renders real buy buttons from live stores. This enables reviewers to verify changes don't break real-world rendering before merging. Key details: - Uses ShopifyBuy.UI.init() API (not onReady - that's buy-button-storefront wrapper) - Tests 3 components: product, collection, product from different store - Includes .catch() error handlers for visible failure feedback - Excluded from npm publish via .npmignore - Documents the difference between buy-button-js and buy-button-storefront APIs This is an interim solution until automated browser testing (Playwright/Vitest) is added. Co-Authored-By: Claude <noreply@anthropic.com> Co-authored-by: AI (Pi/GLM 5.2 Fast (Fireworks) [1m]) <noreply@pi.dev>
1 parent 1c79bb9 commit 4e65a9b

4 files changed

Lines changed: 388 additions & 0 deletions

File tree

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ test-output.xml
1010
lint-output.xml
1111
/errorShots
1212
/test/build
13+
/test-manual
1314
config.json

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ pnpm run test-dev
4545

4646
Will watch for changes and run test suite.
4747

48+
### Manual Browser Testing
49+
50+
To verify buy buttons render correctly in a real browser:
51+
52+
```bash
53+
pnpm build
54+
pnpm serve
55+
# Open the URL the terminal prints on startup, e.g.:
56+
open http://localhost:8080/test-manual/
57+
```
58+
59+
See [`test-manual/README.md`](./test-manual/README.md) for details.
60+
4861
## Documentation
4962

5063
To run docs locally, install jekyll:

test-manual/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Manual Browser Testing
2+
3+
This directory contains a test page for manually verifying buy-button-js works correctly in a real browser environment.
4+
5+
## Important: buy-button-js vs buy-button-storefront
6+
7+
**This test page tests `buy-button-js` directly** — the core UI rendering library.
8+
9+
The embed code merchants get from the Shopify admin loads `buy-button-storefront.min.js` (from CDN), which is a **different package** that wraps buy-button-js with tracking/analytics and provides a convenience API.
10+
11+
| Package | API | Source |
12+
|---------|-----|--------|
13+
| `buy-button-js` (this repo) | `ShopifyBuy.UI.init(client)` | Local build (`lib/buybutton.umd.js`) |
14+
| `buy-button-storefront` (wrapper) | `ShopifyBuy.UI.onReady(client).then(...)` | CDN (`buy-button-storefront.min.js`) |
15+
16+
If you're testing changes to buy-button-js, use this test page. The `onReady` API from merchant embed codes won't work here because that's added by the storefront wrapper.
17+
18+
## Why Manual Testing?
19+
20+
The unit test suite (794 tests) verifies component logic, but doesn't render actual buy buttons in a browser. This test page lets you:
21+
22+
- Verify the built bundle loads correctly
23+
- See real buy buttons render with products from live stores
24+
- Test cart interactions, modals, and checkout flows
25+
- Confirm changes don't break visual rendering or API communication
26+
27+
## Quick Start
28+
29+
```bash
30+
# 1. Install dependencies (if not already done)
31+
pnpm install
32+
33+
# 2. Build the package
34+
pnpm build
35+
36+
# 3. Start the local server
37+
pnpm serve
38+
39+
# 4. Open the URL the terminal prints on startup (e.g. localhost:8080/test-manual/)
40+
open http://localhost:8080/test-manual/
41+
```
42+
43+
> **Note:** `localhost:8080` above is just an example. `http-server` picks the first available port (and moves to 8081, 8082, etc. if 8080 is taken), so use the URL printed in the terminal when you run `pnpm serve`.
44+
45+
## What's Tested
46+
47+
The test page includes several buy button configurations:
48+
49+
| Test | Type | Store | Purpose |
50+
|------|------|-------|---------|
51+
| 1 | Product | kara-daviduik | Basic product with default styling |
52+
| 2 | Collection | kara-daviduik | Collection grid rendering |
53+
| 3 | Product | hydrogen-migration | Cross-store verification |
54+
55+
## Expected Behavior
56+
57+
When working correctly, you should see:
58+
59+
1. ✅ Green "ShopifyBuy loaded successfully" status at the top
60+
2. Product images, titles, and prices rendered
61+
3. "Add to cart" buttons that open a cart drawer when clicked
62+
4. Cart drawer with working quantity controls and checkout button
63+
64+
## Troubleshooting
65+
66+
**"ShopifyBuy not loaded" error:**
67+
- Run `pnpm build` first
68+
- Check that `lib/buybutton.umd.js` exists
69+
70+
**Products not rendering:**
71+
- Check browser console for API errors
72+
- Verify network requests to `*.myshopify.com` succeed
73+
- Some stores may have access restrictions
74+
75+
**CORS errors:**
76+
- Use `pnpm serve` instead of opening the file directly
77+
- Or use a browser with relaxed local file security
78+
79+
## Adding More Tests
80+
81+
To test additional scenarios, add new `<div id="test-X">` elements and corresponding `ui.createComponent()` calls in the script section. Use your own store's domain and storefront access token.

0 commit comments

Comments
 (0)