Skip to content

Commit

Permalink
🧪 test: [QAA129] Adding new send test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
VicAlbr committed Aug 20, 2024
1 parent a442d80 commit 304454e
Show file tree
Hide file tree
Showing 6 changed files with 13,914 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const Root: NonNullable<EvmFamily["sendAmountFields"]>["component"] = props => {
)}
{messageGas && (
<Flex onClick={onBuyClick}>
<Alert type="warning">
<Alert type="warning" data-testid="alert-insufficient-funds-warning">
<TranslatedError error={messageGas} />
</Alert>
</Flex>
Expand Down
8 changes: 8 additions & 0 deletions apps/ledger-live-desktop/tests/component/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class Layout extends Component {

// general
readonly inputError = this.page.locator("id=input-error"); // no data-testid because css style is applied
readonly inputWarning = this.page.getByTestId("alert-insufficient-funds-warning");
private loadingSpinner = this.page.getByTestId("loading-spinner");
readonly logo = this.page.getByTestId("logo");

Expand Down Expand Up @@ -98,6 +99,13 @@ export class Layout extends Component {
await this.topbarSettingsButton.click();
}

@step("Check warning message")
async checkWarningMessage(expectedWarningMessage: RegExp) {
await this.inputWarning.waitFor({ state: "visible" });
const warningText = await this.inputWarning.innerText();
expect(warningText).toMatch(expectedWarningMessage);
}

@step("Check if the error message is the same as expected")
async checkErrorMessage(errorMessage: string | null) {
if (errorMessage !== null) {
Expand Down
18 changes: 15 additions & 3 deletions apps/ledger-live-desktop/tests/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,18 @@ export class Account {
"0xB9051f83AC6e147924377BBEebd1Aa7aB43a67F6",
);

static readonly ETH_USDT = new Account(
static readonly ETH_USDT_1 = new Account(
Currency.ETH_USDT,
"Ethereum 1",
"0xB9051f83AC6e147924377BBEebd1Aa7aB43a67F6",
);

static readonly ETH_USDT_2 = new Account(
Currency.ETH_USDT,
"Ethereum 2",
"0x43047a5023D55a8658Fcb1c1Cea468311AdAA3Ad",
);

static readonly ETH_LIDO = new Account(
Currency.ETH_LIDO,
"Ethereum 1",
Expand Down Expand Up @@ -253,19 +259,25 @@ export class Account {
"TDUKFB9wj3P5f2iNvkRuaDDeWVkTdUVhs1",
);

static readonly BSC_BUSD = new Account(
static readonly BSC_BUSD_1 = new Account(
Currency.BSC_BUSD,
"Binance Smart Chain 1",
"0xB9051f83AC6e147924377BBEebd1Aa7aB43a67F6",
);

static readonly BSC_BUSD_2 = new Account(
Currency.BSC_BUSD,
"Binance Smart Chain 2",
"0x43047a5023D55a8658Fcb1c1Cea468311AdAA3Ad",
);

static readonly BSC_SHIBA = new Account(
Currency.BSC_SHIBA,
"Binance Smart Chain 1",
"0xB9051f83AC6e147924377BBEebd1Aa7aB43a67F6",
);

static readonly MATIC_DAI = new Account(
static readonly MATIC_DAI_1 = new Account(
Currency.MATIC_DAI,
"Polygon 1",
"0xB9051f83AC6e147924377BBEebd1Aa7aB43a67F6",
Expand Down
84 changes: 80 additions & 4 deletions apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ for (const transaction of transactionE2E) {
});
}

test.describe("Send token (subAccount) - invalid input", () => {
test.describe("Send token (subAccount) - invalid address input", () => {
const tokenTransactionInvalid = {
transaction: new Transaction(Account.ALGO_USDT_1, Account.ALGO_USDT_2, "0.1", Fee.MEDIUM),
expectedErrorMessage: "Recipient account has not opted in the selected ASA.",
Expand All @@ -93,7 +93,7 @@ test.describe("Send token (subAccount) - invalid input", () => {
});

test(
`Send from ${tokenTransactionInvalid.transaction.accountToDebit.accountName} to ${tokenTransactionInvalid.transaction.accountToCredit.accountName} - invalid input`,
`Send from ${tokenTransactionInvalid.transaction.accountToDebit.accountName} to ${tokenTransactionInvalid.transaction.accountToCredit.accountName} - invalid address input`,
{
annotation: {
type: "TMS",
Expand All @@ -116,7 +116,83 @@ test.describe("Send token (subAccount) - invalid input", () => {
);
});

test.describe("Send token (subAccount) - valid input", () => {
test.describe("Send token (subAccount) - invalid amount input", () => {
const tokenTransactionInvalid = [
{
transaction: new Transaction(Account.BSC_BUSD_1, Account.BSC_BUSD_2, "1", Fee.MEDIUM),
expectedWarningMessage: new RegExp(
/You need \d+\.\d+ BNB in your account to pay for transaction fees on the Binance Smart Chain network\. .*/,
),
},
{
transaction: new Transaction(Account.ETH_USDT_2, Account.ETH_USDT_1, "1", Fee.MEDIUM),
expectedWarningMessage: new RegExp(
/You need \d+\.\d+ ETH in your account to pay for transaction fees on the Ethereum network\. .*/,
),
},
];
for (const transaction of tokenTransactionInvalid) {
test.use({
userdata: "speculos-2ETH-2BNB",
speculosCurrency: transaction.transaction.accountToDebit.currency,
});
test(
`Send from ${transaction.transaction.accountToDebit.accountName} to ${transaction.transaction.accountToCredit.accountName} - invalid amount input`,
{
annotation: {
type: "TMS",
description: "B2CQA-475",
},
},
async ({ app }) => {
await app.layout.goToAccounts();
await app.accounts.navigateToAccountByName(
transaction.transaction.accountToDebit.accountName,
);
await app.account.navigateToTokenInAccount(transaction.transaction.accountToDebit);
await app.account.clickSend();
await app.send.fillRecipient(transaction.transaction.accountToCredit.address);
await app.send.clickContinue();
await app.send.fillAmount(transaction.transaction.amount);
await app.send.checkContinueButtonDisabled();
await app.layout.checkWarningMessage(transaction.expectedWarningMessage);
},
);
}
});

test.describe("Send token (subAccount) - valid amount input", () => {
const tokenTransactionInvalid = [
new Transaction(Account.ETH_USDT_1, Account.ETH_USDT_2, "1", Fee.MEDIUM),
];
for (const transaction of tokenTransactionInvalid) {
test.use({
userdata: "speculos-tests-app",
speculosCurrency: transaction.accountToDebit.currency,
});
test(
`Send from ${transaction.accountToDebit.accountName} to ${transaction.accountToCredit.accountName} - valid amount input`,
{
annotation: {
type: "TMS",
description: "B2CQA-475",
},
},
async ({ app }) => {
await app.layout.goToAccounts();
await app.accounts.navigateToAccountByName(transaction.accountToDebit.accountName);
await app.account.navigateToTokenInAccount(transaction.accountToDebit);
await app.account.clickSend();
await app.send.fillRecipient(transaction.accountToCredit.address);
await app.send.clickContinue();
await app.send.fillAmount(transaction.amount);
await app.send.checkContinueButtonEnable();
},
);
}
});

test.describe("Send token (subAccount) - valid address input", () => {
const tokenTransactionValid = new Transaction(
Account.ALGO_USDT_1,
Account.ALGO_USDT_3,
Expand All @@ -130,7 +206,7 @@ test.describe("Send token (subAccount) - valid input", () => {
});

test(
`Send from ${tokenTransactionValid.accountToDebit.accountName} to ${tokenTransactionValid.accountToCredit.accountName} - valid input`,
`Send from ${tokenTransactionValid.accountToDebit.accountName} to ${tokenTransactionValid.accountToCredit.accountName} - valid address input`,
{
annotation: {
type: "TMS",
Expand Down
12 changes: 6 additions & 6 deletions apps/ledger-live-desktop/tests/specs/speculos/subAccount.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import { addTmsLink } from "tests/utils/allureUtils";
import { getDescription } from "../../utils/customJsonReporter";

const subAccounts: Account[] = [
Account.ETH_USDT,
Account.ETH_USDT_1,
Account.XLM_USCD,
Account.ALGO_USDT_1,
Account.TRX_USDT,
Account.BSC_BUSD,
Account.MATIC_DAI,
Account.BSC_BUSD_1,
Account.MATIC_DAI_1,
];

const subAccountReceive: Account[] = [
Account.ETH_USDT,
Account.ETH_USDT_1,
Account.ETH_LIDO,
Account.TRX_USDT,
Account.TRX_BTT,
Account.BSC_BUSD,
Account.BSC_BUSD_1,
Account.BSC_SHIBA,
Account.MATIC_DAI,
Account.MATIC_DAI_1,
Account.MATIC_UNI,
];

Expand Down
Loading

0 comments on commit 304454e

Please sign in to comment.