Skip to content

Commit 22242ed

Browse files
authored
test(extension): [LW-8650] add tests for LW-8450 and LW-8480 (#682)
1 parent b8119df commit 22242ed

13 files changed

+120
-123
lines changed

packages/e2e-tests/src/assert/multidelegation/MultidelegationPageAssert.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { t } from '../../utils/translationService';
55
import { TestnetPatterns } from '../../support/patterns';
66
import NetworkComponent from '../../elements/multidelegation/NetworkInfoComponent';
77
import { StakePoolListItem } from '../../elements/multidelegation/StakePoolListItem';
8+
import Tooltip from '../../elements/Tooltip';
89

910
class MultidelegationPageAssert {
1011
assertSeeStakingOnPoolsCounter = async (poolsCount: number) => {
@@ -209,6 +210,12 @@ class MultidelegationPageAssert {
209210
throw new Error(`Unsupported column name: ${columnName}`);
210211
}
211212
};
213+
214+
assertSeeCurrentlyStakingTooltip = async () => {
215+
await Tooltip.component.waitForDisplayed();
216+
expect(await Tooltip.label.getText()).contains(await t('overview.stakingInfoCard.tooltipFiatLabel', 'staking'));
217+
expect(await Tooltip.value.getText()).to.match(TestnetPatterns.USD_VALUE_NO_SUFFIX_REGEX); // TODO: update when LW-8935 is resolved
218+
};
212219
}
213220

214221
export default new MultidelegationPageAssert();

packages/e2e-tests/src/assert/stakingPageAssert.ts

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -62,73 +62,60 @@ class StakingPageAssert {
6262
expectedStakePool.ticker
6363
));
6464

