From bab357a71507b9bb25ac0052b9570ea8d4772a18 Mon Sep 17 00:00:00 2001 From: Victor Alber Date: Tue, 14 Jan 2025 15:14:32 +0100 Subject: [PATCH] test: Adding checks - add Account - B2CQA-2073 --- .../drawers/OperationDetails/index.tsx | 9 +++-- .../tests/component/drawer.component.ts | 2 +- .../tests/page/drawer/operation.drawer.ts | 34 +++++++++++++++++++ apps/ledger-live-desktop/tests/page/index.ts | 2 ++ .../specs/services/ethereumStaking.spec.ts | 4 +-- .../tests/specs/speculos/add.account.spec.ts | 8 ++++- .../tests/specs/speculos/delegate.spec.ts | 2 +- .../tests/specs/speculos/ledgerSync.spec.ts | 2 +- .../tests/specs/speculos/nft.spec.ts | 2 +- .../tests/specs/speculos/send.tx.spec.ts | 2 +- 10 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 apps/ledger-live-desktop/tests/page/drawer/operation.drawer.ts diff --git a/apps/ledger-live-desktop/src/renderer/drawers/OperationDetails/index.tsx b/apps/ledger-live-desktop/src/renderer/drawers/OperationDetails/index.tsx index 871a57de4a4e..c0122406e597 100644 --- a/apps/ledger-live-desktop/src/renderer/drawers/OperationDetails/index.tsx +++ b/apps/ledger-live-desktop/src/renderer/drawers/OperationDetails/index.tsx @@ -424,6 +424,7 @@ const OperationD = (props: Props) => { {hasFailed ? null : ( { - {name} + + {name} + @@ -640,13 +643,13 @@ const OperationD = (props: Props) => { {isNftOperation ? : null} {t("operationDetails.date")} - {dateFormatted} + {dateFormatted} {t("operationDetails.identifier")} - + diff --git a/apps/ledger-live-desktop/tests/component/drawer.component.ts b/apps/ledger-live-desktop/tests/component/drawer.component.ts index 8a2d0c4eadbd..982671833f54 100644 --- a/apps/ledger-live-desktop/tests/component/drawer.component.ts +++ b/apps/ledger-live-desktop/tests/component/drawer.component.ts @@ -35,7 +35,7 @@ export class Drawer extends Component { } @step("Close drawer") - async close() { + async closeDrawer() { await this.closeButton.click(); } diff --git a/apps/ledger-live-desktop/tests/page/drawer/operation.drawer.ts b/apps/ledger-live-desktop/tests/page/drawer/operation.drawer.ts new file mode 100644 index 000000000000..ec09ac139435 --- /dev/null +++ b/apps/ledger-live-desktop/tests/page/drawer/operation.drawer.ts @@ -0,0 +1,34 @@ +import { step } from "tests/misc/reporters/step"; +import { Drawer } from "tests/component/drawer.component"; +import { expect } from "@playwright/test"; + +export class OperationDrawer extends Drawer { + readonly transactionIdLabel = this.page.getByText("Transaction ID"); + readonly transactionIdValue = this.page.getByTestId("operation-id"); + readonly dateLabel = this.page.getByText("Date"); + readonly dateValue = this.page.getByTestId("operation-date"); + readonly amountLabel = this.page.getByText("Amount", { exact: true }); + readonly amountValue = this.page.getByTestId("operation-amount"); + readonly transactionType = this.page.getByTestId("transaction-type"); + readonly accountName = this.page.getByTestId("account-name"); + + @step("Verify drawer information") + async expectDrawerInfos(accountName: string) { + await this.waitForDrawerToBeVisible(); + const transactionType = await this.transactionType.textContent(); + await expect(this.accountName).toHaveText(accountName); + await expect(this.dateLabel).toBeVisible(); + expect(await this.dateValue.textContent()).toMatch( + /^\d{1,2}\/\d{1,2}\/\d{4}, \d{1,2}:\d{2} (AM|PM)$/, + ); + await expect(this.transactionIdLabel).toBeVisible(); + expect(await this.transactionIdValue.textContent()).toMatch(/^[a-zA-Z0-9+/=]{40,}$/); + if (transactionType !== "NFT Received") { + await expect(this.amountLabel).toBeVisible(); + expect(await this.amountValue.textContent()).toMatch(/^[+-]?\$\d+\.\d{2}$/); + } else { + await expect(this.amountLabel).not.toBeVisible(); + expect(this.amountValue).not.toBeVisible(); + } + } +} diff --git a/apps/ledger-live-desktop/tests/page/index.ts b/apps/ledger-live-desktop/tests/page/index.ts index 168f84e88f27..405e77a2a990 100644 --- a/apps/ledger-live-desktop/tests/page/index.ts +++ b/apps/ledger-live-desktop/tests/page/index.ts @@ -25,6 +25,7 @@ import { NftGallery } from "./nftGallery.page"; import { AssetPage } from "./asset.page"; import { SettingsModal } from "tests/page/modal/settings.modal"; import { OnboardingPage } from "tests/page/onboarding.page"; +import { OperationDrawer } from "./drawer/operation.drawer"; export class Application extends PageHolder { public account = new AccountPage(this.page); @@ -53,4 +54,5 @@ export class Application extends PageHolder { public assetPage = new AssetPage(this.page); public settingsModal = new SettingsModal(this.page); public onboarding = new OnboardingPage(this.page); + public operationDrawer = new OperationDrawer(this.page); } diff --git a/apps/ledger-live-desktop/tests/specs/services/ethereumStaking.spec.ts b/apps/ledger-live-desktop/tests/specs/services/ethereumStaking.spec.ts index 08e5c737dd94..c60a3b8df70e 100644 --- a/apps/ledger-live-desktop/tests/specs/services/ethereumStaking.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/services/ethereumStaking.spec.ts @@ -151,7 +151,7 @@ test("Ethereum staking flows via portfolio, asset page and market page @smoke", await assetPage.startStakeFlow(); await drawer.waitForDrawerToBeVisible(); await expect.soft(page).toHaveScreenshot("stake-drawer-opened-from-asset-page.png"); - await drawer.close(); + await drawer.closeDrawer(); }); await test.step("start stake flow via Account page", async () => { @@ -181,7 +181,7 @@ test("Ethereum staking flows via portfolio, asset page and market page @smoke", await expect .soft(page) .toHaveScreenshot("stake-drawer-opened-from-market-page.png", maskPartOfItemsInMarket); - await drawer.close(); + await drawer.closeDrawer(); }); await test.step("Go back to Market page and start stake from ETH coin detail page", async () => { diff --git a/apps/ledger-live-desktop/tests/specs/speculos/add.account.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/add.account.spec.ts index fc286dd85e6e..7c441e237f5e 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/add.account.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/add.account.spec.ts @@ -4,7 +4,10 @@ import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; const currencies = [ - { currency: Currency.BTC, xrayTicket: "B2CQA-2499, B2CQA-2644, B2CQA-2672, B2CQA-786" }, + { + currency: Currency.BTC, + xrayTicket: "B2CQA-2499, B2CQA-2644, B2CQA-2672, B2CQA-786, B2CQA-2073", + }, { currency: Currency.ETH, xrayTicket: "B2CQA-2503, B2CQA-929, B2CQA-2645, B2CQA-2673" }, { currency: Currency.ETC, xrayTicket: "B2CQA-2502, B2CQA-2646, B2CQA-2674" }, { currency: Currency.XRP, xrayTicket: "B2CQA-2505, B2CQA-2647, B2CQA-2675" }, @@ -53,6 +56,9 @@ for (const currency of currencies) { await app.account.expectAccountVisibility(firstAccountName); await app.account.expectAccountBalance(); await app.account.expectLastOperationsVisibility(); + await app.account.clickOnLastOperation(); + await app.operationDrawer.expectDrawerInfos(firstAccountName); + await app.operationDrawer.closeDrawer(); await app.account.expectAddressIndex(0); await app.account.expectShowMoreButton(); }, diff --git a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts index 864784d870ec..ce24bf407fbc 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts @@ -105,7 +105,7 @@ test.describe("Delegate flows", () => { await app.delegateDrawer.transactionTypeIsVisible(); await app.delegateDrawer.providerIsVisible(account.delegate); await app.delegateDrawer.amountValueIsVisible(); - await app.drawer.close(); + await app.drawer.closeDrawer(); if (!getEnv("DISABLE_TRANSACTION_BROADCAST")) { await app.layout.syncAccounts(); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/ledgerSync.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/ledgerSync.spec.ts index 396fac0565cc..112ef30dc16b 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/ledgerSync.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/ledgerSync.spec.ts @@ -96,7 +96,7 @@ test.describe(`[${app.name}] Sync Accounts`, () => { await app.settings.openManageLedgerSync(); await app.ledgerSync.destroyTrustchain(); await app.ledgerSync.expectBackupDeletion(); - await app.drawer.close(); + await app.drawer.closeDrawer(); }, ); }); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts index c92f2b46e1d1..d70af1c4646d 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/nft.spec.ts @@ -51,7 +51,7 @@ test.describe("send NFT to ENS address", () => { await app.speculos.signSendNFTTransaction(transaction); await app.send.expectTxSent(); await app.account.navigateToViewDetails(); - await app.drawer.close(); + await app.drawer.closeDrawer(); await app.layout.goToAccounts(); await app.accounts.navigateToAccountByName(transaction.accountToDebit.accountName); await app.account.navigateToNFTOperation(); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts index 3aa124788e6c..68073f397606 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts @@ -276,7 +276,7 @@ test.describe("Send flows", () => { await app.sendDrawer.addressValueIsVisible( transaction.transaction.accountToCredit.address, ); - await app.drawer.close(); + await app.drawer.closeDrawer(); if (!getEnv("DISABLE_TRANSACTION_BROADCAST")) { await app.layout.goToAccounts(); await app.accounts.clickSyncBtnForAccount(