From 8ebee5abbbc8f99d9bdb1dea697a22f132a0c154 Mon Sep 17 00:00:00 2001 From: Sophie TUAL Date: Tue, 17 Dec 2024 12:13:18 +0100 Subject: [PATCH] B2CQA-2110 : test swapping with Send Max button --- .../tests/page/swap.page.ts | 8 ++ .../tests/specs/speculos/swap.spec.ts | 76 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/apps/ledger-live-desktop/tests/page/swap.page.ts b/apps/ledger-live-desktop/tests/page/swap.page.ts index 650f9e3b7531..893630ddf956 100644 --- a/apps/ledger-live-desktop/tests/page/swap.page.ts +++ b/apps/ledger-live-desktop/tests/page/swap.page.ts @@ -121,6 +121,14 @@ export class SwapPage extends AppPage { await this.quoteContainer(providerName, exchangeType).click(); } + @step("Send Max Amount") + async fillInMaxAmount(electronApp: ElectronApplication) { + const [, webview] = electronApp.windows(); + await webview.getByTestId(this.maxSpendableToggle).click(); + //wait for potential origin amount error to be loaded + await this.page.waitForTimeout(500); + } + @step("Select exchange quote with provider $1") async selectQuote(electronApp: ElectronApplication, providerName: string, rate: string) { const [, webview] = electronApp.windows(); diff --git a/apps/ledger-live-desktop/tests/specs/speculos/swap.spec.ts b/apps/ledger-live-desktop/tests/specs/speculos/swap.spec.ts index ded688c1aee2..cc87bb251df8 100644 --- a/apps/ledger-live-desktop/tests/specs/speculos/swap.spec.ts +++ b/apps/ledger-live-desktop/tests/specs/speculos/swap.spec.ts @@ -415,6 +415,82 @@ for (const { swap, xrayTicket } of tooLowAmountForQuoteSwaps) { }); } +const swapWithSendMax = [ + { + swap: new Swap( + Account.ETH_1, + Account.BTC_NATIVE_SEGWIT_1, + "0.02", + Fee.MEDIUM, + Provider.CHANGELLY, + Rate.FLOAT, + ), + xrayTicket: "B2CQA-2110, QAA-292", + }, + { + swap: new Swap( + Account.ETH_1, + Account.SOL_1, + "0.02", + Fee.MEDIUM, + Provider.CHANGELLY, + Rate.FLOAT, + ), + xrayTicket: "B2CQA-2110, QAA-292", + } +]; + +for (const { swap, xrayTicket } of swapWithSendMax) { + test.describe("Swap - Swap with Send Max", () => { + test.beforeAll(async () => { + process.env.SWAP_DISABLE_APPS_INSTALL = "true"; + process.env.SWAP_API_BASE = "https://swap-stg.ledger-test.com/v5"; + process.env.DISABLE_TRANSACTION_BROADCAST = "true"; + }); + + const accPair: string[] = [swap.accountToDebit, swap.accountToCredit].map(acc => + acc.currency.speculosApp.name.replace(/ /g, "_"), + ); + + test.beforeEach(async () => { + setExchangeDependencies( + accPair.map(appName => ({ + name: appName, + })), + ); + }); + + test.afterAll(async () => { + delete process.env.SWAP_DISABLE_APPS_INSTALL; + delete process.env.SWAP_API_BASE; + delete process.env.DISABLE_TRANSACTION_BROADCAST; + }); + + test.use({ + userdata: "speculos-tests-app", + speculosApp: app, + }); + + test( + `Swap ${swap.accountToDebit.currency.name} to ${swap.accountToCredit.currency.name}`, + { + annotation: { + type: "TMS", + description: xrayTicket, + }, + }, + async ({ app, electronApp }) => { + await addTmsLink(getDescription(test.info().annotations, "TMS").split(", ")); + await performSwapUntilQuoteSelectionStepWithSendMax(app, electronApp, swap); + await app.swap.selectQuote(electronApp, swap.provider.name, swap.rate); + await performSwapUntilDeviceVerificationStep(app, electronApp, swap); + await app.speculos.verifyAmountsAndAcceptSwap(swap); + await app.swapDrawer.verifyExchangeCompletedTextContent(swap.accountToCredit.currency.name); + }, + ); + }); +} + async function performSwapUntilQuoteSelectionStep( app: Application, electronApp: ElectronApplication,