Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions extension/e2e-tests/sendPayment.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TransactionBuilder } from "stellar-sdk";
import { test, expect } from "./test-fixtures";
import { login, loginAndFund, loginToTestAccount } from "./helpers/login";
import { TEST_M_ADDRESS, TEST_TOKEN_ADDRESS } from "./helpers/test-token";
Expand Down Expand Up @@ -241,6 +242,75 @@ test("Send can review formatted inputs", async ({ page, extensionId }) => {
});
});

test("Send persists inputs and submits to network", async ({
page,
extensionId,
}) => {
test.slow();
await loginAndFund({ page, extensionId });
await page.getByTestId("nav-link-send").click({ force: true });

await expect(page.getByText("Send")).toBeVisible();
await page
.getByTestId("send-to-input")
.fill("GBTYAFHGNZSTE4VBWZYAGB3SRGJEPTI5I4Y22KZ4JTVAN56LESB6JZOF");
await page.getByText("Continue").click();

await expect(page.getByTestId("AppHeaderPageTitle")).toContainText("Send");
await page.getByTestId(`SendRow-native`).click({ force: true });
await page.getByTestId("send-amount-amount-input").fill("1000");
await page.getByTestId("send-amount-btn-memo").click();
await page.getByTestId("edit-memo-input").fill("test memo");
await page.getByText("Save").click();
await page.getByTestId("send-amount-btn-fee").click();
await page.getByTestId("edit-tx-settings-fee-input").fill("0.00009");
await page.getByText("Save").click();
await page.getByText("Review Send").click({ force: true });
await expect(page.getByText("You are sending")).toBeVisible({
timeout: 200000,
});
await expect(page.getByTestId("review-tx-send-amount")).toHaveText(
"1000 XLM",
);
await expect(page.getByTestId("review-tx-memo")).toHaveText("test memo");
await expect(page.getByTestId("review-tx-fee")).toHaveText("0.00009 XLM");

let submitTxResponse = "";
page.on("response", async (response) => {
if (response.url().includes("/submit-tx")) {
submitTxResponse = await response.text();
}
});

await page.getByTestId(`SubmitAction`).click();

await expect(page.getByText("Sent!")).toBeVisible({
timeout: 60000,
});
console.log("submitTxResponse", submitTxResponse);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover debug log

const submitTxResponseJson = JSON.parse(submitTxResponse);

expect(submitTxResponseJson.memo).toBe("test memo");
expect(submitTxResponseJson.max_fee).toBe("900");

const tx = TransactionBuilder.fromXDR(
submitTxResponseJson.envelope_xdr,
"Test SDF Network ; September 2015",
);
console.log(tx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same


const txOp = tx.operations[0] as any;

expect(txOp.type).toBe("payment");
expect(txOp.amount).toBe("1000.0000000");
expect(txOp.destination).toBe(
"GBTYAFHGNZSTE4VBWZYAGB3SRGJEPTI5I4Y22KZ4JTVAN56LESB6JZOF",
);
expect(txOp.asset.code).toBe("XLM");

await page.getByText("Done").click();
});

test("Send XLM payments to recent federated addresses", async ({
page,
extensionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const EditMemo = ({ memo, onClose, onSubmit }: EditMemoProps) => {
<Field name="memo">
{({ field }: FieldProps) => (
<Input
data-testid="edit-memo-input"
autoFocus
fieldSize="md"
autoComplete="off"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const EditSettings = ({
<Field name="fee">
{({ field }: FieldProps) => (
<Input
data-testid="edit-tx-settings-fee-input"
type="text"
min={0}
autoFocus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ export const ReviewTx = ({
icon={assetIcon}
isSuspicious={false}
/>
<div className="ReviewTx__SendAssetDetails">
<div
className="ReviewTx__SendAssetDetails"
data-testid="review-tx-send-amount"
>
<span>
{sendAmount} {asset.code}
</span>
Expand All @@ -151,7 +154,10 @@ export const ReviewTx = ({
<div className="ReviewTx__Divider">
<Icon.ChevronDownDouble />
</div>
<div className="ReviewTx__SendDestination">
<div
className="ReviewTx__SendDestination"
data-testid="review-tx-send-destination"
>
{dstAsset && dest ? (
<>
<AssetIcon
Expand Down Expand Up @@ -201,7 +207,10 @@ export const ReviewTx = ({
<Icon.File02 />
Memo
</div>
<div className="ReviewTx__Details__Row__Value">
<div
className="ReviewTx__Details__Row__Value"
data-testid="review-tx-memo"
>
{memo || "None"}
</div>
</div>
Expand All @@ -210,7 +219,10 @@ export const ReviewTx = ({
<Icon.Route />
Fee
</div>
<div className="ReviewTx__Details__Row__Value">
<div
className="ReviewTx__Details__Row__Value"
data-testid="review-tx-fee"
>
{fee} XLM
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ export const SendAmount = ({
</div>
<div className="SendAmount__settings-options">
<Button
data-testid="send-amount-btn-memo"
size="md"
isRounded
variant="tertiary"
Expand All @@ -311,6 +312,7 @@ export const SendAmount = ({
{t("Memo")}
</Button>
<Button
data-testid="send-amount-btn-fee"
size="md"
isRounded
variant="tertiary"
Expand Down
Loading