-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contact search and new amount editor
- Loading branch information
1 parent
077ccb2
commit bc2fbf9
Showing
65 changed files
with
2,027 additions
and
2,465 deletions.
There are no files selected for viewing
This file contains 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,67 +1,69 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.goto("http://localhost:3420/"); | ||
await page.goto("http://localhost:3420/"); | ||
}); | ||
|
||
test("rountrip receive and send", async ({ page }) => { | ||
// Click the receive button | ||
await page.click("text=Receive"); | ||
|
||
// Expect the url to conain receive | ||
await expect(page).toHaveURL(/.*receive/); | ||
|
||
// At least one h1 should show "0 sats" | ||
await expect(page.locator("h1")).toContainText(["0 SATS"]); | ||
|
||
// At least one h2 should show "0 USD" | ||
await expect(page.locator("h2")).toContainText(["$0 USD"]); | ||
// Click the 100k button | ||
await page.click("text=100k"); | ||
// Now the h1 should show "10,000 sats" | ||
|
||
// Type 100000 into the input | ||
await page.locator("#sats-input").pressSequentially("100000"); | ||
|
||
// Now the h1 should show "100,000 sats" | ||
await expect(page.locator("h1")).toContainText(["100,000 SATS"]); | ||
|
||
// Click the "Set Amount" button | ||
await page.click("text=Set Amount"); | ||
|
||
|
||
// There should be a button with the text "Continue" and it should not be disabled | ||
const continueButton = await page.locator("button", { hasText: "Continue" }); | ||
const continueButton = await page.locator("button", { | ||
hasText: "Continue" | ||
}); | ||
await expect(continueButton).not.toBeDisabled(); | ||
|
||
// Wait one second | ||
// TODO: figure out how to not get an error without waiting | ||
await page.waitForTimeout(1000); | ||
|
||
continueButton.click(); | ||
|
||
await expect( | ||
page.getByText("Keep Mutiny open to complete the payment.") | ||
).toBeVisible(); | ||
|
||
// Locate an SVG inside a div with id "qr" | ||
const qrCode = await page.locator("#qr > svg"); | ||
|
||
await expect(qrCode).toBeVisible(); | ||
|
||
const value = await qrCode.getAttribute("value"); | ||
|
||
// The SVG's value property includes "bitcoin:t" | ||
expect(value).toContain("bitcoin:t"); | ||
|
||
const lightningInvoice = value?.split("lightning=")[1]; | ||
|
||
// Post the lightning invoice to the server | ||
const _response = await fetch("https://faucet.mutinynet.com/api/lightning", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
body: JSON.stringify({ | ||
bolt11: lightningInvoice | ||
}) | ||
}); | ||
const _response = await fetch( | ||
"https://faucet.mutinynet.com/api/lightning", | ||
{ | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json" | ||
}, | ||
body: JSON.stringify({ | ||
bolt11: lightningInvoice | ||
}) | ||
} | ||
); | ||
|
||
// Wait for an h1 to appear in the dom that says "Payment Received" | ||
await page.waitForSelector("text=Payment Received", { timeout: 30000 }); | ||
|
@@ -73,20 +75,29 @@ test("rountrip receive and send", async ({ page }) => { | |
await page.click("text=Send"); | ||
|
||
// In the textarea with the placeholder "bitcoin:..." type [email protected] | ||
const sendInput = await page.locator("textarea"); | ||
const sendInput = await page.locator("input"); | ||
await sendInput.fill("[email protected]"); | ||
|
||
await page.click("text=Continue"); | ||
|
||
await page.click("text=Set Amount"); | ||
// Wait two seconds (the destination doesn't show up immediately) | ||
// TODO: figure out how to not get an error without waiting | ||
await page.waitForTimeout(2000); | ||
|
||
await page.click("text=10k"); | ||
// Type 10000 into the input | ||
await page.locator("#sats-input").fill("10000"); | ||
|
||
await page.click("text=Set Amount"); | ||
// Now the h1 should show "100,000 sats" | ||
await expect(page.locator("h1")).toContainText(["10,000 SATS"]); | ||
|
||
await page.click("text=Confirm Send"); | ||
// There should be a button with the text "Confirm Send" and it should not be disabled | ||
const confirmButton = await page.locator("button", { | ||
hasText: "Confirm Send" | ||
}); | ||
await expect(confirmButton).not.toBeDisabled(); | ||
|
||
// Wait for an h1 to appear in the dom that says "Payment Received" | ||
confirmButton.click(); | ||
|
||
// Wait for an h1 to appear in the dom that says "Payment Sent" | ||
await page.waitForSelector("text=Payment Sent", { timeout: 30000 }); | ||
}); | ||
|
||
}); |
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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
Oops, something went wrong.