Skip to content

Commit 222f8d4

Browse files
committed
test(extension): add tests for Voting Center
1 parent 71afab0 commit 222f8d4

File tree

19 files changed

+244
-32
lines changed

19 files changed

+244
-32
lines changed

apps/browser-extension-wallet/src/views/browser-view/features/voting-beta/components/VotingCenterBanner/VotingCenterBanner.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export const VotingCenterBanner = ({ popupView, openExternalLink, govToolUrl }:
1818
const btnWidth = popupView ? '$fill' : '$auto';
1919

2020
return (
21-
<div className={cn(styles.container, { [styles.popupView!]: popupView })} data-testid="register-as-drep-banner">
21+
<div className={cn(styles.container, { [styles.popupView!]: popupView })} data-testid="voting-center-banner">
2222
<img className={styles.bg} src={popupView ? bgPopup : BG} />
2323
<Flex flexDirection="column" justifyContent="center" className={styles.content}>
24-
<div className={styles.title} data-testid="register-as-drep-banner-title">
24+
<div className={styles.title} data-testid="voting-center-banner-title">
2525
{t('browserView.voting-beta.modal.title')}
2626
</div>
27-
<div className={styles.description} data-testid="register-as-drep-banner-description">
27+
<div className={styles.description} data-testid="voting-center-banner-description">
2828
{!popupView ? (
2929
t('browserView.voting-beta.modal.description')
3030
) : (
@@ -40,7 +40,7 @@ export const VotingCenterBanner = ({ popupView, openExternalLink, govToolUrl }:
4040
<Button.CallToAction
4141
w={btnWidth}
4242
onClick={() => openExternalLink(govToolUrl)}
43-
data-testid="register-now-at-gov-tool-button"
43+
data-testid="voting-center-gov-tool-button"
4444
label={t('browserView.voting-beta.modal.cta')}
4545
/>
4646
</Box>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import VotingCenterPage from '../elements/VotingCenterPage';
2+
import { expect } from 'chai';
3+
import { t } from '../utils/translationService';
4+
import { isPopupMode } from '../utils/pageUtils';
5+
6+
class VotingCenterPageAssert {
7+
async assertSeeVotingCenterBanner() {
8+
await VotingCenterPage.banner.waitForDisplayed();
9+
await VotingCenterPage.title.waitForDisplayed();
10+
expect(await VotingCenterPage.title.getText()).to.be.eq(await t('browserView.voting-beta.modal.title'));
11+
await VotingCenterPage.description.waitForDisplayed();
12+
const expectedDescriptionKey = (await isPopupMode())
13+
? 'browserView.voting-beta.modal.description-popup'
14+
: 'browserView.voting-beta.modal.description';
15+
const expectedDescription = (await t(expectedDescriptionKey)).replaceAll('<br /><br />', '\n\n');
16+
expect(await VotingCenterPage.description.getProperty('innerText')).to.be.eq(expectedDescription);
17+
await VotingCenterPage.govToolButton.waitForClickable();
18+
expect(await VotingCenterPage.govToolButton.getText()).to.be.eq(await t('browserView.voting-beta.modal.cta'));
19+
}
20+
}
21+
22+
export default new VotingCenterPageAssert();

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ class CommonAssert {
3737
Activity: '/activity',
3838
Staking: '/staking',
3939
'Address Book': '/address-book',
40-
Settings: '/settings'
40+
Settings: '/settings',
41+
Voting: '/voting',
42+
DApps: '/dapp-explorer'
4143
};
4244

4345
const pagePath = pagePathMap[expectedPage];

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,32 @@ class EducationalListAssert {
9999
await this.assertSeeWidget(expectedTitle, expectedTitles, expectedSubtitles);
100100
}
101101

102+
async assertSeeVotingWidget() {
103+
const faqTranslation = await t(this.faqTranslationPath);
104+
const glossaryTranslation = await t(this.glossaryTranslationPath);
105+
const videoTranslation = await t(this.videoTranslationPath);
106+
const expectedTitle = await t('browserView.sidePanel.learnAbout');
107+
const expectedTitles = [
108+
glossaryTranslation,
109+
faqTranslation,
110+
videoTranslation,
111+
videoTranslation,
112+
faqTranslation,
113+
faqTranslation,
114+
faqTranslation
115+
];
116+
const expectedSubtitles = [
117+
await t('educationalBanners.subtitle.whatIsADigitalAsset'),
118+
await t('educationalBanners.subtitle.howToSendReceiveFunds'),
119+
await t('educationalBanners.subtitle.secureSelfCustody'),
120+
await t('educationalBanners.subtitle.connectingDApps'),
121+
await t('educationalBanners.subtitle.conwayEra'),
122+
await t('educationalBanners.subtitle.governanceFeatures'),
123+
await t('educationalBanners.subtitle.governanceActions')
124+
];
125+
await this.assertSeeWidget(expectedTitle, expectedTitles, expectedSubtitles);
126+
}
127+
102128
async assertSeeGlossaryArticle(title: string) {
103129
const glossaryArticle = glossaryArticles[title];
104130
const expectedPath = `glossary?term=${glossaryArticle.term}`;

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,25 @@ class MenuMainPopupPageAssert {
3131
: MenuMainExtended.stakingButton.waitForDisplayed());
3232
}
3333

34+
async assertSeeVotingButton(mode: 'popup' | 'extended') {
35+
await (mode === 'popup'
36+
? MenuMainPopup.votingButton.waitForDisplayed()
37+
: MenuMainExtended.votingButton.waitForDisplayed());
38+
}
39+
40+
async assertSeeDAppsButton(mode: 'popup' | 'extended') {
41+
await (mode === 'popup'
42+
? MenuMainPopup.dappsButton.waitForDisplayed()
43+
: MenuMainExtended.dappsButton.waitForDisplayed());
44+
}
45+
3446
async assertSeeMainMenu(mode: 'popup' | 'extended') {
3547
await this.assertSeeTokensButton(mode);
3648
await this.assertSeeNftsButton(mode);
3749
await this.assertSeeTransactionsButton(mode);
3850
await this.assertSeeStakingButton(mode);
51+
await this.assertSeeVotingButton(mode);
52+
await this.assertSeeDAppsButton(mode);
3953
}
4054

4155
async assertSeeIconAndTextForEachMenuItemExtended() {
@@ -52,6 +66,12 @@ class MenuMainPopupPageAssert {
5266

5367
await MenuMainExtended.getIcon(MenuMainExtended.stakingButton).waitForDisplayed();
5468
expect(await MenuMainExtended.stakingButton.getText()).to.equal(await t('browserView.sideMenu.links.staking'));
69+
70+
await MenuMainExtended.getIcon(MenuMainExtended.votingButton).waitForDisplayed();
71+
expect(await MenuMainExtended.votingButton.getText()).to.equal(await t('browserView.sideMenu.links.voting'));
72+
73+
await MenuMainExtended.getIcon(MenuMainExtended.dappsButton).waitForDisplayed();
74+
expect(await MenuMainExtended.dappsButton.getText()).to.equal(await t('browserView.sideMenu.links.dappExplorer'));
5575
}
5676

5777
async assertAddressIsNotEqual(wallet = TestWalletName.TestAutomationWallet) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* global WebdriverIO */
2+
import type { ChainablePromiseElement } from 'webdriverio';
3+
4+
class VotingCenterPage {
5+
private readonly BANNER = '[data-testid="voting-center-banner"]';
6+
private readonly TITLE = '[data-testid="voting-center-banner-title"]';
7+
private readonly DESCRIPTION = '[data-testid="voting-center-banner-description"]';
8+
private readonly GOV_TOOL_BUTTON = '[data-testid="voting-center-gov-tool-button"]';
9+
10+
get banner(): ChainablePromiseElement<WebdriverIO.Element> {
11+
return $(this.BANNER);
12+
}
13+
14+
get title(): ChainablePromiseElement<WebdriverIO.Element> {
15+
return $(this.TITLE);
16+
}
17+
18+
get description(): ChainablePromiseElement<WebdriverIO.Element> {
19+
return $(this.DESCRIPTION);
20+
}
21+
22+
get govToolButton(): ChainablePromiseElement<WebdriverIO.Element> {
23+
return $(this.GOV_TOOL_BUTTON);
24+
}
25+
26+
async clickOnGovToolButton(): Promise<void> {
27+
await this.govToolButton.waitForClickable();
28+
await this.govToolButton.click();
29+
}
30+
}
31+
32+
export default new VotingCenterPage();

packages/e2e-tests/src/elements/menuMainExtended.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class MenuMainExtended {
77
private NFTS_BUTTON = '//li[@data-testid="item-nfts"]';
88
private TRANSACTIONS_BUTTON = '//li[@data-testid="item-transactions"]';
99
private STAKING_BUTTON = '//li[@data-testid="item-staking"]';
10-
private DAPP_EXPLORER_BUTTON = '//li[@data-testid="item-dapps"]';
10+
private DAPPS_BUTTON = '//li[@data-testid="item-dapps"]';
11+
private VOTING_BUTTON = '//li[@data-testid="item-voting"]';
1112

1213
get container(): ChainablePromiseElement<WebdriverIO.Element> {
1314
return $(`${this.CONTAINER}`);
@@ -29,8 +30,12 @@ class MenuMainExtended {
2930
return $(`${this.CONTAINER}${this.STAKING_BUTTON}`);
3031
}
3132

32-
get dappExplorerButton(): ChainablePromiseElement<WebdriverIO.Element> {
33-
return $(`${this.CONTAINER}${this.DAPP_EXPLORER_BUTTON}`);
33+
get dappsButton(): ChainablePromiseElement<WebdriverIO.Element> {
34+
return $(`${this.CONTAINER}${this.DAPPS_BUTTON}`);
35+
}
36+
37+
get votingButton(): ChainablePromiseElement<WebdriverIO.Element> {
38+
return $(`${this.CONTAINER}${this.VOTING_BUTTON}`);
3439
}
3540

3641
getIcon(menuItem: ChainablePromiseElement<WebdriverIO.Element>): ChainablePromiseElement<WebdriverIO.Element> {
@@ -61,9 +66,14 @@ class MenuMainExtended {
6166
await this.stakingButton.click();
6267
}
6368

64-
async clickOnDAppExplorerButton() {
65-
await this.dappExplorerButton.waitForClickable();
66-
await this.dappExplorerButton.click();
69+
async clickOnDAppsButton() {
70+
await this.dappsButton.waitForClickable();
71+
await this.dappsButton.click();
72+
}
73+
74+
async clickOnVotingButton() {
75+
await this.votingButton.waitForClickable();
76+
await this.votingButton.click();
6777
}
6878
}
6979

packages/e2e-tests/src/elements/menuMainPopup.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class MenuMainPopup {
77
private NFTS_BUTTON = '//button[@data-testid="main-footer-nfts"]';
88
private TRANSACTIONS_BUTTON = '//button[@data-testid="main-footer-activity"]';
99
private STAKING_BUTTON = '//button[@data-testid="main-footer-staking"]';
10-
private DAPP_EXPLORER_BUTTON = '//button[@data-testid="main-footer-dapp-explorer"]';
10+
private DAPPS_BUTTON = '//button[@data-testid="main-footer-dapp-explorer"]';
11+
private VOTING_BUTTON = '//button[@data-testid="main-footer-voting"]';
1112

1213
get tokensButton(): ChainablePromiseElement<WebdriverIO.Element> {
1314
return $(`${this.CONTAINER}${this.TOKENS_BUTTON}`);
@@ -25,8 +26,12 @@ class MenuMainPopup {
2526
return $(`${this.CONTAINER}${this.STAKING_BUTTON}`);
2627
}
2728

28-
get dappExplorerButton(): ChainablePromiseElement<WebdriverIO.Element> {
29-
return $(`${this.CONTAINER}${this.DAPP_EXPLORER_BUTTON}`);
29+
get dappsButton(): ChainablePromiseElement<WebdriverIO.Element> {
30+
return $(`${this.CONTAINER}${this.DAPPS_BUTTON}`);
31+
}
32+
33+
get votingButton(): ChainablePromiseElement<WebdriverIO.Element> {
34+
return $(`${this.CONTAINER}${this.VOTING_BUTTON}`);
3035
}
3136

3237
async clickOnTokensButton() {
@@ -49,9 +54,14 @@ class MenuMainPopup {
4954
await this.stakingButton.click();
5055
}
5156

52-
async clickOnDAppExplorerButton() {
53-
await this.dappExplorerButton.waitForClickable();
54-
await this.dappExplorerButton.click();
57+
async clickOnDAppsButton() {
58+
await this.dappsButton.waitForClickable();
59+
await this.dappsButton.click();
60+
}
61+
62+
async clickOnVotingButton() {
63+
await this.votingButton.waitForClickable();
64+
await this.votingButton.click();
5565
}
5666
}
5767

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@VotingCenterExtended @Testnet @Mainnet
2+
Feature: Voting Center - Extended View
3+
4+
Background:
5+
Given Lace is ready for test
6+
7+
@LW-12329 @LW-12331
8+
Scenario: Extended view - Voting Center - open and redirect to Gov.tools
9+
When I navigate to Voting extended page
10+
Then I see "Voting Center" banner
11+
And I see "Learn about" widget with all relevant items
12+
When I click on "Access Gov.tool" button
13+
Then New tab with url containing "gov.tools" is opened
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@VotingCenterPopup @Testnet @Mainnet
2+
Feature: Voting Center - Popup View
3+
4+
Background:
5+
Given Lace is ready for test
6+
7+
@LW-12330 @LW-12332
8+
Scenario: Popup view - Voting Center - open and redirect to Gov.tools
9+
When I navigate to Voting popup page
10+
Then I see "Voting Center" banner
11+
When I click on "Access Gov.tool" button
12+
Then New tab with url containing "gov.tools" is opened
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@VotingCenterExtended @Analytics @Testnet @Mainnet
2+
Feature: Analytics - Voting Center - Extended view
3+
4+
Background:
5+
Given Wallet is synced
6+
7+
@LW-12333
8+
Scenario: Analytics - Extended view - Voting Center - open and redirect to Gov.tools
9+
When I set up request interception for posthog analytics request(s)
10+
And I navigate to Voting extended page
11+
Then I validate latest analytics single event "voting | voting | click"
12+
When I click on "Access Gov.tool" button
13+
Then I validate latest analytics single event "voting | voting | banner | button | click"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@VotingCenterPopup @Analytics @Testnet @Mainnet
2+
Feature: Analytics - Voting Center - Popup view
3+
4+
Background:
5+
Given Wallet is synced
6+
7+
@LW-12334
8+
Scenario: Analytics - Popup view - Voting Center - open and redirect to Gov.tools
9+
When I set up request interception for posthog analytics request(s)
10+
And I navigate to Voting popup page
11+
Then I validate latest analytics single event "voting | voting | click"
12+
When I click on "Access Gov.tool" button
13+
Then I validate latest analytics single event "voting | voting | banner | button | click"

packages/e2e-tests/src/hooks/beforeTagHooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Before(
3939

4040
Before(
4141
{
42-
tags: '@AddressBook-extended or @Transactions-Extended or @Tokens-extended or @Staking-Extended or @LockWallet-extended or @Top-Navigation-Extended or @NFTs-Extended or @NFT-Folders-Extended or @SendTx-Bundles-Extended or @SendTx-Simple-Extended or @MainNavigation-Extended or @Send-Transaction-Metadata-Extended or @Settings-Extended or @DAppConnector or @DAppConnector-Extended or @Analytics-Settings-Extended or @Banxa-Extended or @GeneratePaperWallet or @SignMessage-Extended or @WalletAddressPage-Extended or @NamiMode-Extended'
42+
tags: '@AddressBook-extended or @Transactions-Extended or @Tokens-extended or @Staking-Extended or @LockWallet-extended or @Top-Navigation-Extended or @NFTs-Extended or @NFT-Folders-Extended or @SendTx-Bundles-Extended or @SendTx-Simple-Extended or @MainNavigation-Extended or @Send-Transaction-Metadata-Extended or @Settings-Extended or @DAppConnector or @DAppConnector-Extended or @Analytics-Settings-Extended or @Banxa-Extended or @GeneratePaperWallet or @SignMessage-Extended or @WalletAddressPage-Extended or @NamiMode-Extended or @VotingCenterExtended'
4343
},
4444
async () => {
4545
await extendedViewRepositoryWalletInitialization([TestWalletName.TestAutomationWallet]);
@@ -49,7 +49,7 @@ Before(
4949

5050
Before(
5151
{
52-
tags: '@Tokens-popup or @Transactions-Popup or @Staking-Popup or @LockWallet-popup or @Top-Navigation-Popup or @AddressBook-popup or @Common-Popup or @SendTx-Simple-Popup or @MainNavigation-Popup or @Settings-Popup or @NFTs-Popup or @NFT-Folders-Popup or @Send-Transaction-Metadata-Popup or @ForgotPassword or @DAppConnector-Popup or @Analytics-Settings-Popup or @Banxa-Popup or @NamiMode-Popup'
52+
tags: '@Tokens-popup or @Transactions-Popup or @Staking-Popup or @LockWallet-popup or @Top-Navigation-Popup or @AddressBook-popup or @Common-Popup or @SendTx-Simple-Popup or @MainNavigation-Popup or @Settings-Popup or @NFTs-Popup or @NFT-Folders-Popup or @Send-Transaction-Metadata-Popup or @ForgotPassword or @DAppConnector-Popup or @Analytics-Settings-Popup or @Banxa-Popup or @NamiMode-Popup or @VotingCenterPopup'
5353
},
5454
async () => {
5555
await popupViewRepositoryWalletInitialization([TestWalletName.TestAutomationWallet]);

packages/e2e-tests/src/page/extendedView.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ class ExtendedView extends LaceView implements Page {
5454
await browser.url(`${await this.getBaseUrl()}#/dapp-explorer`);
5555
await this.waitForPreloaderToDisappear();
5656
}
57+
58+
async visitVotingCenter() {
59+
await browser.url(`${await this.getBaseUrl()}#/voting`);
60+
await this.waitForPreloaderToDisappear();
61+
}
5762
}
5863

5964
export default new ExtendedView();

packages/e2e-tests/src/page/popupView.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class PopupView extends LaceView implements Page {
7474
await this.waitForPreloaderToDisappear();
7575
}
7676

77+
async visitVotingCenter() {
78+
await browser.url(`${this.basePopupUrl}#/voting`);
79+
await this.setPopupWindowSize();
80+
await this.waitForPreloaderToDisappear();
81+
}
82+
7783
async visitNamiMode() {
7884
await browser.url(`${this.basePopupUrl}`);
7985
await this.setPopupWindowSize();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Then, When } from '@cucumber/cucumber';
2+
import educationalListAssert from '../assert/educationalListAssert';
3+
import VotingCenterPageAssert from '../assert/VotingCenterPageAssert';
4+
import VotingCenterPage from '../elements/VotingCenterPage';
5+
6+
Then(/^I see "Voting Center" banner$/, async () => {
7+
await VotingCenterPageAssert.assertSeeVotingCenterBanner();
8+
});
9+
10+
Then(/^I see "Learn about" widget with all relevant items$/, async () => {
11+
await educationalListAssert.assertSeeVotingWidget();
12+
});
13+
14+
When(/^I click on "Access Gov.tool" button$/, async () => {
15+
await VotingCenterPage.clickOnGovToolButton();
16+
});

packages/e2e-tests/src/steps/commonSteps.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,20 @@ Then(/^I expect wallet repository and local storage to (not be|be) empty$/, asyn
103103
});
104104

105105
When(
106-
/^I (navigate to|am on) (Tokens|NFTs|Activity|Staking|Address Book|Settings|DApp Explorer) (extended|popup) page$/,
106+
/^I (navigate to|am on) (Tokens|NFTs|Activity|Staking|Address Book|Settings|DApps|Voting) (extended|popup) page$/,
107107
async (
108108
_ignored: string,
109-
targetPage: 'Tokens' | 'NFTs' | 'Activity' | 'Staking' | 'Settings' | 'Address Book' | 'DApp Explorer',
109+
targetPage: 'Tokens' | 'NFTs' | 'Activity' | 'Staking' | 'Settings' | 'Address Book' | 'DApps' | 'Voting',
110110
mode: 'extended' | 'popup'
111111
) => {
112112
await visit(targetPage, mode, false);
113113
}
114114
);
115115

116116
When(
117-
/^I visit (Tokens|NFTs|Activity|Staking|Settings|Address Book|DApp Explorer) page in (extended|popup) mode$/,
117+
/^I visit (Tokens|NFTs|Activity|Staking|Settings|Address Book|DApps|Voting) page in (extended|popup) mode$/,
118118
async (
119-
page: 'Tokens' | 'NFTs' | 'Activity' | 'Staking' | 'Settings' | 'Address Book' | 'DApp Explorer',
119+
page: 'Tokens' | 'NFTs' | 'Activity' | 'Staking' | 'Settings' | 'Address Book' | 'DApps' | 'Voting',
120120
mode: 'extended' | 'popup'
121121
) => {
122122
await visit(page, mode, true);
@@ -249,7 +249,7 @@ When(/^I hover over "Expand" button$/, async () => {
249249
});
250250

251251
Then(
252-
/^the (Tokens|NFTs|Activity|Staking|Dapp Store|Voting|Address Book|Settings) page is displayed on a new tab in extended view$/,
252+
/^the (Tokens|NFTs|Activity|Staking|DApps|Voting|Address Book|Settings) page is displayed on a new tab in extended view$/,
253253
async (expectedPage: string) => {
254254
await commonAssert.assertSeePageInNewTab(expectedPage, 'extended');
255255
}

0 commit comments

Comments
 (0)