Skip to content

Commit

Permalink
[QAA-261] Adding E2E delegation scenario for LLD (NEAR, SOLANA, COSMO…
Browse files Browse the repository at this point in the history
…S) (#8033)

* test: ✅ Adding delegate E2E test scenario

* style: 🚚 Rename variable + answer PR coms

* test: ♻️ Refacto modal and drawer components for e2e tests
  • Loading branch information
VicAlbr authored Oct 10, 2024
1 parent b961229 commit c0e9ac0
Show file tree
Hide file tree
Showing 26 changed files with 277 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ const OperationD = (props: Props) => {
color="palette.text.shade60"
mt={0}
mb={1}
data-testid="transaction-type"
>
<Trans i18nKey={`operation.type.${editable ? "SENDING" : operation.type}`} />
</Text>
Expand Down Expand Up @@ -492,7 +493,13 @@ const OperationD = (props: Props) => {
/>
</Box>
) : undefined}
<Text ff="Inter|SemiBold" textAlign="center" fontSize={4} color="palette.text.shade60">
<Text
data-testid="operation-type"
ff="Inter|SemiBold"
textAlign="center"
fontSize={4}
color="palette.text.shade60"
>
<Trans i18nKey={`operation.type.${operation.type}`} />
</Text>
</OpDetailsData>
Expand Down
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 { Transaction } from "tests/models/Transaction";
import { step } from "tests/misc/reporters/step";

export class Drawer extends Component {
Expand All @@ -10,9 +8,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-testid="drawer-content"]').locator(`text=${address}`);
private amountValue = this.page.getByTestId("amountReceived-drawer");
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,17 +20,6 @@ export class Drawer extends Component {
await this.continueButton.click();
}

@step("Verify address is visible")
async addressValueIsVisible(address: string) {
await this.addressValue(address).waitFor({ state: "visible" });
}

@step("Verify that the information of the transaction is visible")
async expectReceiverInfos(tx: Transaction) {
await expect(this.addressValue(tx.accountToCredit.address)).toBeVisible();
await expect(this.amountValue).toBeVisible();
}

async waitForDrawerToBeVisible() {
await this.content.waitFor({ state: "visible" });
await this.closeButton.waitFor({ state: "visible" });
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class Account {
static readonly BTC_NATIVE_SEGWIT_1 = new Account(
Currency.BTC,
"Bitcoin 1",
"bc1qx7f9plgr8msjatkv0dw2ne8gguwfjqr6xyjp50",
"bc1qm6tw2c0u842qjs7g2n2c7ulh76f6xn4sk0dsyt",
);

static readonly BTC_NATIVE_SEGWIT_2 = new Account(
Expand Down
57 changes: 37 additions & 20 deletions apps/ledger-live-desktop/tests/enum/AppInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export class AppInfos {
public readonly name: string,
public readonly sendPattern?: DeviceLabels[],
public readonly receivePattern?: DeviceLabels[],
public readonly lsPattern?: DeviceLabels[],
public readonly delegatePattern?: DeviceLabels[],
) {}
static readonly BITCOIN = new AppInfos(
"Bitcoin",
[
DeviceLabels.AMOUT,
DeviceLabels.AMOUNT,
DeviceLabels.ADDRESS,
DeviceLabels.CONTINUE,
DeviceLabels.REJECT,
Expand All @@ -21,7 +21,7 @@ export class AppInfos {
static readonly BITCOIN_TESTNET = new AppInfos(
"Bitcoin Test",
[
DeviceLabels.AMOUT,
DeviceLabels.AMOUNT,
DeviceLabels.ADDRESS,
DeviceLabels.CONTINUE,
DeviceLabels.REJECT,
Expand All @@ -31,47 +31,48 @@ export class AppInfos {
);
static readonly DOGECOIN = new AppInfos(
"Dogecoin",
[DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly ETHEREUM = new AppInfos(
"Ethereum",
[DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly ETHEREUM_HOLESKY = new AppInfos(
"Ethereum Holesky",
[DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly ETHEREUM_SEPOLIA = new AppInfos(
"Ethereum Sepolia",
[DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly ETHEREUM_CLASSIC = new AppInfos(
"Ethereum Classic",
[DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly SOLANA = new AppInfos(
"Solana",
[DeviceLabels.TRANSFER, DeviceLabels.RECIPIENT, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.PUBKEY, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.DELEGATE_FROM, DeviceLabels.DEPOSIT, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly POLKADOT = new AppInfos(
"Polkadot",
[DeviceLabels.DEST, DeviceLabels.AMOUT, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[DeviceLabels.DEST, DeviceLabels.AMOUNT, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
);
static readonly TRON = new AppInfos(
"Tron",
[DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.SIGN, DeviceLabels.CANCEL],
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.SIGN, DeviceLabels.CANCEL],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.CANCEL],
);
static readonly RIPPLE = new AppInfos(
"Ripple",
[DeviceLabels.AMOUT, DeviceLabels.DESTINATION, DeviceLabels.SIGN, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.DESTINATION, DeviceLabels.SIGN, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly CARDANO = new AppInfos(
Expand All @@ -86,13 +87,13 @@ export class AppInfos {
);
static readonly BITCOIN_CASH = new AppInfos(
"Bitcoin Cash",
[DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly ALGORAND = new AppInfos(
"Algorand",
[
DeviceLabels.AMOUT,
DeviceLabels.AMOUNT,
DeviceLabels.RECEIVER,
DeviceLabels.CAPS_APPROVE,
DeviceLabels.CAPS_REJECT,
Expand All @@ -101,35 +102,51 @@ export class AppInfos {
);
static readonly COSMOS = new AppInfos(
"Cosmos",
[DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[
DeviceLabels.PLEASE_REVIEW,
DeviceLabels.AMOUNT,
DeviceLabels.CAPS_APPROVE,
DeviceLabels.CAPS_REJECT,
],
);
static readonly TEZOS = new AppInfos(
"Tezos",
[DeviceLabels.AMOUT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly POLYGON = new AppInfos(
"Polygon",
[DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly BINANCE_SMART_CHAIN = new AppInfos(
"Binance Smart Chain",
[DeviceLabels.AMOUT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly TON = new AppInfos(
"Ton",
[DeviceLabels.AMOUT, DeviceLabels.TO, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
static readonly NEAR = new AppInfos(
"Near",
[DeviceLabels.AMOUT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.AMOUNT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.WALLET_ID, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[
DeviceLabels.VIEW_HEADER,
DeviceLabels.RECEIVER,
DeviceLabels.CONTINUE_TO_ACTION,
DeviceLabels.VIEW_ACTION,
DeviceLabels.METHOD_NAME,
DeviceLabels.DEPOSIT,
DeviceLabels.REJECT,
DeviceLabels.SIGN,
],
);
static readonly LS = new AppInfos("LedgerSync", [DeviceLabels.LOGIN_LEDGER_SYNC]);
static readonly LS = new AppInfos("LedgerSync");
static readonly EXCHANGE = new AppInfos("Exchange", [
DeviceLabels.SEND,
DeviceLabels.GET,
Expand Down
10 changes: 8 additions & 2 deletions apps/ledger-live-desktop/tests/enum/DeviceLabels.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export enum DeviceLabels {
CONTINUE = "Continue",
AMOUT = "Amount",
AMOUNT = "Amount",
ADDRESS = "Address",
REJECT = "Reject",
SIGN = "Sign",
Expand All @@ -23,9 +23,15 @@ export enum DeviceLabels {
TRANSACTION_FEE = "Transaction fee",
FINALIZE = "Finalize",
RECEIVER = "Receiver",
LOGIN_LEDGER_SYNC = "Log in to Ledger Sync",
GET = "Get",
FEES = "Fees",
ACCEPT_AND_SEND = "Accept and send",
WALLET_ID = "Wallet ID",
VIEW_HEADER = "View Header",
CONTINUE_TO_ACTION = "Continue to action",
VIEW_ACTION = "View action",
METHOD_NAME = "Method name",
DEPOSIT = "Deposit",
DELEGATE_FROM = "Delegate from",
PLEASE_REVIEW = "Please review",
}
9 changes: 9 additions & 0 deletions apps/ledger-live-desktop/tests/models/Delegate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Account } from "../enum/Account";

export class Delegate {
constructor(
public account: Account,
public amount: string,
public provider: string,
) {}
}
50 changes: 50 additions & 0 deletions apps/ledger-live-desktop/tests/page/drawer/delegate.drawer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { step } from "tests/misc/reporters/step";
import { Drawer } from "tests/component/drawer.component";
import { Currency } from "tests/enum/Currency";
import { Delegate } from "tests/models/Delegate";
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";

export class DelegateDrawer extends Drawer {
private provider = (provider: string) =>
this.page.getByTestId("drawer-content").locator(`text=${provider}`);
private amountValue = this.page.getByTestId("amountReceived-drawer");
private transactionType = this.page.getByTestId("transaction-type");
private addressValue = (address: string) =>
this.page.locator('[data-testid="drawer-content"]').locator(`text=${address}`);

@step("Verify address $0 is visible")
async addressValueIsVisible(address: string) {
await expect(this.addressValue(address)).toBeVisible();
}

@step("Verify provider is visible")
async providerIsVisible(account: Delegate) {
if (account.account.currency === Currency.ATOM) {
await expect(this.provider(account.provider)).toBeVisible();
}
}

@step("Verify amount is visible")
async amountValueIsVisible() {
await expect(this.amountValue).toBeVisible();
}

@step("Verify transaction type is correct")
async transactionTypeIsVisible() {
await expect(this.transactionType).toBeVisible();
}

@step("Verify that the information of the transaction is visible")
async expectReceiverInfos(tx: Transaction) {
await expect(this.addressValue(tx.accountToCredit.address)).toBeVisible();
await expect(this.amountValue).toBeVisible();
}

@step("Verify that the information of the delegation is visible")
async expectDelegationInfos(delegationInfo: Delegate) {
await this.providerIsVisible(delegationInfo);
await this.amountValueIsVisible();
await this.transactionTypeIsVisible();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { step } from "tests/misc/reporters/step";
import { expect } from "@playwright/test";
import { Drawer } from "./drawer";
import { Drawer } from "../../component/drawer.component";
import { extractNumberFromText } from "tests/utils/textParserUtils";

export class LedgerSyncDrawer extends Drawer {
Expand Down
21 changes: 21 additions & 0 deletions apps/ledger-live-desktop/tests/page/drawer/send.drawer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { step } from "tests/misc/reporters/step";
import { Drawer } from "tests/component/drawer.component";
import { expect } from "@playwright/test";
import { Transaction } from "tests/models/Transaction";

export class SendDrawer extends Drawer {
private addressValue = (address: string) =>
this.page.locator('[data-testid="drawer-content"]').locator(`text=${address}`);
private amountValue = this.page.getByTestId("amountReceived-drawer");

@step("Verify address is visible")
async addressValueIsVisible(address: string) {
await expect(this.addressValue(address)).toBeVisible();
}

@step("Verify that the information of the transaction is visible")
async expectReceiverInfos(tx: Transaction) {
await expect(this.addressValue(tx.accountToCredit.address)).toBeVisible();
await expect(this.amountValue).toBeVisible();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { expect } from "@playwright/test";
import { step } from "tests/misc/reporters/step";
import { Drawer } from "tests/page/drawer/drawer";
import { Drawer } from "tests/component/drawer.component";
import { capitalizeFirstLetter } from "tests/utils/textParserUtils";

export class SwapConfirmationDrawer extends Drawer {
private amountSent = this.page.getByTestId("amountSent");
private amountReceived = this.page.getByTestId("amountReceived");
private provider = this.page.getByTestId("provider");
private swapProvider = this.page.getByTestId("provider");
private fees = this.page.getByTestId("fees");
private sourceAccount = this.page.getByTestId("sourceAccount");
private targetAccount = this.page.getByTestId("targetAccount");
Expand All @@ -24,7 +24,7 @@ export class SwapConfirmationDrawer extends Drawer {

@step("Verify provider: $0")
async verifyProvider(provider: string) {
await expect(this.provider).toHaveText(capitalizeFirstLetter(provider));
await expect(this.swapProvider).toHaveText(capitalizeFirstLetter(provider));
}

@step("Verify source currency: $0")
Expand Down
6 changes: 5 additions & 1 deletion apps/ledger-live-desktop/tests/page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ 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";
import { Drawer } from "tests/component/drawer.component";
import { SettingsPage } from "tests/page/settings.page";
import { LedgerSyncDrawer } from "./drawer/ledger.sync.drawer";
import { SwapPage } from "tests/page/swap.page";
import { SwapConfirmationDrawer } from "tests/page/drawer/swap.confirmation.drawer";
import { delegateModal } from "tests/page/modal/delegate.modal";
import { DelegateDrawer } from "./drawer/delegate.drawer";
import { SendDrawer } from "./drawer/send.drawer";

export class Application extends PageHolder {
public account = new AccountPage(this.page);
Expand All @@ -31,4 +33,6 @@ export class Application extends PageHolder {
public ledgerSync = new LedgerSyncDrawer(this.page);
public swap = new SwapPage(this.page);
public swapDrawer = new SwapConfirmationDrawer(this.page);
public delegateDrawer = new DelegateDrawer(this.page);
public sendDrawer = new SendDrawer(this.page);
}
Loading

0 comments on commit c0e9ac0

Please sign in to comment.