Skip to content

Commit

Permalink
Merge pull request #9073 from LedgerHQ/support/qaa_449_detox_memo_tag
Browse files Browse the repository at this point in the history
[QAA-449][Detox][Speculos] Add memo tag in Send test
  • Loading branch information
abdurrahman-ledger authored Feb 4, 2025
2 parents 20dd3f9 + 19bd5dd commit 0e25c32
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 33 deletions.
32 changes: 27 additions & 5 deletions apps/ledger-live-mobile/e2e/page/trade/send.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ export default class SendPage {
summaryAmountId = "send-summary-amount";
summaryRecipient = () => getElementById("send-summary-recipient");
summaryRecipientEns = () => getElementById("send-summary-recipient-ens");
summaryMemoTagId = "summary-memo-tag";
summaryMemoTag = () => getElementById(this.summaryMemoTagId);
validationAmountId = "send-validation-amount";
validationAddressId = "send-validation-address";
validationEnsId = "send-validation-domain";
getStep1HeaderTitle = () => getElementById("send-header-step1-title");
recipientContinueButtonId = "recipient-continue-button";
recipientInputId = "recipient-input";
recipientErrorId = "send-recipient-error";
memoTagInputId = "memo-tag-input";
memoTagDrawerTitleId = "memo-tag-drawer-title";
memoTagIgnoreButtonId = "memo-tag-ignore-button";
amountInputId = "amount-input";
amountErrorId = "send-amount-error";
amountMaxSwitch = () => getElementById("send-amount-max-switch");
Expand All @@ -47,13 +52,22 @@ export default class SendPage {
await expect(this.getStep1HeaderTitle()).toBeVisible();
}

async setRecipient(address: string) {
@Step("Set recipient and memo tag")
async setRecipient(address: string, memoTag?: string) {
await typeTextById(this.recipientInputId, address);
if (memoTag && memoTag !== "noTag") {
await typeTextById(this.memoTagInputId, memoTag);
}
}

async recipientContinue() {
@Step("Continue to next step and skip memo tag if needed")
async recipientContinue(memoTag?: string) {
await waitForElementById(this.recipientContinueButtonId); // To prevent flakiness
await tapById(this.recipientContinueButtonId);
if (memoTag == "noTag") {
await waitForElementById(this.memoTagDrawerTitleId);
await tapById(this.memoTagIgnoreButtonId);
}
}

@Step("Expect recipient error message")
Expand All @@ -72,9 +86,9 @@ export default class SendPage {
}

@Step("Set recipient and continue")
async setRecipientAndContinue(address: string) {
await this.setRecipient(address);
await this.recipientContinue();
async setRecipientAndContinue(address: string, memoTag?: string) {
await this.setRecipient(address, memoTag);
await this.recipientContinue(memoTag);
}

@Step("Set the amount and return the value")
Expand Down Expand Up @@ -152,6 +166,14 @@ export default class SendPage {
await expect(this.summaryRecipientEns()).toHaveText(ensName);
}

@Step("Expect memo tag in summary")
async expectSummaryMemoTag(memoTag?: string) {
if (memoTag && memoTag !== "noTag") await expect(this.summaryMemoTag()).toHaveText(memoTag);
else if (await IsIdVisible(this.summaryMemoTagId)) {
await expect(this.summaryMemoTag()).toHaveText("");
}
}

@Step("Dismiss high fee modal if visible")
async dismissHighFeeModal() {
if (await IsIdVisible(this.highFreeConfirmButtonID))
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-mobile/e2e/specs/send/currencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("Send flow", () => {
await app.common.performSearch(accountName);
await app.common.selectAccount(account.id);
await app.send.setRecipient(account.freshAddress);
await app.send.recipientContinue();
await app.send.recipientContinue(account.currency.name == "Cosmos" ? "noTag" : undefined);
await app.send.setAmount(amountInput);
await app.send.amountContinue();
await app.send.expectSummaryAmount(amountWithCode);
Expand Down
35 changes: 23 additions & 12 deletions apps/ledger-live-mobile/e2e/specs/speculos/send/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ export async function runSendTest(transaction: Transaction, tmsLink: string) {
});

it(`Send from ${transaction.accountToDebit.accountName} to ${transaction.accountToCredit.accountName}`, async () => {
const addressToCredit = transaction.accountToCredit.address;
await navigateToSendScreen(app, transaction.accountToDebit.accountName);
await app.send.setRecipientAndContinue(transaction.accountToCredit.address);
await app.send.setRecipientAndContinue(addressToCredit, transaction.memoTag);
await app.send.setAmountAndContinue(transaction.amount);

const amountWithCode = transaction.amount + " " + transaction.accountToCredit.currency.ticker;
await app.send.expectSummaryAmount(amountWithCode);
await app.send.expectSummaryRecipient(transaction.accountToCredit.address);
await app.send.expectSummaryRecipient(addressToCredit);
await app.send.expectSummaryMemoTag(transaction.memoTag);
await app.send.summaryContinue();
await app.send.dismissHighFeeModal();

Expand All @@ -59,7 +61,7 @@ export async function runSendTest(transaction: Transaction, tmsLink: string) {

await app.operationDetails.waitForOperationDetails();
await app.operationDetails.checkAccount(transaction.accountToDebit.accountName);
await app.operationDetails.checkRecipient(transaction.accountToCredit.address);
await app.operationDetails.checkRecipient(addressToCredit);
await app.operationDetails.checkTransactionType("OUT");
});
});
Expand All @@ -81,7 +83,7 @@ export async function runSendInvalidAddressTest(

it(`Send from ${transaction.accountToDebit.accountName} ${accountName || ""} to ${transaction.accountToCredit.accountName} - invalid address input`, async () => {
await navigateToSendScreen(app, accountName || transaction.accountToDebit.accountName);
await app.send.setRecipient(transaction.accountToCredit.address);
await app.send.setRecipient(transaction.accountToCredit.address, transaction.memoTag);
await app.send.expectSendRecipientError(expectedErrorMessage);
});
});
Expand All @@ -103,14 +105,15 @@ export async function runSendValidAddressTest(

it(`Send from ${transaction.accountToDebit.accountName} ${accountName || ""} to ${transaction.accountToCredit.accountName} - valid address & amount input`, async () => {
await navigateToSendScreen(app, accountName || transaction.accountToDebit.accountName);
await app.send.setRecipient(transaction.accountToCredit.address);
await app.send.setRecipient(transaction.accountToCredit.address, transaction.memoTag);
await app.send.expectSendRecipientSuccess(expectedWarningMessage);
await app.send.recipientContinue();
await app.send.recipientContinue(transaction.memoTag);
await app.send.setAmountAndContinue(transaction.amount);

const amountWithCode = transaction.amount + " " + transaction.accountToCredit.currency.ticker;
await app.send.expectSummaryAmount(amountWithCode);
await app.send.expectSummaryRecipient(transaction.accountToCredit.address);
await app.send.expectSummaryMemoTag(transaction.memoTag);
if (expectedWarningMessage) await app.send.expectSummaryWarning(expectedWarningMessage);
});
});
Expand All @@ -131,7 +134,10 @@ export async function runSendInvalidAmountTest(

it(`Check "${expectedErrorMessage}" for ${transaction.accountToDebit.currency.name} - invalid amount ${transaction.amount} input error`, async () => {
await navigateToSendScreen(app, transaction.accountToDebit.accountName);
await app.send.setRecipientAndContinue(transaction.accountToCredit.address);
await app.send.setRecipientAndContinue(
transaction.accountToCredit.address,
transaction.memoTag,
);
await app.send.setAmount(transaction.amount);
await app.send.expectSendAmountError(expectedErrorMessage);
});
Expand All @@ -152,15 +158,17 @@ export async function runSendInvalidTokenAmountTest(
});

it(`Check error message for ${transaction.accountToDebit.currency.name} - invalid amount ${transaction.amount} input error`, async () => {
const addressToCredit = transaction.accountToCredit.address;
await navigateToSendScreen(app, transaction.accountToDebit.currency.name);
await app.send.setRecipientAndContinue(transaction.accountToCredit.address);
await app.send.setRecipientAndContinue(addressToCredit, transaction.memoTag);
await app.send.setAmount(transaction.amount);
await app.send.expectSendAmountSuccess();
await app.send.amountContinue();

const amountWithCode = transaction.amount + " " + transaction.accountToCredit.currency.ticker;
await app.send.expectSummaryAmount(amountWithCode);
await app.send.expectSummaryRecipient(transaction.accountToCredit.address);
await app.send.expectSummaryRecipient(addressToCredit);
await app.send.expectSummaryMemoTag(transaction.memoTag);
await app.send.expectSendSummaryError(expectedErrorMessage);
});
});
Expand All @@ -177,14 +185,16 @@ export async function runSendMaxTest(transaction: Transaction, tmsLink: string)
});

