Skip to content

Commit

Permalink
test(extension): update and block tests due to LW-12193
Browse files Browse the repository at this point in the history
  • Loading branch information
wklos-iohk committed Jan 30, 2025
1 parent cfd6b7b commit 6c9367c
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ class MultidelegationPageAssert {
expect(await MultidelegationPage.delegationCardChartSlices.length).to.equal(poolsCount);
};

assertSeeDelegatedPoolCards = async () => {
assertSeeDelegatedPoolCards = async (hasRewards: boolean, isPopupView: boolean) => {
const poolsCount = Number(await MultidelegationPage.delegationCardPoolsValue.getText());
for (let i = 0; i < poolsCount; i++) {
await this.assertSeeDelegatedPoolDetailsInfo(i);
await this.assertSeeDelegatedPoolFundsInfo(i);
await this.assertSeeDelegatedPoolFundsInfo(i, hasRewards, isPopupView);
}
};

Expand Down Expand Up @@ -103,19 +103,41 @@ class MultidelegationPageAssert {
);
};

assertSeeDelegatedPoolFundsInfo = async (index: number) => {
expect(await MultidelegationPage.delegatedPoolStakedTitle(index).getText()).to.equal(
await t('overview.stakingInfoCard.totalStaked', 'staking')
assertSeeDelegatedPoolFundsInfo = async (index: number, hasRewards: boolean, isPopupView: boolean) => {
// Total staked
expect(await MultidelegationPage.delegatedPoolTotalStakedTitle(index).getText()).to.equal(
await t('overview.stakingInfoCard.totalStaked')
);
const stakedValueNumber = (await MultidelegationPage.delegatedPoolStakedValue(index).getText()).split('tADA')[0];
expect(stakedValueNumber).to.match(TestnetPatterns.NUMBER_DOUBLE_REGEX);
const totalStakedValueText = await MultidelegationPage.delegatedPoolTotalStakedValue(index).getText();
expect(totalStakedValueText).to.match(TestnetPatterns.ADA_LITERAL_VALUE_REGEX);
const totalStakedValue = Number(totalStakedValueText.split('\n')[0]);
hasRewards
? expect(totalStakedValue, 'Total staked not greater than 0!').to.be.greaterThan(0)
: expect(totalStakedValue, 'Total staked not equal to 0!').to.equal(0);

// Last reward
expect(await MultidelegationPage.delegatedPoolLastRewardsTitle(index).getText()).to.equal(
await t('overview.stakingInfoCard.lastReward', 'staking')
await t('overview.stakingInfoCard.lastReward')
);
const lastRewardsValueNumber = (await MultidelegationPage.delegatedPoolLastRewardsValue(index).getText()).split(
'tADA'
)[0];
expect(lastRewardsValueNumber).to.match(TestnetPatterns.NUMBER_DOUBLE_REGEX);
const lastRewardsValueText = await MultidelegationPage.delegatedPoolLastRewardsValue(index).getText();
expect(lastRewardsValueText).to.match(TestnetPatterns.ADA_LITERAL_VALUE_REGEX);
const lastRewardsValue = Number(lastRewardsValueText.split('\n')[0]);
hasRewards
? expect(lastRewardsValue, 'Last reward not greater than 0!').to.be.greaterThan(0)
: expect(lastRewardsValue, 'Last reward not equal to 0!').to.equal(0);

// Total rewards (extended view only!)
if (!isPopupView) {
expect(await MultidelegationPage.delegatedPoolTotalRewardsTitle(index).getText()).to.equal(
await t('overview.stakingInfoCard.totalRewards')
);
const totalRewardsValueText = await MultidelegationPage.delegatedPoolTotalRewardsValue(index).getText();
expect(totalRewardsValueText).to.match(TestnetPatterns.ADA_LITERAL_VALUE_REGEX);
const totalRewardsValue = Number(totalRewardsValueText.split('\n')[0]);
hasRewards
? expect(totalRewardsValue, 'Total reward not greater than 0!').to.be.greaterThan(0)
: expect(totalRewardsValue, 'Total rewards not equal to 0!').to.equal(0);
}
};

assertSeeStakingPoolOnYourPoolsList = async (poolName: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ class MultidelegationPage {
private DELEGATED_POOL_FEE_VALUE = '[data-testid="stats-fee-container"] [data-testid="stats-value"]';
private DELEGATED_POOL_MARGIN_TITLE = '[data-testid="stats-margin-container"] [data-testid="stats-title"]';
private DELEGATED_POOL_MARGIN_VALUE = '[data-testid="stats-margin-container"] [data-testid="stats-value"]';
private DELEGATED_POOL_STAKED_TITLE = '[data-testid="stats-total-staked-container"] [data-testid="stats-title"]';
private DELEGATED_POOL_STAKED_VALUE = '[data-testid="stats-total-staked-container"] [data-testid="stats-value"]';
private DELEGATED_POOL_TOTAL_STAKED_TITLE =
'[data-testid="stats-total-staked-container"] [data-testid="stats-title"]';
private DELEGATED_POOL_TOTAL_STAKED_VALUE =
'[data-testid="stats-total-staked-container"] [data-testid="stats-value"]';
private DELEGATED_POOL_TOTAL_REWARDS_TITLE =
'[data-testid="stats-total-rewards-container"] [data-testid="stats-title"]';
private DELEGATED_POOL_TOTAL_REWARDS_VALUE =
Expand Down Expand Up @@ -267,12 +269,12 @@ class MultidelegationPage {
return $$(this.DELEGATED_POOL_ITEM)[index].$(this.DELEGATED_POOL_MARGIN_VALUE);
}

delegatedPoolStakedTitle(index: number): ChainablePromiseElement<WebdriverIO.Element> {
return $$(this.DELEGATED_POOL_ITEM)[index].$(this.DELEGATED_POOL_STAKED_TITLE);
delegatedPoolTotalStakedTitle(index: number): ChainablePromiseElement<WebdriverIO.Element> {
return $$(this.DELEGATED_POOL_ITEM)[index].$(this.DELEGATED_POOL_TOTAL_STAKED_TITLE);
}

delegatedPoolStakedValue(index: number): ChainablePromiseElement<WebdriverIO.Element> {
return $$(this.DELEGATED_POOL_ITEM)[index].$(this.DELEGATED_POOL_STAKED_VALUE);
delegatedPoolTotalStakedValue(index: number): ChainablePromiseElement<WebdriverIO.Element> {
return $$(this.DELEGATED_POOL_ITEM)[index].$(this.DELEGATED_POOL_TOTAL_STAKED_VALUE);
}

delegatedPoolTotalRewardsTitle(index: number): ChainablePromiseElement<WebdriverIO.Element> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Feature: Staking Page - Delegated funds - Multiple pools - Extended View
Background:
Given Lace is ready for test

@LW-8432 @LW-8433
@LW-8432 @LW-8433 @Pending @issue=LW-12193
Scenario: Extended View - Staking - Delegation card displays correct data
When I navigate to Staking extended page
And I open Overview tab
Then I see Delegation card displaying correct data
And I see Delegation pool cards are displayed
And Delegation pool cards with rewards assigned are displayed in extended view

@LW-9447
Scenario: Extended-view - Staking - Manage staking only one pool is expanded by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Feature: Staking Page - Delegated funds - Multiple pools - Popup View
Then I see Delegation title displayed for multidelegation
And I see Delegation card displaying correct data

@LW-8338
@LW-8338 @Pending @issue=LW-12193
Scenario: Popup View - Delegated pools cards are present
When I navigate to Staking popup page
And I see Delegation pool cards are displayed
And Delegation pool cards with rewards assigned are displayed in popup view

@LW-8934 @LW-8472
Scenario: Popup View - Start Staking - Delegated to multiple pools - "Expanded view" button click
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ Feature: Staking Page - Delegated funds - Single pool - Extended View
| total rewards |
| last reward |

@LW-8432 @LW-8433
@LW-8432 @LW-8433 @Pending @issue=LW-12193
Scenario: Extended View - Staking - Delegation card displays correct data
When I navigate to Staking extended page
And I open Overview tab
Then I see Delegation card displaying correct data
And I see Delegation pool cards are displayed
And Delegation pool cards with rewards assigned are displayed in extended view

@LW-8636
Scenario: Extended View - Staking - Manage button works
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Feature: Staking Page - Delegated funds - Single pool - Popup View
Then I see Delegation title displayed for multidelegation
And I see Delegation card displaying correct data

@LW-8338
@LW-8338 @Pending @issue=LW-12193
Scenario: Popup View - Delegated pools cards are present
When I navigate to Staking popup page
And I see Delegation pool cards are displayed
And Delegation pool cards with rewards assigned are displayed in popup view

@LW-8480
Scenario Outline: Popup View - Staking - Hover over currently staking element: <element>
Expand Down
9 changes: 6 additions & 3 deletions packages/e2e-tests/src/steps/multidelegationSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ Then(/^I see Delegation title displayed for multidelegation$/, async () => {
await MultidelegationPageAssert.assertSeeTitle();
});

Then(/^I see Delegation pool cards are displayed$/, async () => {
await MultidelegationPageAssert.assertSeeDelegatedPoolCards();
});
Then(
/^Delegation pool cards (with|without) rewards assigned are displayed in (extended|popup) view$/,
async (shouldHaveRewards: 'with' | 'without', view: 'extended' | 'popup') => {
await MultidelegationPageAssert.assertSeeDelegatedPoolCards(shouldHaveRewards === 'with', view === 'popup');
}
);

When(/^I save identifiers of stake pools currently in use$/, async () => {
await MultidelegationPage.saveIDsOfStakePoolsInUse();
Expand Down

0 comments on commit 6c9367c

Please sign in to comment.