Skip to content

Commit

Permalink
[QAA-271] - ✅ Adding delegate e2e test - different entry points (#8116)
Browse files Browse the repository at this point in the history
test: ✅ Adding E2E test scenario for delegate - different entry points to access staking flow
  • Loading branch information
VicAlbr authored Oct 16, 2024
1 parent 2be1902 commit d47dea8
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 1 deletion.
24 changes: 24 additions & 0 deletions apps/ledger-live-desktop/tests/page/drawer/asset.drawer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { step } from "tests/misc/reporters/step";
import { Drawer } from "tests/component/drawer.component";
import { Currency } from "tests/enum/Currency";
import { Account } from "tests/enum/Account";

export class AssetDrawer extends Drawer {
private assetInput = this.page.getByTestId("select-asset-drawer-search-input");
private currencyRow = (currencyName: string) =>
this.page.getByTestId(`currency-row-${currencyName}`);
private accountRow = (accountName: string, accountIndex?: number) =>
this.page.getByTestId(`account-row-${accountName}-${accountIndex}`);

@step("Select asset")
async selectAsset(asset: Currency) {
await this.assetInput.click();
await this.assetInput.fill(asset.name);
await this.currencyRow(asset.name.toLowerCase()).click();
}

@step("Select account")
async selectAccountByIndex(account: Account) {
await this.accountRow(account.currency.name.toLowerCase(), account.index).click();
}
}
4 changes: 4 additions & 0 deletions apps/ledger-live-desktop/tests/page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PageHolder } from "tests/page/abstractClasses";
import { AccountPage } from "../page/account.page";
import { AccountsPage } from "../page/accounts.page";
import { PortfolioPage } from "../page/portfolio.page";
import { MarketPage } from "../page/market.page";
import { AddAccountModal } from "../page/modal/add.account.modal";
import { Layout } from "tests/component/layout.component";
import { Modal } from "../component/modal.component";
Expand All @@ -16,12 +17,14 @@ import { SwapConfirmationDrawer } from "tests/page/drawer/swap.confirmation.draw
import { delegateModal } from "tests/page/modal/delegate.modal";
import { DelegateDrawer } from "./drawer/delegate.drawer";
import { SendDrawer } from "./drawer/send.drawer";
import { AssetDrawer } from "./drawer/asset.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 market = new MarketPage(this.page);
public addAccount = new AddAccountModal(this.page);
public layout = new Layout(this.page);
public modal = new Modal(this.page);
Expand All @@ -35,4 +38,5 @@ export class Application extends PageHolder {
public swapDrawer = new SwapConfirmationDrawer(this.page);
public delegateDrawer = new DelegateDrawer(this.page);
public sendDrawer = new SendDrawer(this.page);
public assetDrawer = new AssetDrawer(this.page);
}
17 changes: 17 additions & 0 deletions apps/ledger-live-desktop/tests/page/market.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AppPage } from "tests/page/abstractClasses";
import { step } from "tests/misc/reporters/step";

