Skip to content

Commit

Permalink
contact search and new amount editor
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul authored and AnthonyRonning committed Jan 10, 2024
1 parent 077ccb2 commit bc2fbf9
Show file tree
Hide file tree
Showing 65 changed files with 2,027 additions and 2,465 deletions.
89 changes: 50 additions & 39 deletions e2e/roundtrip.spec.ts
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 });
Expand All @@ -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 });
});

});
4 changes: 3 additions & 1 deletion e2e/routes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ test("visit each route", async ({ page }) => {

// Swap
await page.goto("http://localhost:3420/swap");
await expect(page.locator("h1")).toHaveText("Swap to Lightning");
await expect(
page.getByRole("heading", { name: "Swap to Lightning" })
).toBeVisible();
checklist.set("/swap", true);

// Gift
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,13 @@
"@mutinywallet/mutiny-wasm": "0.5.2",
"@mutinywallet/waila-wasm": "^0.2.6",
"@solid-primitives/upload": "^0.0.111",
"@solid-primitives/websocket": "^1.2.0",
"@solidjs/meta": "^0.29.1",
"@solidjs/router": "^0.9.0",
"@thisbeyond/solid-select": "^0.14.0",
"i18next": "^22.5.1",
"i18next-browser-languagedetector": "^7.1.0",
"qr-scanner": "^1.4.2",
"solid-js": "^1.8.5",
"solid-qr-code": "^0.0.8",
"undici": "^5.27.1"
"solid-qr-code": "^0.0.8"
},
"engines": {
"node": ">=18"
Expand Down
37 changes: 0 additions & 37 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions src/components/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ import { useI18n } from "~/i18n/context";
import { useMegaStore } from "~/state/megaStore";
import { createDeepSignal } from "~/utils";

export const THREE_COLUMNS =
"grid grid-cols-[auto,1fr,auto] gap-4 py-2 px-2 border-b border-neutral-800 last:border-b-0";
export const CENTER_COLUMN = "min-w-0 overflow-hidden max-w-full";
export const MISSING_LABEL =
"py-1 px-2 bg-white/10 rounded inline-block text-sm";
export const RIGHT_COLUMN = "flex flex-col items-right text-right max-w-[8rem]";

export interface IActivityItem {
interface IActivityItem {
kind: HackActivityType;
id: string;
amount_sats: number;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ActivityDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function MiniStringShower(props: { text: string }) {
);
}

export function FormatPrettyPrint(props: { ts: number }) {
function FormatPrettyPrint(props: { ts: number }) {
return (
<div>
{prettyPrintTime(props.ts).split(",", 2).join(",")}
Expand Down
52 changes: 3 additions & 49 deletions src/components/ActivityItem.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { TagItem } from "@mutinywallet/mutiny-wasm";
import { createResource, Match, ParentComponent, Switch } from "solid-js";
import { Match, ParentComponent, Switch } from "solid-js";

import bolt from "~/assets/icons/bolt.svg";
import chain from "~/assets/icons/chain.svg";
import off from "~/assets/icons/download-channel.svg";
import shuffle from "~/assets/icons/shuffle.svg";
import on from "~/assets/icons/upload-channel.svg";
import { AmountFiat, AmountSats } from "~/components";
import { AmountFiat, AmountSats, LabelCircle } from "~/components";
import { useI18n } from "~/i18n/context";
import { useMegaStore } from "~/state/megaStore";
import { generateGradient, timeAgo } from "~/utils";
import { timeAgo } from "~/utils";

export const ActivityAmount: ParentComponent<{
amount: string;
Expand Down Expand Up @@ -44,50 +42,6 @@ export const ActivityAmount: ParentComponent<{
);
};

function LabelCircle(props: {
name?: string;
image_url?: string;
contact: boolean;
label: boolean;
channel?: HackActivityType;
}) {
const [gradient] = createResource(async () => {
if (props.name && props.contact) {
return generateGradient(props.name || "?");
} else {
return undefined;
}
});

const text = () =>
props.contact && props.name && props.name.length
? props.name[0]
: props.label
? "≡"
: "?";
const bg = () => (props.name && props.contact ? gradient() : "");

return (
<div
class="flex h-[3rem] w-[3rem] flex-none items-center justify-center overflow-clip rounded-full border-b border-t border-b-white/10 border-t-white/50 bg-neutral-700 text-3xl uppercase"
style={{ background: bg() }}
>
<Switch>
<Match when={props.image_url}>
<img src={props.image_url} alt={"image"} />
</Match>
<Match when={props.channel === "ChannelOpen"}>
<img src={on} alt="channel open" />
</Match>
<Match when={props.channel === "ChannelClose"}>
<img src={off} alt="channel close" />
</Match>
<Match when={true}>{text()}</Match>
</Switch>
</div>
);
}

export type HackActivityType =
| "Lightning"
| "OnChain"
Expand Down
Loading

0 comments on commit bc2fbf9

Please sign in to comment.