Skip to content

Commit

Permalink
fix the tests and don't redirect to setup
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul committed Feb 22, 2024
1 parent 0cb3551 commit aa7da17
Show file tree
Hide file tree
Showing 20 changed files with 211 additions and 217 deletions.
15 changes: 12 additions & 3 deletions e2e/encrypt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ test("test local encrypt", async ({ page }) => {
// Click the "I wrote down the words" button
await wroteDownButton.click();

// Make sure the balance box ready light is on
await page.locator("title=READY");

// Go back to settings / change password
await visitSettings(page);
await page.click("text=Change Password");
Expand All @@ -46,31 +49,37 @@ test("test local encrypt", async ({ page }) => {
const passwordInput = await page.locator(`input[name='password']`);

// 2. Type the password into the input field
await passwordInput.type("test");
await passwordInput.fill("test");

// 3. Find the input field with the name "confirmPassword"
const confirmPasswordInput = await page.locator(
`input[name='confirmPassword']`
);

// 4. Type the password into the input field
await confirmPasswordInput.type("test");
await confirmPasswordInput.fill("test");

// The "Encrypt" button should not be disabled
const encryptButton = await page.locator("button", { hasText: "Encrypt" });
await expect(encryptButton).not.toBeDisabled();

// wait 5 seconds for no reason (SADLY THIS IS IMPORTANT FOR THE TEST TO PASS)
await page.waitForTimeout(5000);

// Click the "Encrypt" button
await encryptButton.click();

// wait for a while just to see what happens
// await page.waitForTimeout(10000);

// Wait for a modal with the text "Enter your password"
await page.waitForSelector("text=Enter your password");

// Find the input field with the name "password"
const passwordInput2 = await page.locator(`input[name='password']`);

// Type the password into the input field
await passwordInput2.type("test");
await passwordInput2.fill("test");

// Click the "Decrypt Wallet" button
await page.click("text=Decrypt Wallet");
Expand Down
7 changes: 5 additions & 2 deletions e2e/fedimint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ test("fedmint join, receive, send", async ({ page }) => {

const addButton = await page.getByRole("button", { name: "Add" });

// Wait 5 seconds for no good reason
await page.waitForTimeout(5000);

// Click the "Add" button
await addButton.click();

Expand Down Expand Up @@ -68,7 +71,7 @@ test("fedmint join, receive, send", async ({ page }) => {
// TODO: figure out how to not get an error without waiting
await page.waitForTimeout(1000);

continueButton.click();
await continueButton.click();

await expect(
page.getByText("Keep Mutiny open to complete the payment.")
Expand Down Expand Up @@ -135,7 +138,7 @@ test("fedmint join, receive, send", async ({ page }) => {
});
await expect(confirmButton).not.toBeDisabled();

confirmButton.click();
await confirmButton.click();

// Wait for an h1 to appear in the dom that says "Payment Sent"
await page.waitForSelector("text=Payment Sent", { timeout: 30000 });
Expand Down
7 changes: 3 additions & 4 deletions e2e/restore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test("restore from seed @slow", async ({ page }) => {
const wordInput = await page.locator(`input[name='words.${i}']`);

// Type the seed words into the input field
await wordInput.type(seedWords[i]);
await wordInput.fill(seedWords[i]);
}

// There should be a button with the text "Restore" and it should not be disabled
Expand All @@ -40,7 +40,7 @@ test("restore from seed @slow", async ({ page }) => {

// A modal should pop up, click the "Confirm" button
const confirmButton = await page.locator("button", { hasText: "Confirm" });
confirmButton.click();
await confirmButton.click();

// Eventually we should have a balance of 100k sats
await page.locator("text=100,000 SATS");
Expand All @@ -64,6 +64,5 @@ test("restore from seed @slow", async ({ page }) => {

await confirmDeleteButton.click();

// Wait for the wallet to load
await page.waitForSelector("text=Welcome to the Mutiny!");
await page.locator("text=Welcome to the Mutiny!");
});
16 changes: 11 additions & 5 deletions e2e/roundtrip.spec.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { expect, test } from "@playwright/test";

import { loadHome } from "./utils";

test.beforeEach(async ({ page }) => {
await page.goto("http://localhost:3420/");
});

test("rountrip receive and send", async ({ page }) => {
// Click the receive button
await page.click("text=Receive");
await loadHome(page);

await page.locator("#fab").click();
await page.locator("text=Receive").last().click();

// Expect the url to conain receive
// Expect the url to contain 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"]);
// await expect(page.locator("h2")).toContainText(["$0 USD"]);
await page.waitForSelector("text=$0 USD");

// Type 100000 into the input
await page.locator("#sats-input").pressSequentially("100000");
Expand Down Expand Up @@ -72,7 +77,8 @@ test("rountrip receive and send", async ({ page }) => {
await page.click("text=Nice");

// Now we send
await page.click("text=Send");
await page.locator("#fab").click();
await page.locator("text=Send").click();

// In the textarea with the placeholder "bitcoin:..." type refund@lnurl-staging.mutinywallet.com
const sendInput = await page.locator("input");
Expand Down
12 changes: 7 additions & 5 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import { expect, Page } from "@playwright/test";
export async function loadHome(page: Page) {
// Start on the home page
await expect(page).toHaveTitle(/Mutiny Wallet/);
await page.waitForSelector("text=Welcome to the Mutiny!");
// await page.waitForSelector("text=Welcome to the Mutiny!");

console.log("Waiting for new wallet to be created...");
// console.log("Waiting for new wallet to be created...");

await page.locator(`button:has-text('New Wallet')`).click();
// await page.locator(`button:has-text('New Wallet')`).click();

await page.locator("text=Create your profile").first();
// await page.locator("text=Create your profile").first();

await page.locator("button:has-text('Skip for now')").click();
// await page.locator("button:has-text('Skip for now')").click();

// Should have a balance up top now
await page.locator(`text=0 sats`).first();
// Status light should be ready
await page.locator(`title="READY"`).first();
}

export async function visitSettings(page: Page) {
Expand Down
19 changes: 10 additions & 9 deletions src/components/ActivityDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,12 @@ function OnchainHeader(props: { info: OnChainTx; kind?: HackActivityType }) {
{props.kind === "ChannelOpen"
? i18n.t("activity.transaction_details.channel_open")
: props.kind === "ChannelClose"
? i18n.t("activity.transaction_details.channel_close")
: isSend()
? i18n.t("activity.transaction_details.onchain_send")
: i18n.t("activity.transaction_details.onchain_receive")}
? i18n.t("activity.transaction_details.channel_close")
: isSend()
? i18n.t("activity.transaction_details.onchain_send")
: i18n.t(
"activity.transaction_details.onchain_receive"
)}
<Switch>
<Match
when={
Expand Down Expand Up @@ -302,8 +304,8 @@ function OnchainDetails(props: {
await (state.mutiny_wallet?.list_channels() as Promise<
MutinyChannel[]
>);
const channel = channels.find(
(channel) => channel.outpoint?.startsWith(props.info.txid)
const channel = channels.find((channel) =>
channel.outpoint?.startsWith(props.info.txid)
);
return channel;
} catch (e) {
Expand Down Expand Up @@ -492,9 +494,8 @@ export function ActivityDetailsModal(props: {
try {
if (kind() === "Lightning") {
console.debug("reading invoice: ", id());
const invoice = await state.mutiny_wallet?.get_invoice_by_hash(
id()
);
const invoice =
await state.mutiny_wallet?.get_invoice_by_hash(id());
return invoice;
} else if (kind() === "ChannelClose") {
console.debug("reading channel close: ", id());
Expand Down
Loading

0 comments on commit aa7da17

Please sign in to comment.