Skip to content

Commit ba3d02d

Browse files
committed
Enhance Ledger account tests to handle Firefox compatibility. Added checks for "Firefox Not Supported" message and refactored account selection logic for improved clarity and maintainability.
1 parent 2d055b7 commit ba3d02d

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

test/e2e/tests/hardware-wallets/ledger-account.spec.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Browser, By } from 'selenium-webdriver';
12
import FixtureBuilder from '../../fixture-builder';
23
import { withFixtures } from '../../helpers';
34
import { shortenAddress } from '../../../../ui/helpers/utils/util';
@@ -9,6 +10,8 @@ import HomePage from '../../page-objects/pages/home/homepage';
910
import SelectHardwareWalletAccountPage from '../../page-objects/pages/hardware-wallet/select-hardware-wallet-account-page';
1011
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
1112

13+
const IS_FIREFOX = process.env.SELENIUM_BROWSER === Browser.FIREFOX;
14+
1215
describe('Ledger Hardware', function () {
1316
it('derives the correct accounts and unlocks the first account', async function () {
1417
await withFixtures(
@@ -31,32 +34,40 @@ describe('Ledger Hardware', function () {
3134
await connectHardwareWalletPage.check_pageIsLoaded();
3235
await connectHardwareWalletPage.openConnectLedgerPage();
3336

34-
const selectLedgerAccountPage = new SelectHardwareWalletAccountPage(
35-
driver,
36-
);
37-
await selectLedgerAccountPage.check_pageIsLoaded();
37+
if (IS_FIREFOX) {
38+
// check Firefox Not Supported text exists and stop test
39+
await driver.findElement(
40+
By.xpath("//*[contains(text(), 'Firefox Not Supported')]"),
41+
);
42+
} else {
43+
const selectLedgerAccountPage = new SelectHardwareWalletAccountPage(
44+
driver,
45+
);
3846

39-
// Check that the first page of accounts is correct
40-
await selectLedgerAccountPage.check_accountNumber();
41-
for (const { address } of KNOWN_PUBLIC_KEY_ADDRESSES.slice(0, 4)) {
42-
const shortenedAddress = `${address.slice(0, 4)}...${address.slice(
43-
-4,
44-
)}`;
45-
await selectLedgerAccountPage.check_addressIsDisplayed(
46-
shortenedAddress,
47+
await selectLedgerAccountPage.check_pageIsLoaded();
48+
49+
// Check that the first page of accounts is correct
50+
await selectLedgerAccountPage.check_accountNumber();
51+
for (const { address } of KNOWN_PUBLIC_KEY_ADDRESSES.slice(0, 4)) {
52+
const shortenedAddress = `${address.slice(0, 4)}...${address.slice(
53+
-4,
54+
)}`;
55+
await selectLedgerAccountPage.check_addressIsDisplayed(
56+
shortenedAddress,
57+
);
58+
}
59+
60+
// Unlock first account of first page and check that the correct account has been added
61+
await selectLedgerAccountPage.unlockAccount(1);
62+
await headerNavbar.check_pageIsLoaded();
63+
await new HomePage(driver).check_expectedBalanceIsDisplayed('0');
64+
await headerNavbar.openAccountMenu();
65+
await accountListPage.check_pageIsLoaded();
66+
await accountListPage.check_accountDisplayedInAccountList('Ledger 1');
67+
await accountListPage.check_accountAddressDisplayedInAccountList(
68+
shortenAddress(KNOWN_PUBLIC_KEY_ADDRESSES[0].address),
4769
);
4870
}
49-
50-
// Unlock first account of first page and check that the correct account has been added
51-
await selectLedgerAccountPage.unlockAccount(1);
52-
await headerNavbar.check_pageIsLoaded();
53-
await new HomePage(driver).check_expectedBalanceIsDisplayed('0');
54-
await headerNavbar.openAccountMenu();
55-
await accountListPage.check_pageIsLoaded();
56-
await accountListPage.check_accountDisplayedInAccountList('Ledger 1');
57-
await accountListPage.check_accountAddressDisplayedInAccountList(
58-
shortenAddress(KNOWN_PUBLIC_KEY_ADDRESSES[0].address),
59-
);
6071
},
6172
);
6273
});

0 commit comments

Comments
 (0)