Skip to content

Commit

Permalink
test(extension): testing framework maintenance (#1091)
Browse files Browse the repository at this point in the history
* test(extension): remove webTester class

* test(extension): remove unused code from modal class

* test(extension): remove unused NetworkAssert class

* test(extension): cleanup after LW-5635

* test(extension): move steps for settings page to relevant file

* test(extension): remove tokensPageObject.ts

* test(extension): disable showing multidelegation persistance banner for some tests
  • Loading branch information
wklos-iohk committed Apr 25, 2024
1 parent 5a138cf commit 92eabfb
Show file tree
Hide file tree
Showing 20 changed files with 76 additions and 230 deletions.
33 changes: 0 additions & 33 deletions packages/e2e-tests/src/actor/webTester.ts

This file was deleted.

6 changes: 2 additions & 4 deletions packages/e2e-tests/src/assert/dAppConnectorAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import testContext from '../utils/testContext';
import RemoveDAppModal from '../elements/dappConnector/removeDAppModal';
import NoWalletModal from '../elements/dappConnector/noWalletModal';
import extensionUtils from '../utils/utils';
import TokensPageObject from '../pageobject/tokensPageObject';
import TokensPage from '../elements/tokensPage';
import { getTestWallet, TestWalletName } from '../support/walletConfiguration';
import { browser } from '@wdio/globals';
import InsufficientFundsDAppPage from '../elements/dappConnector/insufficientFundsDAppPage';
Expand Down Expand Up @@ -218,9 +218,7 @@ class DAppConnectorAssert {
expect(await ExampleDAppPage.walletNetworkId.getText()).to.equal(extensionUtils.isMainnet() ? '1' : '0');
expect(await ExampleDAppPage.walletUtxo.getText()).not.to.be.empty;

const actualWalletLovelaceBalance = Number(
(Number(await TokensPageObject.loadTokenBalance('Cardano')) * 100).toFixed(0)
);
const actualWalletLovelaceBalance = Number((Number(await TokensPage.loadTokenBalance('Cardano')) * 100).toFixed(0));
const dAppWalletLovelaceBalance = Math.trunc(Number(await ExampleDAppPage.walletBalance.getText()) / 10_000);

expect(dAppWalletLovelaceBalance).to.be.closeTo(actualWalletLovelaceBalance, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ class StakePoolDetailsAssert {
await StakePoolDetails.rosTitle.waitForDisplayed();
expect(await StakePoolDetails.rosTitle.getText()).to.equal(await t('drawer.details.metrics.ros', 'staking'));
await StakePoolDetails.rosValue.waitForDisplayed();
// TODO BUG LW-5635
// expect(await StakePoolDetails.rosValue.getText()).to.match(TestnetPatterns.PERCENT_DOUBLE_REGEX);
expect(await StakePoolDetails.rosValue.getText()).to.match(TestnetPatterns.PERCENT_DOUBLE_REGEX);
}

private async assertSeeDelegators() {
Expand Down
24 changes: 0 additions & 24 deletions packages/e2e-tests/src/assert/networkAssert.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/e2e-tests/src/assert/stakePoolDetailsAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class StakePoolDetailsAssert {
await t('cardano.stakePoolMetricsBrowser.activeStake')
);
expect(await StakePoolDetails.rosTitle.getText()).to.equal('ROS');
// TODO BUG LW-5635
// expect((await StakePoolDetails.rosValue.getText()) as string).to.match(TestnetPatterns.PERCENT_DOUBLE_REGEX);
expect((await StakePoolDetails.rosValue.getText()) as string).to.match(TestnetPatterns.PERCENT_DOUBLE_REGEX);

expect((await StakePoolDetails.activeStakeValue.getText()).slice(0, -1)).to.match(
TestnetPatterns.NUMBER_DOUBLE_REGEX
Expand Down
7 changes: 2 additions & 5 deletions packages/e2e-tests/src/assert/stakingPageAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ class StakingPageAssert {
? expect(await StakingInfoComponent.poolTicker.getText()).to.contain(expectedStakePool.poolId.slice(0, 6))
: expect(await StakingInfoComponent.poolTicker.getText()).to.equal(expectedStakePool.ticker);

expect(await StakingInfoComponent.statsApy.title.getText()).to.equal(
expect(await StakingInfoComponent.statsROS.title.getText()).to.equal(
await t('browserView.staking.stakingInfo.stats.ros')
);
// TODO BUG LW-5635
// expect((await webTester.getTextValueFromElement(stakingInfoComponent.statsApy().value())) as string).to.match(
// TestnetPatterns.PERCENT_DOUBLE_REGEX
// );
expect(await StakingInfoComponent.statsROS.value.getText()).to.match(TestnetPatterns.PERCENT_DOUBLE_REGEX);

expect(await StakingInfoComponent.statsFee.title.getText()).to.equal(
await t('browserView.staking.stakingInfo.stats.Fee')
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/src/assert/tokensPageAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TokensPageAssert {
};

assertCounterNumberMatchesWalletTokens = async () => {
const tokensCounterValue = Number((await TokensPage.counter.getText()).slice(1, -1));
const tokensCounterValue = await TokensPage.getTokensCounterAsNumber();
if (tokensCounterValue > 0) await TokensPage.coinGeckoCredits.scrollIntoView();
await TokensPage.tokenRowSkeleton.waitForDisplayed({ reverse: true, timeout: 60_000 });
const rowsNumber = (await TokensPage.getRows()).length;
Expand Down
4 changes: 0 additions & 4 deletions packages/e2e-tests/src/elements/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class Modal {
return this.container.$(this.CONFIRM_BUTTON);
}

buttonWithText(value: string): ChainablePromiseElement<WebdriverIO.Element> {
return $(this.CONTAINER).$(`//button/span[text() = '${value}']`);
}

async clickCancelButton() {
await this.cancelButton.waitForClickable();
await this.cancelButton.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class StakingInfoComponent {
private POOL_LOGO = '[data-testid="stake-pool-logo"]';
private POOL_NAME = '[data-testid="stake-pool-name"]';
private POOL_TICKER = '[data-testid="stake-pool-ticker"]';
private STATS_APY_CONTAINER = '[data-testid="stats-ros-container"]';
private STATS_ROS_CONTAINER = '[data-testid="stats-ros-container"]';
private STATS_FEE_CONTAINER = '[data-testid="stats-fee-container"]';
private STATS_MARGIN_CONTAINER = '[data-testid="stats-margin-container"]';
private STATS_LAST_REWARD_CONTAINER = '[data-testid="stats-last-reward-container"]';
Expand All @@ -30,8 +30,8 @@ class StakingInfoComponent {
return $(this.POOL_TICKER);
}

get statsApy(): StatsComponent {
return new StatsComponent(this.STATS_APY_CONTAINER);
get statsROS(): StatsComponent {
return new StatsComponent(this.STATS_ROS_CONTAINER);
}

get statsFee(): StatsComponent {
Expand Down
4 changes: 4 additions & 0 deletions packages/e2e-tests/src/elements/tokenDetailsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class TokenDetailsPage extends CommonDrawerElements {
get transactionsListItems(): Promise<WebdriverIO.ElementArray> {
return $$(this.TRANSACTION_ITEM);
}

async clickOnViewAllButton() {
await this.viewAllButton.click();
}
}

export default new TokenDetailsPage();
35 changes: 30 additions & 5 deletions packages/e2e-tests/src/elements/tokensPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import SectionTitle from './sectionTitle';
import { ChainablePromiseElement } from 'webdriverio';
import { ChainablePromiseArray } from 'webdriverio/build/types';
import TokensPageAssert from '../assert/tokensPageAssert';
import testContext from '../utils/testContext';
import { Asset } from '../data/Asset';

class TokensPage {
private BALANCE_LABEL = '[data-testid="portfolio-balance-label"]';
Expand All @@ -22,7 +24,6 @@ class TokensPage {
private SEND_BUTTON_POPUP_MODE = 'main [data-testid="send-button"]';
private CLOSED_EYE_ICON = '[data-testid="closed-eye-icon"]';
private OPENED_EYE_ICON = '[data-testid="opened-eye-icon"]';
private VIEW_ALL_BUTTON = '[data-testid="view-all-button"]';
private TOKEN_ROW_SKELETON = '.ant-skeleton';
private PRICE_FETCH_ERROR_DESCRIPTION = '[data-testid="banner-description"]';

Expand Down Expand Up @@ -58,10 +59,6 @@ class TokensPage {
return $(this.BALANCE_CURRENCY);
}

get ViewAllButton(): ChainablePromiseElement<WebdriverIO.Element> {
return $(this.VIEW_ALL_BUTTON);
}

tokensAvatar(index: number): ChainablePromiseElement<WebdriverIO.Element> {
return $$(this.TOKENS_TABLE_ROW)[index].$(this.TOKEN_AVATAR);
}
Expand Down Expand Up @@ -163,6 +160,34 @@ class TokensPage {
async waitForPricesToBeFetched() {
await this.totalBalanceValue.waitForDisplayed({ timeout: TokensPageAssert.ADA_PRICE_CHECK_INTERVAL });
}

async clickTokenWithName(tokenName: string) {
await this.tokensTableItemWithName(tokenName).click();
}

async waitUntilHeadersLoaded() {
await this.title.waitForDisplayed({ timeout: 30_000 });
await this.totalBalanceLabel.waitForDisplayed({ timeout: 30_000 });
}

async waitUntilCardanoTokenLoaded() {
const selector = 'p=Cardano';
await $(selector).waitForClickable({ timeout: 120_000 });
}

async saveTokenBalance(tokenName: string) {
const rowIndex = await this.getTokenRowIndex(tokenName);
const tokenBalance = await this.getTokenBalanceAsFloatByIndex(rowIndex);
testContext.save(`${Asset.getByName(tokenName)?.ticker}tokenBalance`, tokenBalance);
}

async loadTokenBalance(tokenName: string) {
return testContext.load(`${Asset.getByName(tokenName)?.ticker}tokenBalance`);
}

async clickOnCoinGeckoCreditsLink() {
await this.coinGeckoLink.click();
}
}

export default new TokensPage();
48 changes: 0 additions & 48 deletions packages/e2e-tests/src/elements/webElement.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/e2e-tests/src/features/SettingsPageExtended.feature
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,13 @@ Feature: General Settings - Extended Browser View
Then I see LW homepage
And I see a different wallet address than in my initial wallet

# this test should be executed as the last one in this suite
# this test should be executed as the last one in this suite
@LW-2521 @LW-9113 @Mainnet @Testnet
Scenario: Extended View - Remove wallet and confirm
And my local storage is fully initialized
When I open settings from header menu
And I click on Remove wallet button
Then I see Remove wallet section
When I click on Remove wallet button
And I click "Remove wallet" button on "Remove wallet" modal
Then I see Analytics banner
And I expect wallet repository and local storage to be empty
Expand Down
2 changes: 2 additions & 0 deletions packages/e2e-tests/src/hooks/beforeTagHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Before(
async () => {
await extendedViewWalletInitialization();
await localStorageInitializer.disableShowingMultidelegationBetaBanner();
await localStorageInitializer.disableShowingMultidelegationPersistenceBanner();
}
);

Expand All @@ -49,6 +50,7 @@ Before(
async () => {
await popupViewWalletInitialization();
await localStorageInitializer.disableShowingMultidelegationBetaBanner();
await localStorageInitializer.disableShowingMultidelegationPersistenceBanner();
}
);

Expand Down
39 changes: 0 additions & 39 deletions packages/e2e-tests/src/pageobject/tokensPageObject.ts

This file was deleted.

9 changes: 5 additions & 4 deletions packages/e2e-tests/src/steps/commonSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
switchToWindowWithRetry
} from '../utils/window';
import { Given } from '@wdio/cucumber-framework';
import tokensPageObject from '../pageobject/tokensPageObject';
import TokensPage from '../elements/tokensPage';
import ToastMessage from '../elements/toastMessage';
import menuMainAssert from '../assert/menuMainAssert';
import LocalStorageAssert from '../assert/localStorageAssert';
Expand All @@ -50,19 +50,20 @@ Given(/^Lace is ready for test$/, async () => {
await MainLoader.waitUntilLoaderDisappears();
await settingsExtendedPageObject.waitUntilSyncingModalDisappears();
await settingsExtendedPageObject.multiAddressModalConfirm();
await tokensPageObject.waitUntilCardanoTokenLoaded();
await TokensPage.waitUntilCardanoTokenLoaded();
await settingsExtendedPageObject.closeWalletSyncedToast();
});

Then(/^Lace is loaded properly$/, async () => {
await MainLoader.waitUntilLoaderDisappears();
await settingsExtendedPageObject.waitUntilSyncingModalDisappears();
await tokensPageObject.waitUntilCardanoTokenLoaded();
await TokensPage.waitUntilCardanoTokenLoaded();
});

Given(/^Lace with empty wallet is ready for test$/, async () => {
await tokensPageObject.waitUntilHeadersLoaded();
await TokensPage.waitUntilHeadersLoaded();
});

Then(/I navigate to home page on (popup|extended) view/, async (viewType: string) => {
await browser.pause(1000);
await (viewType === 'popup' ? popupView.visit() : extendedView.visit());
Expand Down

0 comments on commit 92eabfb

Please sign in to comment.