From a6c4184aaaa5e7d14e82427d1f572a10ad06c6ba Mon Sep 17 00:00:00 2001 From: Abdurrahman SASTIM Date: Thu, 5 Dec 2024 14:41:06 +0100 Subject: [PATCH] chore: review comments --- .../tests/page/modal/delegate.modal.ts | 19 +++++++++++++------ .../tests/specs/speculos/delegate.spec.ts | 17 +++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/apps/ledger-live-desktop/tests/page/modal/delegate.modal.ts b/apps/ledger-live-desktop/tests/page/modal/delegate.modal.ts index 4abe40d2b8fe..3fd06964e7e9 100644 --- a/apps/ledger-live-desktop/tests/page/modal/delegate.modal.ts +++ b/apps/ledger-live-desktop/tests/page/modal/delegate.modal.ts @@ -4,7 +4,6 @@ import { step } from "tests/misc/reporters/step"; export class delegateModal extends Modal { private titleProvider = this.page.getByTestId("modal-provider-title"); - private sideInfoProvider = this.page.getByTestId("modal-provider-side-info"); private delegateContinueButton = this.page.getByText("Continue"); private rowProvider = this.page.getByTestId("modal-provider-row"); private searchOpenButton = this.page.getByText("Show all"); @@ -18,20 +17,28 @@ export class delegateModal extends Modal { private checkIcon = this.page.getByTestId("check-icon"); @step("Get title provider on row $0") - async getTitleProvider(row: number) { + async getTitleProvider(row: number): Promise { await this.titleProvider.nth(row - 1).waitFor(); - return await this.titleProvider.nth(row - 1).textContent(); + const titleProvider = await this.titleProvider.nth(row - 1).textContent(); + expect(titleProvider).not.toBeNull(); + return titleProvider!; } - @step("Verify first provider name") + @step("Verify first provider name is $0") async verifyFirstProviderName(provider: string) { const providerName = await this.getTitleProvider(1); expect(providerName).toBe(provider); } @step("Select provider on row $0") - async selectProvider(row: number) { - this.rowProvider.nth(row - 1).click(); + async selectProviderOnRow(row: number) { + await this.selectProviderByName(await this.getTitleProvider(row)); + } + + @step("Select provider $0") + async selectProviderByName(name: string) { + const providerRow = this.rowProvider.filter({ hasText: name }).first(); + await providerRow.click({ position: { x: 10, y: 10 } }); // Prevent click on the title as it is a redirection await this.verifyContinueEnabled(); } 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 ce3eb5de1e65..215394feb876 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/delegate.spec.ts @@ -5,6 +5,7 @@ import { addTmsLink } from "tests/utils/allureUtils"; import { getDescription } from "../../utils/customJsonReporter"; import { commandCLI } from "tests/utils/cliUtils"; import { isRunningInScheduledWorkflow } from "tests/utils/githubUtils"; +import { Currency } from "@ledgerhq/live-common/e2e/enum/Currency"; const e2eDelegationAccounts = [ { @@ -86,9 +87,9 @@ test.describe("Delegate flows", () => { await app.account.clickBannerCTA(); await app.delegate.verifyFirstProviderName(account.delegate.provider); - if (account.delegate.account.currency.name === "Solana") { + if (account.delegate.account.currency.name == Currency.SOL.name) { await app.delegate.verifyContinueDisabled(); - await app.delegate.selectProvider(1); + await app.delegate.selectProviderByName(account.delegate.provider); await app.delegate.verifyProviderTC(account.delegate.provider); await app.delegate.verifyProvider(1); } @@ -148,17 +149,21 @@ test.describe("Delegate flows", () => { await app.modal.continue(); await app.delegate.verifyFirstProviderName(validator.delegate.provider); - if (validator.delegate.account.currency.name === "Solana") { + if (validator.delegate.account.currency.name == Currency.SOL.name) { await app.delegate.verifyContinueDisabled(); - await app.delegate.selectProvider(1); + await app.delegate.selectProviderByName(validator.delegate.provider); await app.delegate.verifyProviderTC(validator.delegate.provider); } else await app.delegate.verifyContinueEnabled(); await app.delegate.verifyProvider(1); await app.delegate.openSearchProviderModal(); await app.delegate.checkValidatorListIsVisible(); - await app.delegate.selectProvider(2); + await app.delegate.selectProviderOnRow(2); // TODO: verification skipped due to bug (Clicking 'Show less' does not select the validator that was chosen previously) - LIVE-14500 - if (!["Solana", "Cardano"].includes(validator.delegate.account.currency.name)) + if ( + ![Currency.SOL.name, Currency.ADA.name].includes( + validator.delegate.account.currency.name, + ) + ) await app.delegate.closeProviderList(2); }, );