Skip to content

Commit

Permalink
Merge pull request #7432 from LedgerHQ/revert-7200-support/qaa-84_sen…
Browse files Browse the repository at this point in the history
…d_test

Revert "[QAA 84] [Playwright] [Speculos] Adding new checks for send test + new tests cases"
  • Loading branch information
VicAlbr authored Jul 25, 2024
2 parents c6cf93e + 6f66cad commit efe88bf
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 350 deletions.
19 changes: 0 additions & 19 deletions apps/ledger-live-desktop/tests/component/layout.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from "@playwright/test";
import { step } from "../misc/reporters/step";
import { Component } from "tests/page/abstractClasses";

Expand Down Expand Up @@ -52,15 +51,6 @@ export class Layout extends Component {
await this.drawerMarketButton.click();
}

async checkInputErrorNotVisible() {
await this.inputError.waitFor({ state: "hidden" });
}

@step("synchronize accounts")
async syncAccounts() {
await this.topbarSynchronizeButton.click();
}

@step("Open Accounts")
async goToAccounts() {
await this.drawerAccountsButton.click();
Expand Down Expand Up @@ -96,15 +86,6 @@ export class Layout extends Component {
await this.topbarSettingsButton.click();
}

async checkErrorMessage(errorMessage: string | null) {
if (errorMessage !== null) {
await this.inputError.waitFor({ state: "visible" });
const errorText: any = await this.inputError.textContent();
const normalize = (str: string) => str.replace(/\u00A0/g, " ").trim();
expect(normalize(errorText)).toEqual(normalize(errorMessage));
}
}

async lockApp() {
await this.topbarLockButton.click();
}
Expand Down
12 changes: 0 additions & 12 deletions apps/ledger-live-desktop/tests/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ export class Account {
"12fY9vqzD8j1uvqSRx9y3gXRA1S3bwr5xunBVZvx1eeZFaHY",
);

static readonly DOT_3 = new Account(
Currency.DOT,
"Polkadot 3",
"1532VyvZyyMUmLfhMUYh2KRVLzwYfHcxjtejyX4swkpG82BX",
);

static readonly SOL_1 = new Account(
Currency.SOL,
"Solana 1",
Expand Down Expand Up @@ -128,12 +122,6 @@ export class Account {
"6TFDU3BYQ2FO32SOYQDTHDW5XKGEYH4FCT34ZQRHFPJRVMLEQWOO2OEUU4",
);

static readonly ALGO_3 = new Account(
Currency.ALGO,
"Algorand 3",
"3ASRTAN6KCZCICTIFQ5N2UBOSSBOZ7WFSOI2CJEJ4ESK532RODQZ7KCSOA",
);

static readonly XLM_1 = new Account(
Currency.XLM,
"Stellar 1",
Expand Down
5 changes: 0 additions & 5 deletions apps/ledger-live-desktop/tests/enum/Fee.ts

This file was deleted.

18 changes: 2 additions & 16 deletions apps/ledger-live-desktop/tests/models/Transaction.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import { Account } from "../enum/Account";
import { Token } from "../enum/Token";

export abstract class Transaction {
export class Transaction {
constructor(
public readonly accountToDebit: Account,
public readonly accountToCredit: Account,
public readonly recipient: string,
public readonly amount: string,
public readonly speed: string,
) {}
}
export class BasicTransaction extends Transaction {}
export class TokenTransaction extends Transaction {
constructor(
accountToDebit: Account,
public readonly accountToCredit1: Account,
public readonly accountToCredit2: Account,
amount: string,
speed: string,
public readonly token: Token,
) {
super(accountToDebit, accountToCredit1, amount, speed);
}
}
19 changes: 2 additions & 17 deletions apps/ledger-live-desktop/tests/page/account.page.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expect } from "@playwright/test";
import { step } from "tests/misc/reporters/step";
import { AppPage } from "tests/page/abstractClasses";
import { Token } from "tests/enum/Token";
import { Token } from "tests/enum/Tokens";

export class AccountPage extends AppPage {
readonly settingsButton = this.page.getByTestId("account-settings-button");
private settingsDeleteButton = this.page.getByTestId("account-settings-delete-button");
Expand Down Expand Up @@ -30,7 +31,6 @@ export class AccountPage extends AppPage {
this.page.getByRole("button", { name: `${accountName}` });
private tokenRow = (tokenTicker: string) => this.page.getByTestId(`token-row-${tokenTicker}`);
private addTokenButton = this.page.getByRole("button", { name: "Add token" });
private viewDetailsButton = this.page.getByText("View details");

@step("Navigate to token $0")
async navigateToToken(token: Token) {
Expand Down Expand Up @@ -69,16 +69,6 @@ export class AccountPage extends AppPage {
await this.stakeButton.click();
}

@step("Click on View Details button")
async navigateToViewDetails() {
await this.viewDetailsButton.click();
}

@step("Click on last operation")
async clickOnLastOperation() {
await this.operationRows.first().click();
}

async clickBannerCTA() {
await this.stakeBannerButton.scrollIntoViewIfNeeded();
await this.stakeBannerButton.click();
Expand Down Expand Up @@ -154,9 +144,4 @@ export class AccountPage extends AppPage {
expect(tokenInfos).toContain(token.tokenName);
expect(tokenInfos).toContain(token.tokenTicker);
}

@step("navigate to token in account")
async navigateToTokenInAccount(token: Token) {
await this.tokenRow(token.tokenTicker).click();
}
}
20 changes: 0 additions & 20 deletions apps/ledger-live-desktop/tests/page/drawer/drawer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Component } from "tests/page/abstractClasses";
import { expect } from "@playwright/test";
import { BasicTransaction } from "tests/models/Transaction";

export class Drawer extends Component {
readonly content = this.page.getByTestId("drawer-content");
Expand All @@ -9,10 +7,6 @@ export class Drawer extends Component {
private closeButton = this.page.getByTestId("drawer-close-button");
private currencyButton = (currency: string) =>
this.page.getByTestId(`currency-row-${currency.toLowerCase()}`).first();
private addressValue = (address: string) =>
this.page.locator('[data-test-id="drawer-content"]').locator(`text=${address}`);
private amountValue = (amount: string) =>
this.page.locator('[data-test-id="drawer-content"]').locator(`text=${amount}`);
readonly selectAssetTitle = this.page.getByTestId("select-asset-drawer-title").first();
readonly selectAccountTitle = this.page.getByTestId("select-account-drawer-title").first();
readonly swapAmountFrom = this.page.getByTestId("swap-amount-from").first();
Expand All @@ -25,20 +19,6 @@ export class Drawer extends Component {
await this.continueButton.click();
}

async adressValueIsVisible(address: string) {
await this.addressValue(address).waitFor({ state: "visible" });
}

async amoutValueIsVisible(amount: string) {
await this.amountValue(amount).waitFor({ state: "visible" });
}

async expectReceiverInfos(tx: BasicTransaction) {
await expect(this.addressValue(tx.accountToDebit.address)).toBeVisible();
await expect(this.addressValue(tx.accountToCredit.address)).toBeVisible();
await expect(this.amountValue(tx.amount)).toBeVisible();
}

async waitForDrawerToBeVisible() {
await this.content.waitFor({ state: "visible" });
await this.closeButton.waitFor({ state: "visible" });
Expand Down
2 changes: 0 additions & 2 deletions apps/ledger-live-desktop/tests/page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import { Modal } from "../component/modal.component";
import { ReceiveModal } from "../page/modal/receive.modal";
import { SpeculosPage } from "tests/page/speculos.page";
import { SendModal } from "tests/page/modal/send.modal";
import { Drawer } from "tests/page/drawer/drawer";

export class Application extends PageHolder {
public account = new AccountPage(this.page);
public drawer = new Drawer(this.page);
public accounts = new AccountsPage(this.page);
public portfolio = new PortfolioPage(this.page);
public addAccount = new AddAccountModal(this.page);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from "@playwright/test";
import { Modal } from "../../component/modal.component";
import { step } from "tests/misc/reporters/step";
import { Token } from "tests/enum/Token";
import { Token } from "tests/enum/Tokens";

export class AddAccountModal extends Modal {
private selectAccount = this.page.locator("text=Choose a crypto asset"); // FIXME: I need an id
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/page/modal/receive.modal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from "@playwright/test";
import { Modal } from "../../component/modal.component";
import { step } from "tests/misc/reporters/step";
import { Token } from "tests/enum/Token";
import { Token } from "tests/enum/Tokens";

export class ReceiveModal extends Modal {
private skipDeviceButton = this.page.getByTestId("receive-connect-device-skip-device-button");
Expand Down
67 changes: 15 additions & 52 deletions apps/ledger-live-desktop/tests/page/modal/send.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@ import { Transaction } from "../../models/Transaction";

export class SendModal extends Modal {
private drowdownAccount = this.page.locator('[data-test-id="modal-content"] svg').nth(1);
readonly recipientInput = this.page.locator('[id="send-recipient-input"]');
readonly continueButton = this.page.getByRole("button", { name: "continue" });
readonly recipientInput = this.page.getByPlaceholder("Enter");
private continueRecipientButton = this.page.getByRole("button", { name: "continue" });
private totalDebitValue = this.page.locator("text=Total to debit");
private checkDeviceLabel = this.page.locator(
"text=Double-check the transaction details on your Ledger device before signing.",
);
private checkTransactionbroadcastLabel = this.page.locator("text=Transaction sent");
private recipientAddressDisplayedValue = this.page.locator("data-test-id=recipient-address");
private amountDisplayedValue = this.page.locator("data-test-id=transaction-amount");
private ASAErrorMessage = this.page.getByText(
"Recipient account has not opted in the selected ASA.",
);
private invalidAddressErrorMessage = (network: string) =>
this.page.getByText(`This is not a valid ${network} address`);
private addressValue = (address: string) =>
this.page.getByTestId("modal-content").locator(`text=${address}`);
private amountValue = (amount: string, currency: string) =>
this.page.locator(`text=${amount} ${currency}`).first();
private recipientAddressDisplayedValue = this.page.getByTestId("recipient-address");
private amountDisplayedValue = this.page.getByTestId("transaction-amount");

async selectAccount(name: string) {
await this.drowdownAccount.click();
Expand All @@ -30,8 +29,8 @@ export class SendModal extends Modal {
}

@step("Click `Continue` button")
async clickContinueToDevice() {
await this.continueButton.click();
async clickContinue() {
await this.continueRecipientButton.click();
await expect(this.checkDeviceLabel).toBeVisible();
}

Expand All @@ -43,18 +42,20 @@ export class SendModal extends Modal {

@step("Fill tx information")
async fillTxInfo(tx: Transaction) {
await this.fillRecipient(tx.accountToCredit.address);
await this.continueButton.click();
await this.fillRecipient(tx.recipient);
await this.continueRecipientButton.click();
await this.cryptoAmountField.fill(tx.amount);
await this.countinueSendAmount();
}

@step("Verify tx information before confirming")
async expectTxInfoValidity(tx: Transaction) {
await expect(this.totalDebitValue).toBeVisible();
await expect(this.addressValue(tx.recipient)).toBeVisible();
const displayedReceiveAddress = await this.recipientAddressDisplayedValue.innerText();
expect(displayedReceiveAddress).toEqual(tx.accountToCredit.address);
expect(displayedReceiveAddress).toEqual(tx.recipient);

await expect(this.amountValue(tx.amount, tx.accountToDebit.currency.uiLabel)).toBeVisible();
const displayedAmount = await this.amountDisplayedValue.innerText();
expect(displayedAmount).toEqual(expect.stringContaining(tx.amount));
}
Expand All @@ -63,42 +64,4 @@ export class SendModal extends Modal {
async expectTxSent() {
await expect(this.checkTransactionbroadcastLabel).toBeVisible();
}

@step("Check continue button disable and ASA error message visible")
async checkASAError() {
await expect(this.continueButton).toBeDisabled();
await expect(this.ASAErrorMessage).toBeVisible();
}

@step("Check invalid address error message")
async checkInvalidAddressError(tx: Transaction) {
await expect(this.continueButton).toBeDisabled();
await expect(
this.invalidAddressErrorMessage(tx.accountToDebit.currency.deviceLabel),
).toBeVisible();
}

@step("Check continue button enable")
async checkContinueButtonEnable() {
await expect(this.continueButton).toBeEnabled();
}

@step("Fill amount")
async fillAmount(tx: Transaction) {
if (tx.amount == "send max") {
await this.toggleMaxAmount();
} else {
await this.cryptoAmountField.fill(tx.amount);
}
}

@step("Click `Continue` button")
async clickContinue() {
await this.continueButton.click();
}

@step("Check continue button disabled")
async checkContinueButtonDisabled() {
await expect(this.continueButton).toBeDisabled();
}
}
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/page/speculos.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class SpeculosPage extends AppPage {
const amountScreen = await pressRightUntil(DeviceLabels.AMOUT);
expect(verifyAmount(tx.amount, amountScreen)).toBe(true);
const addressScreen = await pressRightUntil(DeviceLabels.ADDRESS);
expect(assertAddressesEquality(tx.accountToCredit.address, addressScreen)).toBe(true);
expect(assertAddressesEquality(tx.recipient, addressScreen)).toBe(true);
await pressRightUntil(tx.accountToDebit.currency.sendPattern[2]);
await pressBoth();
if (tx.accountToDebit.currency.uiName === Currency.tBTC.uiName) {
Expand Down
Loading

0 comments on commit efe88bf

Please sign in to comment.