it(`Check Valid amount input (${transaction.amount}) - ${transaction.accountToCredit.accountName}`, async () => {
const addressToCredit = transaction.accountToCredit.address;
await navigateToSendScreen(app, transaction.accountToDebit.accountName);
await app.send.setRecipientAndContinue(transaction.accountToCredit.address);
await app.send.setRecipientAndContinue(addressToCredit, transaction.memoTag);
const amount = await app.send.setAmount("max");
await app.send.expectSendAmountSuccess();
await app.send.amountContinue();

await app.send.expectSummaryMaxAmount(amount);
await app.send.expectSummaryRecipient(transaction.accountToCredit.address);
await app.send.expectSummaryRecipient(addressToCredit);
await app.send.expectSummaryMemoTag(transaction.memoTag);
});
});
}
Expand All @@ -204,13 +214,14 @@ export async function runSendENSTest(transaction: Transaction, tmsLink: string)
invariant(ensName, "ENS name is not provided");

await navigateToSendScreen(app, transaction.accountToDebit.accountName);
await app.send.setRecipientAndContinue(ensName);
await app.send.setRecipientAndContinue(ensName, transaction.memoTag);
await app.send.setAmountAndContinue(transaction.amount);

const amountWithCode = transaction.amount + " " + transaction.accountToCredit.currency.ticker;
await app.send.expectSummaryAmount(amountWithCode);
await app.send.expectSummaryRecipient(transaction.accountToCredit.address);
await app.send.expectSummaryRecipientEns(ensName);
await app.send.expectSummaryMemoTag(transaction.memoTag);
await app.send.summaryContinue();
await app.send.dismissHighFeeModal();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { Account } from "@ledgerhq/live-common/e2e/enum/Account";
import { Transaction } from "@ledgerhq/live-common/e2e/models/Transaction";
import { runSendTest } from "../send/send";

