From 7e1e810a95475c12a44a3cb5941e09918865500f 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/page/drawer/operation.drawer.ts | 39 +++++++++++++++++++ apps/ledger-live-desktop/tests/page/index.ts | 2 + .../tests/specs/speculos/add.account.spec.ts | 8 +++- 4 files changed, 54 insertions(+), 4 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/page/drawer/operation.drawer.ts b/apps/ledger-live-desktop/tests/page/drawer/operation.drawer.ts new file mode 100644 index 000000000000..ae10265466c8 --- /dev/null +++ b/apps/ledger-live-desktop/tests/page/drawer/operation.drawer.ts @@ -0,0 +1,39 @@ +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 drawer = this.page.getByTestId("drawer-content"); + 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 drawerCloseButton = this.page.getByTestId("drawer-close-button"); + readonly accountName = this.page.getByTestId("account-name"); + + @step("Verify drawer information") + async expectDrawerInfos(accountName: string) { + await expect(this.drawer).toBeVisible(); + const transactionType = await this.transactionType.textContent(); + await expect(this.transactionType).toBeVisible(); + 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}$/); + } + } + + @step("Close drawer") + async closeDrawer() { + await this.drawerCloseButton.click(); + } +} 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/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(); },