-
Notifications
You must be signed in to change notification settings - Fork 40
feat: add minimal Playwright smoke test #534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cdd1d1a
feat(e2e): add minimal Playwright smoke test
DSanich 969acaf
refactor: rename test:e2e to test:e2e:browser
DSanich 3c1f386
fix: yarn lock
rolznz 45d8b17
Merge branch 'feat/e2e-minimal' of github.com-rolznz:DSanich/js-sdk i…
rolznz df93cce
fix: CI fix
DSanich d0bbe35
refactor(e2e): move Playwright tests to e2e/browser
DSanich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| dist | ||
| node_modules | ||
| test-results | ||
| playwright-report |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # E2E Tests | ||
|
|
||
| - **`e2e/browser/`** — Playwright tests (run in real browser) | ||
| - **`e2e/`** — Jest integration tests (NWC faucet, etc., see PR #535) | ||
|
|
||
| ## Browser tests (Playwright) | ||
|
|
||
| Minimal smoke test to verify the bundled SDK loads and runs in a browser. | ||
|
|
||
| ### Setup | ||
|
|
||
| ```bash | ||
| yarn install | ||
| yarn test:e2e:browser:install | ||
| ``` | ||
|
|
||
| ### Run | ||
|
|
||
| ```bash | ||
| yarn test:e2e:browser | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <title>SDK Smoke Test</title> | ||
| </head> | ||
| <body> | ||
| <div id="status">loading...</div> | ||
| <script type="module"> | ||
| try { | ||
| const { SATS, resolveAmount } = await import("/dist/esm/lnclient.js"); | ||
| const amount = SATS(10); | ||
| const resolved = await resolveAmount(amount); | ||
| if (resolved.satoshi === 10 && resolved.millisat === 10_000) { | ||
| window.__sdkReady = true; | ||
| document.getElementById("status").textContent = "ok"; | ||
| } else { | ||
| document.getElementById("status").textContent = "fail"; | ||
| } | ||
| } catch (e) { | ||
| console.error(e); | ||
| document.getElementById("status").textContent = "error"; | ||
| } | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { test, expect } from "@playwright/test"; | ||
|
|
||
| /** | ||
| * Minimal smoke test: verifies the bundled SDK loads and runs in a browser. | ||
| * Catches bundle/build issues that Jest (Node) cannot detect. | ||
| */ | ||
| test("bundled SDK loads and runs in browser", async ({ page }) => { | ||
| await page.goto("/e2e/browser/fixtures/smoke.html"); | ||
| await page.waitForSelector("#status:has-text('ok')", { timeout: 10000 }); | ||
|
|
||
| const result = await page.evaluate(() => { | ||
| return (window as { __sdkReady?: boolean }).__sdkReady; | ||
| }); | ||
|
|
||
| expect(result).toBe(true); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { defineConfig, devices } from "@playwright/test"; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: "./e2e/browser", | ||
| fullyParallel: true, | ||
| forbidOnly: !!process.env.CI, | ||
| retries: process.env.CI ? 2 : 0, | ||
| workers: process.env.CI ? 1 : undefined, | ||
| reporter: "html", | ||
| use: { | ||
| baseURL: "http://localhost:3000", | ||
| trace: "on-first-retry", | ||
| }, | ||
| projects: [ | ||
| { name: "chromium", use: { ...devices["Desktop Chrome"] } }, | ||
| { name: "firefox", use: { ...devices["Desktop Firefox"] } }, | ||
| { name: "webkit", use: { ...devices["Desktop Safari"] } }, | ||
| ], | ||
| webServer: { | ||
| command: "yarn build && serve . -p 3000", | ||
| url: "http://localhost:3000", | ||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 180000, | ||
| }, | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.