Skip to content

Commit

Permalink
demo3 swap e2e tests adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
bharamboure-ledger committed Oct 18, 2024
1 parent 0453aaa commit 7c733b8
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,23 @@ const SwapCompleted = ({
<IconClock size={16} />
</WrapperClock>
</IconWrapper>
<Text mt={4} color="palette.text.shade100" ff="Inter|SemiBold" fontSize={5}>
<Text
mt={4}
color="palette.text.shade100"
data-testid={"swap-completed-message"}
ff="Inter|SemiBold"
fontSize={5}
>
<Trans i18nKey={`swap2.exchangeDrawer.completed.title`} />
</Text>
<Text mt={13} textAlign="center" color="palette.text.shade50" ff="Inter|Regular" fontSize={4}>
<Text
mt={13}
textAlign="center"
color="palette.text.shade50"
data-testid={"swap-completed-description"}
ff="Inter|Regular"
fontSize={4}
>
<Trans
i18nKey={`swap2.exchangeDrawer.completed.description`}
values={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Drawer extends Component {
await this.currencyButton(currency).click();
}

protected getAccountButton = (accountName: string, index: number) =>
public getAccountButton = (accountName: string, index: number) =>
this.page.getByTestId(`account-row-${accountName.toLowerCase()}-${index}`).first();

async selectAccount(accountName: string, index = 0) {
Expand Down
2 changes: 0 additions & 2 deletions apps/ledger-live-desktop/tests/enum/Swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ export class Provider {
public readonly uiName: string,
) {}
static readonly CHANGELLY = new Provider("changelly", "Changelly");
static readonly ONEINCH = new Provider("oneinch", "1inch");
static readonly EXODUS = new Provider("exodus", "Exodus");
static readonly THORSWAP = new Provider("thorswap", "THORSwap");
}

export enum Rate {
Expand Down

This file was deleted.

37 changes: 2 additions & 35 deletions apps/ledger-live-desktop/tests/page/speculos.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,12 @@ export class SpeculosPage extends AppPage {
}

verifySwapFeesAmountScreen(swap: Swap, feesAmountScreen: string[]) {
let speculosFeesAmount = "";
speculosFeesAmount =
const feesAmount =
extractNumberFromString(swap.feesAmount).length < 19
? extractNumberFromString(swap.feesAmount)
: extractNumberFromString(swap.feesAmount).substring(0, 18);
expect(
verifySwapFeesAmount(swap.accountToDebit.currency.name, speculosFeesAmount, feesAmountScreen),
verifySwapFeesAmount(swap.accountToDebit.currency.name, feesAmount, feesAmountScreen),
).toBeTruthy();
}

Expand Down Expand Up @@ -156,36 +155,4 @@ export class SpeculosPage extends AppPage {
throw new Error(`Unsupported currency: ${currencyName}`);
}
}

verifySwapGetAmountScreen(swap: Swap, getAmountScreen: string[]) {
if (swap.accountToCredit.currency.name === "Solana") {
expect(
verifyAmount(
`${extractNumberFromString(swap.amountToReceive)} ${swap.accountToCredit.currency.ticker}`,
getAmountScreen,
),
).toBeTruthy();
} else {
expect(
verifyAmount(
`${swap.accountToCredit.currency.ticker} ${extractNumberFromString(swap.amountToReceive)}`,
getAmountScreen,
),
).toBeTruthy();
}
}

verifySwapFeesAmountScreen(swap: Swap, feesAmountScreen: string[]) {
let speculosFeesAmount = "";
if (swap.feesAmount) {
//max number of chars on the screen
speculosFeesAmount =
extractNumberFromString(swap.feesAmount).length < 18
? extractNumberFromString(swap.feesAmount)
: extractNumberFromString(swap.feesAmount).substring(0, 17);
}
expect(
verifySwapFeesAmount(swap.accountToDebit.currency.name, speculosFeesAmount, feesAmountScreen),
).toBeTruthy();
}
}
2 changes: 0 additions & 2 deletions apps/ledger-live-desktop/tests/page/swap.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ElectronApplication, expect } from "@playwright/test";
import { capitalizeFirstLetter } from "tests/utils/textParserUtils";
import { Account } from "tests/enum/Account";
import { ChooseAssetDrawer } from "tests/page/drawer/choose.asset.drawer";
import { ChooseAccountDrawer } from "tests/page/drawer/choose.account.drawer";

export class SwapPage extends AppPage {
private currencyByName = (accountName: string) => this.page.getByText(accountName); // TODO: this is rubbish. Changed this
Expand Down Expand Up @@ -45,7 +44,6 @@ export class SwapPage extends AppPage {
// Quote Components
private quoteContainer = (providerName: string, exchangeType: string) =>
this.page.getByTestId(`quote-container-${providerName}-${exchangeType}`);
//private quoteSelector = (providerName: string) => `quote-container-${providerName}`;
private quoteSelector = (providerName: string, rate: string) =>
`quote-container-${providerName}-${rate}`;

Expand Down
8 changes: 4 additions & 4 deletions apps/ledger-live-desktop/tests/specs/speculos/swap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const swaps = [
Provider.CHANGELLY,
Rate.FLOAT,
),
xrayTicket: "B2CQA-2750",
xrayTicket: "B2CQA-2750, B2CQA-600",
},
{
swap: new Swap(
Expand All @@ -29,7 +29,7 @@ const swaps = [
Provider.CHANGELLY,
Rate.FLOAT,
),
xrayTicket: "B2CQA-2744",
xrayTicket: "B2CQA-2744, B2CQA-2432",
},
{
swap: new Swap(
Expand All @@ -40,7 +40,7 @@ const swaps = [
Provider.CHANGELLY,
Rate.FLOAT,
),
xrayTicket: "B2CQA-2752",
xrayTicket: "B2CQA-2752, B2CQA-2048",
},
{
swap: new Swap(
Expand Down Expand Up @@ -106,7 +106,7 @@ const swaps = [
Provider.CHANGELLY,
Rate.FLOAT,
),
xrayTicket: "B2CQA-2751",
xrayTicket: "B2CQA-2751, B2CQA-2212",
},
];

Expand Down

0 comments on commit 7c733b8

Please sign in to comment.