const transaction = new Transaction(Account.ALGO_1, Account.ALGO_2, "0.001");
const transaction = new Transaction(Account.ALGO_1, Account.ALGO_2, "0.001", undefined, "noTag");
runSendTest(transaction, "B2CQA-2810");
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { Account } from "@ledgerhq/live-common/e2e/enum/Account";
import { Transaction } from "@ledgerhq/live-common/e2e/models/Transaction";
import { runSendValidAddressTest } from "../send";

const transaction = new Transaction(Account.ATOM_1, Account.ATOM_2, "0.0001");
const transaction = new Transaction(Account.ATOM_1, Account.ATOM_2, "0.0001", undefined, "noTag");
runSendValidAddressTest(transaction, "B2CQA-2721");
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { Account } from "@ledgerhq/live-common/e2e/enum/Account";
import { Transaction } from "@ledgerhq/live-common/e2e/models/Transaction";
import { runSendValidAddressTest } from "../send";

const transaction = new Transaction(Account.XRP_1, Account.XRP_2, "2");
const transaction = new Transaction(Account.XRP_1, Account.XRP_2, "2", undefined, "noTag");
runSendValidAddressTest(transaction, "B2CQA-2719");
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ export default function CardanoSendRowsCustom(props: Props) {
<View>
<SummaryRow title={t("send.summary.memo.title")} onPress={editMemo}>
{transaction.memo ? (
<LText semiBold style={styles.tagText} onPress={editMemo} numberOfLines={1}>
<LText
semiBold
style={styles.tagText}
onPress={editMemo}
numberOfLines={1}
testID="summary-memo-tag"
>
{transaction.memo}
</LText>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ export default function CosmosFamilySendRowsCustomComponent({ transaction, editM
<View>
<SummaryRow title={t("send.summary.memo.title")} onPress={editMemo}>
{transaction.memo ? (
<LText semiBold style={styles.tagText} onPress={editMemo} numberOfLines={1}>
<LText
semiBold
style={styles.tagText}
onPress={editMemo}
numberOfLines={1}
testID="summary-memo-tag"
>
{transaction.memo}
</LText>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ export default function HederaSendRowsCustom(props: Props) {
<View>
<SummaryRow title={t("send.summary.memo.title")} onPress={editMemo}>
{transaction.memo ? (
<LText semiBold style={styles.tagText} onPress={editMemo} numberOfLines={1}>
<LText
semiBold
style={styles.tagText}
onPress={editMemo}
numberOfLines={1}
testID="summary-memo-tag"
>
{transaction.memo}
</LText>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function InternetComputerMemoRow({ account, transaction }: Props)
</SummaryRow>
) : (
<SummaryRow title={<Trans i18nKey="common.edit" />} onPress={editMemo}>
<LText semiBold style={styles.tagText} onPress={editMemo}>
<LText semiBold style={styles.tagText} onPress={editMemo} testID="summary-memo-tag">
{String(memo)}
</LText>
</SummaryRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ export default function SolanaSendRowsCustom({ account, transaction, navigation,
<View>
<SummaryRow title={t("send.summary.memo.title")} onPress={editMemo}>
{model.uiState.memo ? (
<Text fontWeight="semiBold" style={styles.tagText} onPress={editMemo} numberOfLines={1}>
<Text
fontWeight="semiBold"
style={styles.tagText}
onPress={editMemo}
numberOfLines={1}
testID="summary-memo-tag"
>
{model.uiState.memo}
</Text>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function StacksMemoRow({ account, transaction }: Props) {
</SummaryRow>
) : (
<SummaryRow title={<Trans i18nKey="common.edit" />} onPress={editMemo}>
<LText semiBold style={styles.tagText} onPress={editMemo}>
<LText semiBold style={styles.tagText} onPress={editMemo} testID="summary-memo-tag">
{String(memo)}
</LText>
</SummaryRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function StellarMemoValueRow({ account, transaction }: Props) {
title={<Trans i18nKey={`stellar.memoType.${memoType || "NO_MEMO"}`} />}
onPress={editMemo}
>
<LText semiBold style={styles.tagText} onPress={editMemo}>
<LText semiBold style={styles.tagText} onPress={editMemo} testID="summary-memo-tag">
{String(memoValue)}
</LText>
</SummaryRow>
Expand Down
6 changes: 5 additions & 1 deletion apps/ledger-live-mobile/src/families/xrp/SendRowTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export default function XrpTagRow({ account, transaction }: Props) {
<View>
<SummaryRow title={<Trans i18nKey="send.summary.tag" />}>
<View style={styles.tagContainer}>
{tag && <LText style={styles.tagText}>{tag.toString()}</LText>}
{tag && (
<LText style={styles.tagText} testID="summary-memo-tag">
{tag.toString()}
</LText>
)}
<LText
style={[
styles.link,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,12 @@ export function GenericMemoTagInput<T extends Transaction>({
onChange({ value, patch });
};

return <AnimatedInput {...inputProps} value={value} onChangeText={handleChange} />;
return (
<AnimatedInput
{...inputProps}
value={value}
onChangeText={handleChange}
testID="memo-tag-input"
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function GenericMemoTagSummary({
}
data={
<Flex pt={2}>
<Text fontSize={13} onPress={editMemo} numberOfLines={1}>
<Text fontSize={13} onPress={editMemo} numberOfLines={1} testID="summary-memo-tag">
{memoTag}
</Text>
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,29 @@ export const MemoTagDrawer = memo(({ open, onClose, onNext }: Props) => {
</Circle>
</Flex>

<Text variant="h4" textAlign="center" mb={6}>
<Text variant="h4" textAlign="center" mb={6} testID="memo-tag-drawer-title">
{t("transfer.memoTag.title")}
</Text>

<Text variant="bodyLineHeight" textAlign="center" color="neutral.c80" mb={8}>
{t("transfer.memoTag.description")}
</Text>

<Button type="primary" title={t("transfer.memoTag.cta")} onPress={onClose} mb={3} />
<Button
type="primary"
title={t("transfer.memoTag.cta")}
onPress={onClose}
mb={3}
testID="memo-tag-add-button"
/>

<Button
type="tertiary"
title={t("transfer.memoTag.ignore")}
onPress={onNext}
outline
mb={3}
testID="memo-tag-ignore-button"
/>

<Button
Expand Down

0 comments on commit 0e25c32

Please sign in to comment.