export class MarketPage extends AppPage {
private searchInput = this.page.getByTestId("market-search-input");
Expand All @@ -13,60 +14,76 @@ export class MarketPage extends AppPage {
readonly swapButton = (ticker: string) => this.page.getByTestId(`market-${ticker}-swap-button`);
private stakeButton = (ticker: string) => this.page.getByTestId(`market-${ticker}-stake-button`);

@step("Search for $0")
async search(query: string) {
await this.searchInput.fill(query);
}

@step("Switch counter value for $0")
async switchCountervalue(_ticker: string) {
await this.counterValueSelect.click();
// TODO: For some reason need to hack selects like that
await this.page.click('#react-select-2-listbox div div:has-text("Thai Baht - THB")');
}

@step("Switch market range for $0")
async switchMarketRange(range: string) {
await this.marketRangeSelect.click();
// TODO: For some reason need to hack selects like that
await this.page.click(`text=${range}`);
}

@step("Toggle star filter")
async toggleStarFilter() {
await this.starFilterButton.click();
}

@step("Open coin page for $0")
async openCoinPage(ticker: string) {
await this.coinRow(ticker).click();
await this.coinPageContainer.waitFor({ state: "attached" });
await this.loadingPlaceholder.first().waitFor({ state: "detached" });
}

@step("Star $0")
async starCoin(ticker: string) {
await this.starButton(ticker).click();
}

@step("Open buy page for $0")
async openBuyPage(ticker: string) {
await this.buyButton(ticker).click();
// FIXME windows seems to be choking on the transition taking longer.
await new Promise(resolve => setTimeout(resolve, 1000));
}

@step("Wait for loading")
async waitForLoading() {
await this.loadingPlaceholder.first().waitFor({ state: "detached" });
}

@step("Wait for loading with swap buttons")
async waitForLoadingWithSwapbtn() {
await this.loadingPlaceholder.first().waitFor({ state: "detached" });
await this.swapButton("btc").waitFor({ state: "attached" }); // swap buttons are displayed few seconds after
}

@step("Wait for search bar to be empty")
async waitForSearchBarToBeEmpty() {
await this.page.waitForFunction(async () => {
return (await this.searchInput?.inputValue()) === "";
});
}

@step("Start stake flow for $0")
async startStakeFlowByTicker(ticker: string) {
await this.stakeButton(ticker).click();
await this.page.getByText("choose account").waitFor({ state: "visible" });
await this.page.getByText("Add account").waitFor({ state: "visible" });
}

@step("Click on stake button for $0")
async stakeButtonClick(ticker: string) {
await this.stakeButton(ticker.toLowerCase()).click();
}
}
55 changes: 54 additions & 1 deletion apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getDescription } from "../../utils/customJsonReporter";
const e2eDelegationAccounts = [
{
delegate: new Delegate(Account.ATOM_1, "0.001", "Ledger"),
xrayTicket: "B2CQA-2740",
xrayTicket: "B2CQA-2740, B2CQA-2770",
},
{
delegate: new Delegate(Account.SOL_1, "0.001", "Ledger by Figment"),
Expand Down Expand Up @@ -127,3 +127,56 @@ for (const validator of validators) {
);
});
}

test.describe("Staking flow from different entry point", () => {
const delegateAccount = new Delegate(Account.ATOM_1, "0.001", "Ledger");
test.use({
userdata: "skip-onboarding",
speculosApp: delegateAccount.account.currency.speculosApp,
cliCommands: [
`liveData --currency ${delegateAccount.account.currency.ticker} --index ${delegateAccount.account.index} --add`,
],
});

test(
"Staking flow from portfolio entry point",
{
annotation: {
type: "TMS",
description: "B2CQA-2769",
},
},
async ({ app }) => {
await addTmsLink(getDescription(test.info().annotations).split(", "));
await app.layout.goToPortfolio();
await app.portfolio.startStakeFlow();

await app.assetDrawer.selectAsset(delegateAccount.account.currency);
await app.assetDrawer.selectAccountByIndex(delegateAccount.account);

await app.delegate.verifyProvider(delegateAccount.provider);
await app.delegate.continueDelegate();
},
);

test(
"Staking flow from market entry point",
{
annotation: {
type: "TMS",
description: "B2CQA-2771",
},
},
async ({ app }) => {
await addTmsLink(getDescription(test.info().annotations).split(", "));
await app.layout.goToMarket();
await app.market.search(delegateAccount.account.currency.name);
await app.market.stakeButtonClick(delegateAccount.account.currency.ticker);

await app.assetDrawer.selectAccountByIndex(delegateAccount.account);

await app.delegate.verifyProvider(delegateAccount.provider);
await app.delegate.continueDelegate();
},
);
});

0 comments on commit d47dea8

Please sign in to comment.