Skip to content

Commit

Permalink
Merge pull request #7918 from LedgerHQ/support/fix-addAccount-e2e
Browse files Browse the repository at this point in the history
Fix add account e2e test - Bitcoin
  • Loading branch information
VicAlbr authored Sep 26, 2024
2 parents d504db1 + 5e6c972 commit 03c3a22
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ function AccountRow(props: Props) {
color="palette.text.shade60"
/>
) : null}
{!isDisabled && !isReadonly && <CheckBox disabled isChecked={isChecked || !!isDisabled} />}
{!isDisabled && !isReadonly && (
<CheckBox
data-testid="accountRow-checkbox"
disabled
isChecked={isChecked || !!isDisabled}
/>
)}
</AccountRowContainer>
);
}
Expand Down
11 changes: 6 additions & 5 deletions apps/ledger-live-desktop/tests/component/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class Layout extends Component {
// general
readonly inputError = this.page.locator("id=input-error"); // no data-testid because css style is applied
readonly insufficientFundsWarning = this.page.getByTestId("insufficient-funds-warning");
private loadingSpinner = this.page.getByTestId("loading-spinner");
readonly logo = this.page.getByTestId("logo");

// updater
Expand Down Expand Up @@ -104,10 +103,12 @@ export class Layout extends Component {
}

@step("Check warning message")
async checkWarningMessage(expectedWarningMessage: RegExp) {
await expect(this.insufficientFundsWarning).toBeVisible();
const warningText = await this.insufficientFundsWarning.innerText();
expect(warningText).toMatch(expectedWarningMessage);
async checkWarningMessage(expectedWarningMessage: RegExp | string | null) {
if (expectedWarningMessage !== null) {
await expect(this.insufficientFundsWarning).toBeVisible();
const warningText = await this.insufficientFundsWarning.innerText();
expect(warningText).toMatch(expectedWarningMessage);
}
}

@step("Check if the error message is the same as expected")
Expand Down
4 changes: 2 additions & 2 deletions apps/ledger-live-desktop/tests/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export class Account {
public readonly address: string,
) {}

static readonly BTC_1 = new Account(
static readonly BTC_NATIVE_SEGWIT_1 = new Account(
Currency.BTC,
"Bitcoin 1",
"bc1qx7f9plgr8msjatkv0dw2ne8gguwfjqr6xyjp50",
);

static readonly BTC_2 = new Account(
static readonly BTC_NATIVE_SEGWIT_2 = new Account(
Currency.BTC,
"Bitcoin 2",
"bc1q7ezsfc44adw2gyzqjmwhuh2e83uk8u5hrw590r",
Expand Down
1 change: 1 addition & 0 deletions apps/ledger-live-desktop/tests/page/abstractClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export abstract class Component extends PageHolder {
`//*[contains(text(),"${text}")]/following::span[contains(text(),"${followingText}")]`,
)
.first();
protected loadingSpinner = this.page.getByTestId("loading-spinner");

async waitForPageDomContentLoadedState() {
return await this.page.waitForLoadState("domcontentloaded");
Expand Down
13 changes: 13 additions & 0 deletions apps/ledger-live-desktop/tests/page/modal/add.account.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export class AddAccountModal extends Modal {
private selectAccount = this.page.locator("text=Choose a crypto asset"); // FIXME: I need an id
readonly selectAccountInput = this.page.locator('[placeholder="Search"]'); // FIXME: I need an id
readonly addAccountsButton = this.page.getByTestId("add-accounts-import-add-button");
private deselectAllButton = this.page.getByText("Deselect all");
private checkbox = this.page.getByTestId("accountRow-checkbox").first();
private accountsList = this.page.getByTestId("add-accounts-step-import-accounts-list");
private stopButton = this.page.getByTestId("add-accounts-import-stop-button");
private doneButton = this.page.getByTestId("add-accounts-finish-close-button");
Expand Down Expand Up @@ -92,10 +94,21 @@ export class AddAccountModal extends Modal {
await expect(this.closeButton).toBeVisible();
await this.continue();
await this.waitForSync();
await this.loadingSpinner.waitFor({ state: "hidden" });
}

@step("click `Add Accounts` button - mocked tests")
async addAccountsMocked() {
await this.addAccountsButton.click();
await expect(this.successAddLabel).toBeVisible();
}

@step("Click `Add Accounts` button")
async addAccounts() {
if (await this.deselectAllButton.isVisible()) {
await this.deselectAllButton.click();
await this.checkbox.click({ force: true });
}
await this.addAccountsButton.click();
await expect(this.successAddLabel).toBeVisible();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test.describe.parallel("Accounts @smoke", () => {
});

await test.step(`[${currency}] Scan and add accounts`, async () => {
await addAccountModal.addAccounts();
await addAccountModal.addAccountsMocked();
await expect.soft(addAccountModal.container).toHaveScreenshot(`${currency}-success.png`);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addTmsLink } from "tests/utils/allureUtils";
import { getDescription } from "../../utils/customJsonReporter";

const accounts = [
{ account: Account.BTC_1, xrayTicket: "B2CQA-2548" },
{ account: Account.BTC_NATIVE_SEGWIT_1, xrayTicket: "B2CQA-2548" },
{ account: Account.ETH_1, xrayTicket: "B2CQA-2551" },
{ account: Account.SOL_1, xrayTicket: "B2CQA-2553" },
{ account: Account.XRP_1, xrayTicket: "B2CQA-2557" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addTmsLink } from "tests/utils/allureUtils";
import { getDescription } from "../../utils/customJsonReporter";

const accounts = [
{ account: Account.BTC_1, xrayTicket: "B2CQA-2559, B2CQA-2687" },
{ account: Account.BTC_NATIVE_SEGWIT_1, xrayTicket: "B2CQA-2559, B2CQA-2687" },
{ account: Account.ETH_1, xrayTicket: "B2CQA-2561, B2CQA-2688, B2CQA-2697" },
{ account: Account.SOL_1, xrayTicket: "B2CQA-2563, B2CQA-2689" },
{ account: Account.TRX_1, xrayTicket: "B2CQA-2565, B2CQA-2690, B2CQA-2699" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ test.describe("Send token (subAccount) - valid address & amount input", () => {
test.describe("Check invalid address input error", () => {
const transactionInvalidAddress = new Transaction(
Account.ETH_1,
Account.BTC_1,
Account.BTC_NATIVE_SEGWIT_1,
"0.00001",
Fee.MEDIUM,
);
Expand Down
2 changes: 1 addition & 1 deletion apps/ledger-live-desktop/tests/specs/speculos/swap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Providers, Rates } from "tests/enum/Swap";

const swaps = [
{
swap: new Swap(Account.ETH_1, Account.BTC_1, "0.015", Fee.MEDIUM),
swap: new Swap(Account.ETH_1, Account.BTC_NATIVE_SEGWIT_1, "0.015", Fee.MEDIUM),
},
];

Expand Down

0 comments on commit 03c3a22

Please sign in to comment.