Skip to content

Commit

Permalink
Merge branch 'main' into fix/LW-10242-drawer-to-stay-closed-on-enter
Browse files Browse the repository at this point in the history
  • Loading branch information
VanessaPC authored Apr 19, 2024
2 parents f8337aa + 2bb331d commit 7f5c122
Show file tree
Hide file tree
Showing 32 changed files with 512 additions and 528 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/ui/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export interface LoaderProps {
}

export const Loader = ({ className }: LoaderProps): React.ReactElement => (
<img src={LoaderIcon} className={cn(styles.loader, { [className]: className })} />
<img src={LoaderIcon} className={cn(styles.loader, { [className]: className })} data-testid="loader-image" />
);
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export const WalletSetupConnectHardwareWalletStepRevamp = ({
)}
{state === 'error' && (
<>
<img src={ExclamationCircleIcon} className={styles.errorImage} alt="hardware wallet connection error image" />
<img
src={ExclamationCircleIcon}
className={styles.errorImage}
alt="hardware wallet connection error image"
data-testid="error-image"
/>
<Banner message={translations.errorMessage} />
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { StakePoolListItem } from '../../elements/multidelegation/StakePoolListI
import Tooltip from '../../elements/Tooltip';
import testContext from '../../utils/testContext';
import { StakePoolGridCard } from '../../elements/multidelegation/StakePoolGridCard';
import { StakePoolListColumnName } from '../../types/staking';
import { SortingOrder } from '../../types/sortingOrder';
import { mapColumnNameStringToEnum, sortColumnContent } from '../../utils/stakePoolListContent';
import { StakePoolListColumn } from '../../enums/StakePoolListColumn';

class MultidelegationPageAssert {
assertSeeStakingOnPoolsCounter = async (poolsCount: number) => {
Expand Down Expand Up @@ -188,36 +192,37 @@ class MultidelegationPageAssert {
expect(await firstStakePool.ticker.getText()).to.equal(expectedTicker);
};

assertSeeTooltipForColumn = async (columnName: string) => {
assertSeeTooltipForColumn = async (column: StakePoolListColumn) => {
await MultidelegationPage.tooltip.waitForStable();
await MultidelegationPage.tooltip.waitForDisplayed();
let expectedTooltipText;
switch (columnName) {
case 'Ticker':
switch (column) {
case StakePoolListColumn.Ticker:
expectedTooltipText = await t('browsePools.tooltips.ticker', 'staking');
break;
case 'Saturation':
case StakePoolListColumn.Saturation:
expectedTooltipText = await t('browsePools.tooltips.saturation', 'staking');
break;
case 'ROS':
case StakePoolListColumn.ROS:
expectedTooltipText = await t('browsePools.tooltips.ros', 'staking');
break;
case 'Cost':
case StakePoolListColumn.Cost:
expectedTooltipText = await t('browsePools.tooltips.cost', 'staking');
break;
case 'Margin':
case StakePoolListColumn.Margin:
expectedTooltipText = await t('browsePools.tooltips.margin', 'staking');
break;
case 'Blocks':
case StakePoolListColumn.Blocks:
expectedTooltipText = await t('browsePools.tooltips.blocks', 'staking');
break;
case 'Pledge':
case StakePoolListColumn.Pledge:
expectedTooltipText = await t('browsePools.tooltips.pledge', 'staking');
break;
case 'Live Stake':
case StakePoolListColumn.LiveStake:
expectedTooltipText = await t('browsePools.tooltips.liveStake', 'staking');
break;
default:
throw new Error(`Unsupported column name: ${columnName}`);
throw new Error(`Unsupported column name: ${column}`);
}
expect(await MultidelegationPage.tooltip.getText()).to.equal(expectedTooltipText);
};
Expand Down Expand Up @@ -300,6 +305,39 @@ class MultidelegationPageAssert {
const cardsInARow = Math.floor(rowWidth / cardWidth);
expect(cardsInARow).to.equal(expectedCardsCount);
};

assertSeeColumnSortingIndicator = async (column: StakePoolListColumnName, order: 'ascending' | 'descending') => {
await (
await MultidelegationPage.getColumnSortingIndicator(mapColumnNameStringToEnum(column), order)
).waitForDisplayed();
};

assertSeeStakePoolsSorted = async (
stakePoolsDisplayType: 'list rows' | 'cards',
sortingOption: StakePoolListColumnName,
order: SortingOrder,
poolLimit?: number
) => {
await MultidelegationPage.waitForPoolsCounterToBeGreaterThanZero();
poolLimit ??= await MultidelegationPage.getNumberOfPoolsFromCounter();
if (stakePoolsDisplayType === 'cards') {
// TODO: add code to handle grid cards - LW-10284
throw new Error('Please add validation for grid cards sorting');
} else {
const columnContent = await MultidelegationPage.extractColumnContent(
mapColumnNameStringToEnum(sortingOption),
poolLimit
);
const sortedColumnContent = await sortColumnContent(
columnContent,
mapColumnNameStringToEnum(sortingOption),
order
);

expect(columnContent).to.not.be.empty;
expect(columnContent).to.deep.equal(sortedColumnContent);
}
};
}

export default new MultidelegationPageAssert();
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import ConnectYourDevicePage from '../../elements/onboarding/ConnectYourDevicePage';
import { t } from '../../utils/translationService';
import { expect } from 'chai';
import OnboardingCommonAssert from './onboardingCommonAssert';

class ConnectYourDevicePageAssert extends OnboardingCommonAssert {
async assertSeeConnectYourDevicePage() {
await this.assertSeeStepTitle(await t('core.walletSetupConnectHardwareWalletStepRevamp.title'));
// TODO: replace subtitle assertions when USE_TREZOR_HW=true
// await this.assertSeeStepSubtitle(await t('core.walletSetupConnectHardwareWalletStepRevamp.subTitle'));
await this.assertSeeStepSubtitle(await t('core.walletSetupConnectHardwareWalletStepRevamp.subTitleLedgerOnly'));

await ConnectYourDevicePage.loader.waitForDisplayed();

await this.assertSeeBackButton();
await this.assertSeeTryAgainButton(false);

await this.assertSeeLegalLinks();
await this.assertSeeHelpAndSupportButton();
}

async assertSeeError(expectedErrorMessage: string) {
await ConnectYourDevicePage.errorImage.waitForDisplayed();
await ConnectYourDevicePage.banner.container.waitForDisplayed();
expect(await ConnectYourDevicePage.banner.description.getText()).to.equal(expectedErrorMessage);
}

async assertSeeTryAgainButton(shouldBeVisible: boolean) {
await ConnectYourDevicePage.tryAgainButton.waitForDisplayed({ reverse: !shouldBeVisible });
if (shouldBeVisible) {
expect(await ConnectYourDevicePage.tryAgainButton.getText()).to.equal(
await t('core.walletSetupConnectHardwareWalletStepRevamp.errorCta')
);
}
}

async assertSeeTryAgainButtonEnabled(shouldBeEnabled: boolean) {
await ConnectYourDevicePage.tryAgainButton.waitForEnabled({ reverse: !shouldBeEnabled });
}
}

export default new ConnectYourDevicePageAssert();

This file was deleted.

17 changes: 0 additions & 17 deletions packages/e2e-tests/src/assert/stakingPageAssert.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import StakingPage from '../elements/staking/stakingPage';
import { TestnetPatterns } from '../support/patterns';
import webTester from '../actor/webTester';
import StakingInfoComponent from '../elements/staking/stakingInfoComponent';
import { t } from '../utils/translationService';
import { StakePoolListItem } from '../elements/staking/StakePoolListItem';
import StakingSuccessDrawer from '../elements/staking/StakingSuccessDrawer';
import { Logger } from '../support/logger';
import StakingExtendedPageObject from '../pageobject/stakingExtendedPageObject';
import { sortColumnContent } from '../utils/stakePoolListContent';
import { expect } from 'chai';
import { StakePool } from '../data/expectedStakePoolsData';
import StakingPasswordDrawer from '../elements/staking/StakingPasswordDrawer';
Expand Down Expand Up @@ -114,18 +109,6 @@ class StakingPageAssert {
});
};

assertStakePoolItemsOrder = async (columnName: string, order: string) => {
const stakePoolListItem = new StakePoolListItem();
await webTester.waitUntilSeeElement(stakePoolListItem.container(), 60_000);
const columnContent: string[] = await StakingExtendedPageObject.extractColumnContent(columnName);
Logger.log(`EXTRACTED DATA: ${columnContent}`);
const sortedColumnContent = await sortColumnContent(columnContent, columnName, order);
Logger.log(`SORTED DATA: ${sortedColumnContent}`);

expect(columnContent).to.not.be.empty;
expect(columnContent).to.deep.equal(sortedColumnContent);
};

assertSeeStakingPasswordDrawer = async () => {
await StakingPasswordDrawer.title.waitForDisplayed();
expect(await StakingPasswordDrawer.title.getText()).to.equal(
Expand Down
Loading

0 comments on commit 7f5c122

Please sign in to comment.