Skip to content

Commit

Permalink
test(extension): cleanup staking-related code (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
wklos-iohk authored Jul 15, 2024
1 parent 29e9e84 commit 2d78c77
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 329 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import StakingErrorDrawer from '../../elements/multidelegation/StakingErrorDrawer';
import { expect } from 'chai';
import { t } from '../../utils/translationService';

class StakingErrorDrawerAssert {
assertSeeStakingError = async () => {
await StakingErrorDrawer.icon.waitForDisplayed();
await StakingErrorDrawer.title.waitForDisplayed();
expect(await StakingErrorDrawer.title.getText()).to.equal(await t('browserView.staking.details.fail.title'));
await StakingErrorDrawer.description.waitForDisplayed();
expect(await StakingErrorDrawer.description.getText()).to.equal(
await t('browserView.staking.details.fail.description')
);
await StakingErrorDrawer.retryButton.waitForDisplayed();
expect(await StakingErrorDrawer.retryButton.getText()).to.equal(
await t('browserView.staking.details.fail.btn.retry')
);
await StakingErrorDrawer.closeButton.waitForDisplayed();
expect(await StakingErrorDrawer.closeButton.getText()).to.equal(
await t('browserView.staking.details.fail.btn.close')
);
};
}

export default new StakingErrorDrawerAssert();
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { t } from '../utils/translationService';
import StakingExitModal from '../elements/staking/StakingExitModal';
import { t } from '../../utils/translationService';
import StakingExitModal from '../../elements/multidelegation/StakingExitModal';

class StakingExitModalAssert {
assertSeeStakingExitModal = async () => {
Expand Down
70 changes: 0 additions & 70 deletions packages/e2e-tests/src/assert/stakingPageAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import StakingPage from '../elements/staking/stakingPage';
import { TestnetPatterns } from '../support/patterns';
import StakingInfoComponent from '../elements/staking/stakingInfoComponent';
import { t } from '../utils/translationService';
import StakingSuccessDrawer from '../elements/staking/StakingSuccessDrawer';
import { expect } from 'chai';
import { StakePool } from '../data/expectedStakePoolsData';
import StakingPasswordDrawer from '../elements/staking/StakingPasswordDrawer';
import StakingErrorDrawer from '../elements/staking/StakingErrorDrawer';
import { browser } from '@wdio/globals';

class StakingPageAssert {
Expand Down Expand Up @@ -72,80 +69,13 @@ class StakingPageAssert {
);
};

assertStakingSuccessDrawer = async (process: 'Initial' | 'Switching', mode: 'extended' | 'popup') => {
await StakingSuccessDrawer.drawerHeaderCloseButton.waitForDisplayed();
if (mode === 'extended') {
await StakingSuccessDrawer.drawerNavigationTitle.waitForDisplayed();
expect(await StakingSuccessDrawer.drawerNavigationTitle.getText()).to.equal(
await t('browserView.staking.details.titleSecond')
);
}
await StakingSuccessDrawer.resultIcon.waitForDisplayed();
await StakingSuccessDrawer.resultTitle.waitForDisplayed();
expect(await StakingSuccessDrawer.resultTitle.getText()).to.equal(
process === 'Initial'
? await t('browserView.staking.details.success.title')
: await t('browserView.staking.details.switchedPools.title')
);
await StakingSuccessDrawer.resultSubtitle.waitForDisplayed();
expect(await StakingSuccessDrawer.resultSubtitle.getText()).to.equal(
process === 'Initial'
? await t('browserView.staking.details.success.subTitle')
: await t('browserView.staking.details.switchedPools.subTitle')
);

await StakingSuccessDrawer.closeButton.waitForDisplayed();
expect(await StakingSuccessDrawer.closeButton.getText()).to.equal(await t('general.button.close'));
};

assertSeeSingleSearchResult = async () => {
await browser.waitUntil(async () => (await StakingPage.counter.getText()) === '(1)', {
timeout: 20_000,
timeoutMsg: 'failed while waiting for single search result'
});
};

assertSeeStakingPasswordDrawer = async () => {
await StakingPasswordDrawer.title.waitForDisplayed();
expect(await StakingPasswordDrawer.title.getText()).to.equal(
await t('browserView.staking.details.confirmation.title')
);
await StakingPasswordDrawer.subtitle.waitForDisplayed();
expect(await StakingPasswordDrawer.subtitle.getText()).to.equal(
await t('browserView.transaction.send.enterWalletPasswordToConfirmTransaction')
);
await StakingPasswordDrawer.passwordInputContainer.waitForDisplayed();
await StakingPasswordDrawer.confirmButton.waitForDisplayed();
expect(await StakingPasswordDrawer.confirmButton.getText()).to.equal(await t('general.button.confirm'));
};

assertSeeStakingError = async () => {
await StakingErrorDrawer.icon.waitForDisplayed();
await StakingErrorDrawer.title.waitForDisplayed();
expect(await StakingErrorDrawer.title.getText()).to.equal(await t('browserView.staking.details.fail.title'));
await StakingErrorDrawer.description.waitForDisplayed();
expect(await StakingErrorDrawer.description.getText()).to.equal(
await t('browserView.staking.details.fail.description')
);
await StakingErrorDrawer.retryButton.waitForDisplayed();
expect(await StakingErrorDrawer.retryButton.getText()).to.equal(
await t('browserView.staking.details.fail.btn.retry')
);
await StakingErrorDrawer.closeButton.waitForDisplayed();
expect(await StakingErrorDrawer.closeButton.getText()).to.equal(
await t('browserView.staking.details.fail.btn.close')
);
};

async assertSeeTickerInCostColumn(expectedTicker: 'ADA' | 'tADA') {
const regex = expectedTicker === 'ADA' ? /[^t]ADA/g : /tADA/g;

const tickerList = await StakingPage.stakePoolListCostList.map(async (stakePoolListCost) =>
String(((await stakePoolListCost.getText()) as string).match(regex))
);
this.assertTickerInList(expectedTicker, tickerList);
}

async assertSeeTickerInCurrentStakedPool(expectedTicker: 'ADA' | 'tADA') {
const regex = expectedTicker === 'ADA' ? /[^t]ADA/g : /tADA/g;

Expand Down
102 changes: 51 additions & 51 deletions packages/e2e-tests/src/elements/multidelegation/MultidelegationPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import MultidelegationPageAssert from '../../assert/multidelegation/Multidelegat
import { browser } from '@wdio/globals';
import { clearInputFieldValue } from '../../utils/inputFieldUtils';
import { ChainablePromiseElement } from 'webdriverio';
import StakePoolDetails from '../staking/stakePoolDetails';
import testContext from '../../utils/testContext';
import { isPopupMode } from '../../utils/pageUtils';
import CommonDrawerElements from '../CommonDrawerElements';
Expand All @@ -14,6 +13,7 @@ import StakePoolDetailsDrawer from './StakePoolDetailsDrawer';
import MoreOptionsComponent from './MoreOptionsComponent';
import { StakePoolListColumn } from '../../enums/StakePoolListColumn';
import { StakePoolSortingOption } from '../../enums/StakePoolSortingOption';
import { ChainablePromiseArray } from 'webdriverio/build/types';

class MultidelegationPage {
private ACTIVITY_TAB = '[data-testid="activity-tab"]';
Expand Down Expand Up @@ -79,155 +79,155 @@ class MultidelegationPage {
private POOLS_COUNTER = '[data-testid="pools-counter"]';
private POOL_CARD = '[data-testid="stake-pool-card"]';

get title() {
get title(): ChainablePromiseElement<WebdriverIO.Element> {
return SectionTitle.sectionTitle;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

get delegationCardChartSlices() {
get delegationCardChartSlices(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $$(this.DELEGATION_CARD_CHART_PIE_SLICE);
}

get delegatedPoolItems() {
get delegatedPoolItems(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $$(this.DELEGATED_POOL_ITEM);
}

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

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

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

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

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

get displayedPools() {
get displayedPools(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $(this.STAKE_POOL_LIST_SCROLL_WRAPPER).$$(this.POOL_ITEM);
}

get displayedCards() {
get displayedCards(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $(this.STAKE_POOL_LIST_SCROLL_WRAPPER).$$(this.POOL_CARD);
}

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

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

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

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

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

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

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

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

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

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

get stakingPoolInfoItems() {
get stakingPoolInfoItems(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $$(this.STAKING_POOL_INFO);
}

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

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

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

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

Expand Down Expand Up @@ -291,19 +291,19 @@ class MultidelegationPage {
return $$(this.DELEGATED_POOL_ITEM)[index].$(this.DELEGATED_POOL_LAST_REWARDS_VALUE);
}

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

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

get selectedPoolsInGridView() {
get selectedPoolsInGridView(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $$(this.SELECTED_STAKE_POOLS_IN_GRID_VIEW);
}

get selectedPoolsInListView() {
get selectedPoolsInListView(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $$(this.SELECTED_STAKE_POOLS_IN_LIST_VIEW);
}

Expand Down Expand Up @@ -450,14 +450,14 @@ class MultidelegationPage {
const stakingPoolInfoItems = await this.stakingPoolInfoItems;
for (const stakingPoolInfoItem of stakingPoolInfoItems) {
await stakingPoolInfoItem.click();
await StakePoolDetails.container.waitForDisplayed();
await StakePoolDetails.container.waitForStable();
await StakePoolDetails.poolId.waitForDisplayed();
await StakePoolDetails.poolName.waitForDisplayed();
await StakePoolDetails.poolTicker.waitForDisplayed();
const poolId = await StakePoolDetails.poolId.getText();
const poolName = await StakePoolDetails.poolName.getText();
const poolTicker = await StakePoolDetails.poolTicker.getText();
await StakePoolDetailsDrawer.container.waitForDisplayed();
await StakePoolDetailsDrawer.container.waitForStable();
await StakePoolDetailsDrawer.poolId.waitForDisplayed();
await StakePoolDetailsDrawer.poolName.waitForDisplayed();
await StakePoolDetailsDrawer.poolTicker.waitForDisplayed();
const poolId = await StakePoolDetailsDrawer.poolId.getText();
const poolName = await StakePoolDetailsDrawer.poolName.getText();
const poolTicker = await StakePoolDetailsDrawer.poolTicker.getText();
const poolData = { poolId, poolName, poolTicker };
poolDataToBeSaved.push(poolData);
(await isPopupMode())
Expand Down
Loading

0 comments on commit 2d78c77

Please sign in to comment.