diff --git a/apps/ledger-live-desktop/src/renderer/components/LinkWithExternalIcon.tsx b/apps/ledger-live-desktop/src/renderer/components/LinkWithExternalIcon.tsx index b4b364e0ecc1..f891520d701e 100644 --- a/apps/ledger-live-desktop/src/renderer/components/LinkWithExternalIcon.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/LinkWithExternalIcon.tsx @@ -40,6 +40,7 @@ type Props = { style?: React.CSSProperties; fontSize?: number; color?: string; + id?: string; }; // can add more dynamic options if needed export function LinkWithExternalIcon({ onClick, @@ -48,9 +49,16 @@ export function LinkWithExternalIcon({ style, fontSize, color = "wallet", + id, }: Props) { return ( - + {label || children} ); diff --git a/apps/ledger-live-desktop/src/renderer/families/solana/shared/components/LedgerValidatorTCLink.tsx b/apps/ledger-live-desktop/src/renderer/families/solana/shared/components/LedgerValidatorTCLink.tsx index 2d0285de39af..151368a49512 100644 --- a/apps/ledger-live-desktop/src/renderer/families/solana/shared/components/LedgerValidatorTCLink.tsx +++ b/apps/ledger-live-desktop/src/renderer/families/solana/shared/components/LedgerValidatorTCLink.tsx @@ -21,7 +21,13 @@ export default function LedgerValidatorTCLink({ transaction }: Props) { if (!data) return null; const openLedgerValidatorTC = () => openURL(data.url); - return ; + return ( + + ); } const shouldShowTC = ({ model }: Transaction) => { switch (model.kind) { diff --git a/apps/ledger-live-desktop/src/renderer/icons/Check.tsx b/apps/ledger-live-desktop/src/renderer/icons/Check.tsx index 5e1a3ddc1765..d51b5919e841 100644 --- a/apps/ledger-live-desktop/src/renderer/icons/Check.tsx +++ b/apps/ledger-live-desktop/src/renderer/icons/Check.tsx @@ -8,7 +8,7 @@ const Check = ({ size?: number; color?: string; }) => ( - + this.page.getByTestId(`stake-provider-container-${stakeProviderID}`); private detailsButton = this.page.getByRole("button", { name: "View details" }); + private validatorTC = this.page.getByTestId("ledger-validator-tc"); + private checkIcon = this.page.getByTestId("check-icon"); - @step("Get title provider") - async getTitleProvider() { - await this.titleProvider.waitFor(); - return await this.titleProvider.textContent(); + @step("Get title provider on row $0") + async getTitleProvider(row: number): Promise { + await this.titleProvider.nth(row - 1).waitFor(); + const titleProvider = await this.titleProvider.nth(row - 1).textContent(); + expect(titleProvider).not.toBeNull(); + return titleProvider!; } - @step("Verify provider is $0") - async verifyProvider(provider: string) { - const providerName = await this.getTitleProvider(); - if (providerName) { - expect(providerName).toBe(provider); - } + @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 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(); + } + + @step("Select provider on row $0") + async verifyProvider(row: number) { + const isCheckIconWithinRowProvider = + (await this.rowProvider + .nth(row - 1) + .locator(this.checkIcon) + .count()) > 0; + expect(isCheckIconWithinRowProvider).toBe(true); + } + + @step("Verify continue button is disabled") + async verifyContinueDisabled() { + await expect(this.delegateContinueButton).toBeDisabled(); + } + + @step("Verify continue button is enabled") + async verifyContinueEnabled() { + await expect(this.delegateContinueButton).toBeEnabled(); + } + + @step("Verify provider TC contains $0") + async verifyProviderTC(provider: string) { + const providerTC = await this.validatorTC.textContent(); + expect(providerTC).toContain(provider); } @step("Click on continue button - delegate") @@ -43,14 +83,11 @@ export class delegateModal extends Modal { await this.inputSearchField.fill(provider); } - @step("check selected provider is different from the previous one") - async selectProvider(providerIndex: number) { - const selectedfProvider = await this.titleProvider.nth(providerIndex).textContent(); - await this.rowProvider.nth(providerIndex).click(); + @step("Check selected provider is displayed when closing list") + async closeProviderList(providerRow: number) { + const selectedfProvider = await this.getTitleProvider(providerRow); await this.searchCloseButton.click(); - if (selectedfProvider) { - expect(await this.getTitleProvider()).toContain(selectedfProvider); - } + expect(await this.getTitleProvider(1)).toContain(selectedfProvider); } @step("Click on chosen stake provider $0") diff --git a/apps/ledger-live-desktop/tests/specs/accounts/delegate.smoke.spec.ts b/apps/ledger-live-desktop/tests/specs/accounts/delegate.smoke.spec.ts index 8cda584b6943..8467a9658c67 100644 --- a/apps/ledger-live-desktop/tests/specs/accounts/delegate.smoke.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/accounts/delegate.smoke.spec.ts @@ -28,7 +28,7 @@ test("Delegate flow using max amount", async () => { await test.step("Check Ledger is the provider by default", async () => { await modalPage.continue(); - const defaultprovider = await delegate.getTitleProvider(); + const defaultprovider = await delegate.getTitleProvider(1); expect(defaultprovider).toEqual("Ledger"); }); @@ -52,8 +52,8 @@ test("The user search and select a provider", async () => { const providerResearched = "Figment"; await delegate.openSearchProviderModal(); await delegate.inputProvider(providerResearched); - await delegate.selectProvider(0); - const providerSelected = await delegate.getTitleProvider(); + await delegate.selectProviderOnRow(1); + const providerSelected = await delegate.getTitleProvider(1); expect(providerSelected).toEqual(providerResearched); }); }); 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 77ecf213f7c5..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 = [ { @@ -34,10 +35,10 @@ const validators = [ delegate: new Delegate(Account.NEAR_2, "0.01", "ledgerbyfigment.poolv1.near"), xrayTicket: "B2CQA-2732, B2CQA-2765", }, - /*{ - delegate: new Delegate(Account.ADA_1, "0.01", "LBF3 - Ledger by Figment 3"), // todo: deactivate due to bug (Clicking 'Show less' does not select the validator that was chosen previously) - LIVE-14500 + { + delegate: new Delegate(Account.ADA_1, "0.01", "LBF3 - Ledger by Figment 3"), xrayTicket: "B2CQA-2766", - },*/ + }, { delegate: new Delegate(Account.MULTIVERS_X_1, "1", "Ledger by Figment"), xrayTicket: "B2CQA-2767", @@ -85,8 +86,13 @@ test.describe("Delegate flows", () => { await app.accounts.navigateToAccountByName(account.delegate.account.accountName); await app.account.clickBannerCTA(); - await app.delegate.verifyProvider(account.delegate.provider); - + await app.delegate.verifyFirstProviderName(account.delegate.provider); + if (account.delegate.account.currency.name == Currency.SOL.name) { + await app.delegate.verifyContinueDisabled(); + await app.delegate.selectProviderByName(account.delegate.provider); + await app.delegate.verifyProviderTC(account.delegate.provider); + await app.delegate.verifyProvider(1); + } await app.delegate.continueDelegate(); await app.delegate.fillAmount(account.delegate.amount); await app.modal.countinueSendAmount(); @@ -142,10 +148,23 @@ test.describe("Delegate flows", () => { await app.account.startStakingFlowFromMainStakeButton(); await app.modal.continue(); - await app.delegate.verifyProvider(validator.delegate.provider); + await app.delegate.verifyFirstProviderName(validator.delegate.provider); + if (validator.delegate.account.currency.name == Currency.SOL.name) { + await app.delegate.verifyContinueDisabled(); + 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(1); + 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 ( + ![Currency.SOL.name, Currency.ADA.name].includes( + validator.delegate.account.currency.name, + ) + ) + await app.delegate.closeProviderList(2); }, ); }); @@ -185,7 +204,7 @@ test.describe("Delegate flows", () => { await app.assetDrawer.selectAsset(delegateAccount.account.currency); await app.assetDrawer.selectAccountByIndex(delegateAccount.account); - await app.delegate.verifyProvider(delegateAccount.provider); + await app.delegate.verifyFirstProviderName(delegateAccount.provider); await app.delegate.continueDelegate(); }, ); @@ -206,7 +225,7 @@ test.describe("Delegate flows", () => { await app.assetDrawer.selectAccountByIndex(delegateAccount.account); - await app.delegate.verifyProvider(delegateAccount.provider); + await app.delegate.verifyFirstProviderName(delegateAccount.provider); await app.delegate.continueDelegate(); }, );