Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B2CQA-2110 : Swapping with Send Max button #8714

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/ledger-live-desktop/tests/page/swap.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
76 changes: 76 additions & 0 deletions apps/ledger-live-desktop/tests/specs/speculos/swap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading