Skip to content

Commit

Permalink
anti patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
seaona committed Oct 24, 2024
1 parent 3195e3d commit c66015d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 41 deletions.
12 changes: 5 additions & 7 deletions test/e2e/tests/settings/auto-lock.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { strict: assert } = require('assert');
const {
defaultGanacheOptions,
openMenuSafe,
Expand Down Expand Up @@ -41,12 +40,11 @@ describe('Auto-Lock Timer', function () {
'[data-testid="advanced-setting-auto-lock"] button',
);
// Verify the wallet is locked
const pageTitle = await driver.findElement(
'[data-testid="unlock-page-title"]',
);
const unlockButton = await driver.findElement('.unlock-page button');
assert.equal(await pageTitle.getText(), 'Welcome back!');
assert.equal(await unlockButton.isDisplayed(), true);
driver.waitForSelector({
css: '[data-testid="unlock-page-title"]',
text: 'Welcome back!',
});
await driver.waitForSelector('.unlock-page button');
},
);
});
Expand Down
32 changes: 25 additions & 7 deletions test/e2e/tests/settings/localization.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
const { strict: assert } = require('assert');
const {
defaultGanacheOptions,
withFixtures,
unlockWallet,
} = require('../../helpers');
const FixtureBuilder = require('../../fixture-builder');

async function mockPhpConversion(mockServer) {
return await mockServer
.forGet('https://min-api.cryptocompare.com/data/price')
.withQuery({ fsym: 'ETH', tsyms: 'PHP,USD' })
.thenCallback(() => {
return {
statusCode: 200,
json: {
PHP: '100000',
USD: '2500',
},
};
});
}

describe('Localization', function () {
it('can correctly display Philippine peso symbol and code', async function () {
await withFixtures(
Expand All @@ -22,18 +36,22 @@ describe('Localization', function () {
})
.build(),
ganacheOptions: defaultGanacheOptions,
testSpecificMock: mockPhpConversion,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await unlockWallet(driver);

// After the removal of displaying secondary currency in coin-overview.tsx, we will test localization on main balance with showNativeTokenAsMainBalance = false
const primaryBalance = await driver.findElement(
'[data-testid="eth-overview__primary-currency"]',
);
const balanceText = await primaryBalance.getText();
assert.ok(balanceText.startsWith('₱'));
assert.ok(balanceText.endsWith('PHP'));
await driver.waitForSelector({
tag: 'span',
text: 'PHP',
});

await driver.waitForSelector({
tag: 'span',
text: '₱2,500,000.00',
});
},
);
});
Expand Down
15 changes: 2 additions & 13 deletions test/e2e/tests/settings/settings-general.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { strict: assert } = require('assert');
const {
defaultGanacheOptions,
openMenuSafe,
Expand Down Expand Up @@ -28,25 +27,15 @@ describe('Settings', function () {
'[data-testid="jazz_icon"] .settings-page__content-item__identicon__item__icon--active',
);

const jazziconText = await driver.findElement({
await driver.waitForSelector({
tag: 'h6',
text: 'Jazzicons',
});
assert.equal(
await jazziconText.getText(),
'Jazzicons',
'Text for icon should be Jazzicons',
);

const blockiesText = await driver.findElement({
await driver.waitForSelector({
tag: 'h6',
text: 'Blockies',
});
assert.equal(
await blockiesText.getText(),
'Blockies',
'Text for icon should be Blockies',
);
},
);
});
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/tests/settings/settings-security-reveal-srp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ describe('Reveal SRP through settings', function () {
await tapAndHoldToRevealSRP(driver);

// confirm SRP text matches expected
const displayedSRP = await driver.findVisibleElement(
'[data-testid="srp_text"]',
);
assert.equal(await displayedSRP.getText(), E2E_SRP);
await driver.waitForSelector({
css: '[data-testid="srp_text"]',
text: E2E_SRP,
});

// copy SRP text to clipboard
await driver.clickElement({
Expand Down
14 changes: 4 additions & 10 deletions test/e2e/tests/settings/show-hex-data.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { strict: assert } = require('assert');
const {
defaultGanacheOptions,
withFixtures,
Expand Down Expand Up @@ -84,15 +83,10 @@ describe('Check the toggle for hex data', function () {
await sendTransactionAndVerifyHexData(driver);

// Verify hex data in the container content
const pageContentContainer = await driver.findElement(
selectors.containerContent,
);
const pageContentContainerText = await pageContentContainer.getText();
assert.equal(
pageContentContainerText.includes(inputData.hexDataText),
true,
'Hex data is incorrect',
);
await driver.waitForSelector({
tag: 'p',
text: '0x0abc',
});
},
);
});
Expand Down

0 comments on commit c66015d

Please sign in to comment.