65-
await expect(await webTester.getTextValueFromElement(stakingInfoComponent.statsApy().title())).to.equal(
65+
expect(await stakingInfoComponent.statsApy.title.getText()).to.equal(
6666
await t('browserView.staking.stakingInfo.stats.ros')
6767
);
6868
// TODO BUG LW-5635
6969
// await expect((await webTester.getTextValueFromElement(stakingInfoComponent.statsApy().value())) as string).to.match(
7070
// TestnetPatterns.PERCENT_DOUBLE_REGEX
7171
// );
7272

73-
await expect(await webTester.getTextValueFromElement(stakingInfoComponent.statsFee().title())).to.equal(
73+
expect(await stakingInfoComponent.statsFee.title.getText()).to.equal(
7474
await t('browserView.staking.stakingInfo.stats.Fee')
7575
);
76-
await expect((await webTester.getTextValueFromElement(stakingInfoComponent.statsFee().value())) as string).to.match(
77-
TestnetPatterns.ADA_LITERAL_VALUE_REGEX
78-
);
76+
expect(await stakingInfoComponent.statsFee.value.getText()).to.match(TestnetPatterns.ADA_LITERAL_VALUE_REGEX);
7977

80-
await expect(await webTester.getTextValueFromElement(stakingInfoComponent.statsMargin().title())).to.equal(
78+
expect(await stakingInfoComponent.statsMargin.title.getText()).to.equal(
8179
await t('browserView.staking.stakingInfo.stats.Margin')
8280
);
83-
await expect(
84-
(await webTester.getTextValueFromElement(stakingInfoComponent.statsMargin().value())) as string
85-
).to.match(TestnetPatterns.PERCENT_DOUBLE_REGEX);
81+
expect(await stakingInfoComponent.statsMargin.value.getText()).to.match(TestnetPatterns.PERCENT_DOUBLE_REGEX);
8682

8783
if (mode === 'extended') {
88-
await expect(await webTester.getTextValueFromElement(stakingInfoComponent.statsTotalRewards().title())).to.equal(
84+
expect(await stakingInfoComponent.statsTotalRewards.title.getText()).to.equal(
8985
await t('browserView.staking.stakingInfo.totalRewards.title')
9086
);
9187

92-
await expect(
93-
(await webTester.getTextValueFromElement(stakingInfoComponent.statsTotalRewards().value())) as string
94-
).to.match(TestnetPatterns.ADA_LITERAL_VALUE_REGEX_OR_0);
88+
expect(await stakingInfoComponent.statsTotalRewards.value.getText()).to.match(
89+
TestnetPatterns.ADA_LITERAL_VALUE_REGEX_OR_0
90+
);
9591
}
9692

97-
await expect(await webTester.getTextValueFromElement(stakingInfoComponent.statsTotalStaked().title())).to.equal(
93+
expect(await stakingInfoComponent.statsTotalStaked.title.getText()).to.equal(
9894
await t('browserView.staking.stakingInfo.totalStaked.title')
9995
);
100-
await expect(
101-
(await webTester.getTextValueFromElement(stakingInfoComponent.statsTotalStaked().value())) as string
102-
).to.match(TestnetPatterns.ADA_LITERAL_VALUE_REGEX);
96+
expect(await stakingInfoComponent.statsTotalStaked.value.getText()).to.match(
97+
TestnetPatterns.ADA_LITERAL_VALUE_REGEX
98+
);
10399

104-
await expect(await webTester.getTextValueFromElement(stakingInfoComponent.statsLastReward().title())).to.equal(
100+
expect(await stakingInfoComponent.statsLastReward.title.getText()).to.equal(
105101
await t('browserView.staking.stakingInfo.lastReward.title')
106102
);
107-
await expect(
108-
(await webTester.getTextValueFromElement(stakingInfoComponent.statsLastReward().value())) as string
109-
).to.match(TestnetPatterns.ADA_LITERAL_VALUE_REGEX);
110-
};
111-
112-
assertSeeCurrentlyStakingTooltip = async () => {
113-
const stakingInfoComponent = new StakingInfoComponent();
114-
await webTester.seeWebElement(stakingInfoComponent.tooltip());
115-
const tooltipText = (await webTester.getTextValueFromElement(stakingInfoComponent.tooltip())) as string;
116-
const expectedTitle = await t('browserView.staking.stakingInfo.tooltip.title');
117-
await expect(tooltipText).contains(expectedTitle);
118-
await expect(tooltipText.replace(expectedTitle, '') as string).to.match(TestnetPatterns.USD_VALUE_NO_SUFFIX_REGEX);
103+
expect(await stakingInfoComponent.statsLastReward.value.getText()).to.match(
104+
TestnetPatterns.ADA_LITERAL_VALUE_REGEX
105+
);
119106
};
120107

121108
assertStakingSuccessDrawer = async (process: 'Initial' | 'Switching', mode: 'extended' | 'popup') => {
122109
await StakingSuccessDrawer.drawerHeaderCloseButton.waitForDisplayed();
123110
if (mode === 'extended') {
124111
await StakingSuccessDrawer.drawerNavigationTitle.waitForDisplayed();
125-
await expect(await StakingSuccessDrawer.drawerNavigationTitle.getText()).to.equal(
112+
expect(await StakingSuccessDrawer.drawerNavigationTitle.getText()).to.equal(
126113
await t('browserView.staking.details.titleSecond')
127114
);
128115
}
129116
await StakingSuccessDrawer.resultIcon.waitForDisplayed();
130117
await StakingSuccessDrawer.resultTitle.waitForDisplayed();
131-
await expect(await StakingSuccessDrawer.resultTitle.getText()).to.equal(
118+
expect(await StakingSuccessDrawer.resultTitle.getText()).to.equal(
132119
process === 'Initial'
133120
? await t('browserView.staking.details.success.title')
134121
: await t('browserView.staking.details.switchedPools.title')
@@ -142,7 +129,7 @@ class StakingPageAssert {
142129
// );
143130

144131
await StakingSuccessDrawer.closeButton.waitForDisplayed();
145-
await expect(await StakingSuccessDrawer.closeButton.getText()).to.equal(await t('general.button.close'));
132+
expect(await StakingSuccessDrawer.closeButton.getText()).to.equal(await t('general.button.close'));
146133
};
147134

148135
assertSeeSingleSearchResult = async () => {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Tooltip {
2+
private TOOLTIP_COMPONENT = '[data-testid="tooltip"]';
3+
private TOOLTIP_LABEL = '[data-testid="tooltip-label"]';
4+
private TOOLTIP_VALUE = '[data-testid="tooltip-value"]';
5+
6+
get component() {
7+
return $(this.TOOLTIP_COMPONENT);
8+
}
9+
10+
get label() {
11+
return $(this.TOOLTIP_LABEL);
12+
}
13+
14+
get value() {
15+
return $(this.TOOLTIP_VALUE);
16+
}
17+
}
18+
19+
export default new Tooltip();

packages/e2e-tests/src/elements/staking/stakingInfoComponent.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { LocatorStrategy } from '../../actor/webTester';
21
import { WebElement, WebElementFactory as Factory } from './../webElement';
32
import { StatsComponent } from './statsComponent';
43

@@ -14,7 +13,6 @@ export class StakingInfoComponent extends WebElement {
1413
private STATS_LAST_REWARD_CONTAINER = '//div[@data-testid="stats-last-reward-container"]';
1514
private STATS_TOTAL_STAKED_CONTAINER = '//div[@data-testid="stats-total-staked-container"]';
1615
private STATS_TOTAL_REWARDS_CONTAINER = '//div[@data-testid="stats-total-rewards-container"]';
17-
private TOOLTIP = '//div[@data-testid="tooltip"]';
1816

1917
constructor() {
2018
super();
@@ -40,35 +38,42 @@ export class StakingInfoComponent extends WebElement {
4038
return Factory.fromSelector(`${this.CONTAINER}${this.POOL_TICKER}`, 'xpath');
4139
}
4240

43-
statsApy(): StatsComponent {
41+
get statsApy(): StatsComponent {
4442
return new StatsComponent(this.STATS_APY_CONTAINER);
4543
}
4644

47-
statsFee(): StatsComponent {
45+
get statsFee(): StatsComponent {
4846
return new StatsComponent(this.STATS_FEE_CONTAINER);
4947
}
5048

51-
statsMargin(): StatsComponent {
49+
get statsMargin(): StatsComponent {
5250
return new StatsComponent(this.STATS_MARGIN_CONTAINER);
5351
}
5452

55-
statsTotalStaked(): StatsComponent {
53+
get statsTotalStaked(): StatsComponent {
5654
return new StatsComponent(this.STATS_TOTAL_STAKED_CONTAINER);
5755
}
5856

59-
statsLastReward(): StatsComponent {
57+
get statsLastReward(): StatsComponent {
6058
return new StatsComponent(this.STATS_LAST_REWARD_CONTAINER);
6159
}
6260

63-
statsTotalRewards(): StatsComponent {
61+
get statsTotalRewards(): StatsComponent {
6462
return new StatsComponent(this.STATS_TOTAL_REWARDS_CONTAINER);
6563
}
6664

67-
tooltip(): WebElement {
68-
return Factory.fromSelector(`${this.TOOLTIP}`, 'xpath');
65+
async hoverOverTotalStakedValue(): Promise<void> {
66+
await this.statsTotalStaked.value.scrollIntoView();
67+
await this.statsTotalStaked.value.moveTo();
6968
}
7069

71-
locatorStrategy(): LocatorStrategy {
72-
return 'xpath';
70+
async hoverOverTotalRewardsValue(): Promise<void> {
71+
await this.statsTotalRewards.value.scrollIntoView();
72+
await this.statsTotalRewards.value.moveTo();
73+
}
74+
75+
async hoverOverLastRewardValue(): Promise<void> {
76+
await this.statsLastReward.value.scrollIntoView();
77+
await this.statsLastReward.value.moveTo();
7378
}
7479
}
Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
1-
import webTester, { LocatorStrategy } from '../../actor/webTester';
2-
import { WebElement, WebElementFactory as Factory } from './../webElement';
3-
4-
export class StatsComponent extends WebElement {
1+
/* eslint-disable no-undef*/
2+
export class StatsComponent {
53
protected CONTAINER;
64
private TITLE = '//div[@data-testid="stats-title"]';
75
private VALUE = '//div[@data-testid="stats-value"]';
86

97
constructor(containerSelector: string) {
10-
super();
118
this.CONTAINER = containerSelector;
129
}
1310

14-
container(): WebElement {
15-
return Factory.fromSelector(`${this.CONTAINER}`, 'xpath');
16-
}
17-
18-
title(): WebElement {
19-
return Factory.fromSelector(`${this.CONTAINER}${this.TITLE}`, 'xpath');
20-
}
21-
22-
value(): WebElement {
23-
return Factory.fromSelector(`${this.CONTAINER}${this.VALUE}`, 'xpath');
24-
}
25-
26-
async getTitle(): Promise<string | number> {
27-
return await webTester.getTextValueFromElement(this.title());
11+
get container(): ChainablePromiseElement {
12+
return $(this.CONTAINER);
2813
}
2914

30-
async getValue(): Promise<string | number> {
31-
return await webTester.getTextValueFromElement(this.value());
15+
get title(): ChainablePromiseElement {
16+
return $(`${this.CONTAINER}${this.TITLE}`);
3217
}
3318

34-
locatorStrategy(): LocatorStrategy {
35-
return 'xpath';
19+
get value(): ChainablePromiseElement {
20+
return $(`${this.CONTAINER}${this.VALUE}`);
3621
}
3722
}

packages/e2e-tests/src/features/MultidelegationDelegatedFundsExtended.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,15 @@ Feature: Staking Page - Extended View
2525
| confirmation | I click outside the drawer |
2626
| password | I click outside the drawer |
2727
| success | I click outside the drawer |
28+
29+
@LW-8450
30+
Scenario Outline: Extended View - Staking - Hover over currently staking element: <element>
31+
Given I disable showing Multidelegation beta banner
32+
And I navigate to Staking extended page
33+
When I hover over <element> in currently staking component
34+
Then I see tooltip for element in currently staking component
35+
Examples:
36+
| element |
37+
| total staked |
38+
| total rewards |
39+
| last reward |

packages/e2e-tests/src/features/MultidelegationDelegatedFundsPopup.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@ Feature: Staking Page - Popup View
2323
| walletName |
2424
| MultidelegationDelegatedSingle |
2525
| MultidelegationDelegatedMulti |
26+
27+
@LW-8480
28+
Scenario Outline: Popup View - Staking - Hover over currently staking element: <element>
29+
Given I disable showing Multidelegation beta banner
30+
And I navigate to Staking popup page
31+
When I hover over <element> in currently staking component
32+
Then I see tooltip for element in currently staking component
33+
Examples:
34+
| element |
35+
| total staked |
36+
| last reward |

packages/e2e-tests/src/features/StakingPageDelegatedFundsExtended.feature

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@ Feature: Staking Page - Funds already delegated - Extended Browser View
1515
When I click pool name in currently staking component
1616
Then I see drawer with "ADA CAPITAL" stake pool details
1717

18-
@LW-2644
19-
Scenario Outline: Extended View - Staking - Hover over currently staking element: <element_to_hover>
20-
And I navigate to Staking extended page
21-
When I hover over <element_to_hover> in currently staking component
22-
Then I see tooltip for currently staking component
23-
Examples:
24-
| element_to_hover |
25-
| last reward |
26-
| total staked |
27-
| total rewards |
28-
2918
@LW-4877
3019
Scenario: Extended View - Stake pool details - Enter and Escape buttons support
3120
Given I am on Staking extended page

packages/e2e-tests/src/features/StakingPageDelegatedFundsPopup.feature

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,3 @@ Feature: Staking Page - Funds already delegated - Popup View
1515
When I click pool name in currently staking component
1616
Then I see drawer with "ADA Capital" stake pool details
1717

18-
@LW-2654
19-
Scenario Outline: Popup View - Staking - Hover over currently staking element: <element_to_hover>
20-
And I navigate to Staking popup page
21-
When I hover over <element_to_hover> in currently staking component
22-
Then I see tooltip for currently staking component
23-
Examples:
24-
| element_to_hover |
25-
| total staked |
26-
| last reward |

packages/e2e-tests/src/pageobject/stakingPageObject.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ class StakingPageObject {
2323
await webTester.clickElement(new StakingInfoComponent().poolName());
2424
}
2525

26-
async hoverLastRewardInStakingInfoComponent() {
27-
await webTester.hoverOnWebElement(new StakingInfoComponent().statsLastReward().value());
28-
}
29-
30-
async hoverTotalStakedInStakingInfoComponent() {
31-
await webTester.hoverOnWebElement(new StakingInfoComponent().statsTotalStaked().value());
32-
}
33-
34-
async hoverTotalRewardsInStakingInfoComponent() {
35-
await webTester.hoverOnWebElement(new StakingInfoComponent().statsTotalRewards().value());
36-
}
37-
3826
async getPoolIdFromStakePoolDetails(mode: 'extended' | 'popup') {
3927
await this.clickPoolNameInStakingInfoComponent();
4028
await StakePoolDetails.poolId.waitForDisplayed();

0 commit comments

Comments
 (0)