Skip to content

Commit

Permalink
test(extension): add e2e for wallet account disabling (#1323)
Browse files Browse the repository at this point in the history
* test(extension): add e2e for wallet account disabling

* test(extension): fix quotes for steps
  • Loading branch information
ljagiela authored Jul 26, 2024
1 parent 41b6613 commit 1c78d28
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const DisableAccountConfirmation = ({
<Dialog.Title>{title}</Dialog.Title>
<Dialog.Description>{description}</Dialog.Description>
<Dialog.Actions>
<Dialog.Action cancel label={cancel} onClick={onCancel} />
<Dialog.Action label={confirm} onClick={onConfirm} />
<Dialog.Action cancel label={cancel} onClick={onCancel} testId="dialog-action-cancel" />
<Dialog.Action label={confirm} onClick={onConfirm} testId="dialog-action-confirm" />
</Dialog.Actions>
</Dialog.Root>
);
18 changes: 18 additions & 0 deletions packages/e2e-tests/src/assert/WalletAccountsMenuAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import WalletAccounts from '../elements/accounts/WalletAccountsMenu';
import { expect } from 'chai';
import { t } from '../utils/translationService';
import WalletAccountsMenuItem from '../elements/accounts/WalletAccountsMenuItem';
import HoldUpDisableAccountDialog from '../elements/accounts/HoldUpDisableAccountDialog';

class WalletAccountsMenuAssert {
async assertSeeAccountsMenu(shouldBeDisplayed: boolean): Promise<void> {
Expand Down Expand Up @@ -35,6 +36,23 @@ class WalletAccountsMenuAssert {
expect(await accountItem.path.getText()).to.equal(`m/1852'/1815'/${accountIndex}'`);
}
}

async assertSeeHoldUpModal(shouldBeDisplayed: boolean): Promise<void> {
await HoldUpDisableAccountDialog.body.waitForDisplayed({ reverse: !shouldBeDisplayed });
if (shouldBeDisplayed) {
await HoldUpDisableAccountDialog.title.waitForDisplayed();
expect(await HoldUpDisableAccountDialog.title.getText()).to.equal(await t('account.disable.title'));

await HoldUpDisableAccountDialog.description.waitForDisplayed();
expect(await HoldUpDisableAccountDialog.description.getText()).to.equal(await t('account.disable.description'));

await HoldUpDisableAccountDialog.cancelButton.waitForDisplayed();
expect(await HoldUpDisableAccountDialog.cancelButton.getText()).to.equal(await t('account.disable.cancel'));

await HoldUpDisableAccountDialog.confirmButton.waitForDisplayed();
expect(await HoldUpDisableAccountDialog.confirmButton.getText()).to.equal(await t('account.disable.confirm'));
}
}
}

export default new WalletAccountsMenuAssert();
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-disable no-undef */
import { ChainablePromiseElement } from 'webdriverio';

class HoldUpDisableAccountDialog {
private BODY = '[role="alertdialog"]';
private TITLE = '//h2[@data-testid="dialog-title"]';
private DESCRIPTION = `${this.TITLE}/following-sibling::span`;
private CANCEL_BUTTON = '[data-testid="dialog-action-cancel"]';
private CONFIRM_BUTTON = '[data-testid="dialog-action-confirm"]';

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

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

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

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

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

async clickCancelButton() {
await this.cancelButton.waitForClickable();
await this.cancelButton.click();
}

async clickConfirmButton() {
await this.confirmButton.waitForClickable();
await this.confirmButton.click();
}
}

export default new HoldUpDisableAccountDialog();
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CommonDrawerElements from '../CommonDrawerElements';
class WalletAccountsUnlockDrawer extends CommonDrawerElements {
private HEADLINE = '[data-testid="enable-account-headline"]';
private DESCRIPTION = '[data-testid="enable-account-description"]';
private PASSWORD_FORM = '//div[@data-testid="enable-account-password-input"]';
private PASSWORD_FORM = '//div[@data-testid="enable-account-password"]';
private PASSWORD_INPUT = `${this.PASSWORD_FORM}//form//input`;
private PASSWORD_INPUT_PLACEHOLDER = `${this.PASSWORD_FORM}//label`;
private PASSWORD_INPUT_BUTTON = `${this.PASSWORD_FORM}//form//button`;
Expand Down
62 changes: 52 additions & 10 deletions packages/e2e-tests/src/features/WalletAccountsExtended.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ Feature: Wallet accounts
Scenario: Extended View - Accounts menu - Account unlock drawer displayed
Given I click the menu button
And I click on chevron for wallet number 1
When I click unlock button: 4
When I click "enable" button: 4
Then I see account unlock drawer with all elements in extended mode

@LW-11020
Scenario: Extended View - Accounts menu - Unlocking account error when wrong password
Given I click the menu button
And I click on chevron for wallet number 1
And I click unlock button: 4
And I click "enable" button: 4
When I fill invalid password on the account unlock drawer
And I click "Confirm" button on the account unlock drawer
Then I see wallet unlock error
Expand All @@ -40,15 +40,15 @@ Feature: Wallet accounts
Scenario Outline: Extended View - Accounts menu - Closing unlock drawer when <action>
Given I click the menu button
And I click on chevron for wallet number 1
And I see unlock button: 4
And I click unlock button: 4
And I see "enable" button: 4
And I click "enable" button: 4
When <action>
Then I do not see account unlock drawer with all elements in extended mode
And I see unlock button: 4
And I see "enable" button: 4
Examples:
| action |
| I click outside the drawer |
| I close the drawer by clicking back button |
| action |
| I click outside the drawer |
| I close the drawer by clicking back button |
| I click "Cancel" button on the account unlock drawer |

@LW-9312
Expand All @@ -58,7 +58,7 @@ Feature: Wallet accounts
And I close the drawer by clicking close button
And I click the menu button
And I click on chevron for wallet number 1
When I click unlock button: 4
When I click "enable" button: 4
And I fill valid password on the account unlock drawer
And I click "Confirm" button on the account unlock drawer
Then I see "Account #3 activated" toast
Expand All @@ -69,7 +69,7 @@ Feature: Wallet accounts
And I close the drawer by clicking close button
When I click the menu button
And I click on chevron for wallet number 1
Then I do not see unlock button: 4
Then I do not see "enable" button: 4

@LW-9313
Scenario: Extended View - Accounts menu - Switching account
Expand All @@ -96,3 +96,45 @@ Feature: Wallet accounts
And I click on back arrow button on "Accounts" menu
When I click "Receive" button on page header
Then I see "Wallet Address" page in extended mode for account: 0 and wallet "MultiAccActive1"

@LW-11056 @LW-9303 @LW-9302
Scenario: Extended View - Accounts menu - Disable button not displayed for active account
Given I click the menu button
When I click on chevron for wallet number 1
Then I do not see "disable" button: 1
And I see "disable" button: 2
And I see "disable" button: 3
And I see "enable" button: 4

@LW-11055
Scenario: Extended View - Accounts menu - Disable account modal displayed
Given I click the menu button
And I click on chevron for wallet number 1
When I click "disable" button: 2
Then I see "Hold Up!" account disable modal

@LW-11054
Scenario: Extended View - Accounts menu - Disable account modal cancel click
Given I click the menu button
And I click on chevron for wallet number 1
And I click "disable" button: 2
And I see "Hold Up!" account disable modal
When I click "Cancel" on "Hold Up!" account disable modal
Then I do not see "Hold Up!" account disable modal
And I see "disable" button: 2

@LW-11053
Scenario: Extended View - Accounts menu - Disable account
Given I click the menu button
And I click on chevron for wallet number 1
And I click "disable" button: 2
And I see "Hold Up!" account disable modal
When I click "Disable" on "Hold Up!" account disable modal
Then I do not see "Hold Up!" account disable modal
And I see "enable" button: 2
And I do not see "disable" button: 2
When I click account item: 2
Then "Accounts" menu is displayed
When I click "enable" button: 2
Then I see account unlock drawer with all elements in extended mode

61 changes: 51 additions & 10 deletions packages/e2e-tests/src/features/WalletAccountsPopup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,38 @@ Feature: Wallet accounts
Scenario: Popup View - Accounts menu - Account unlock drawer displayed
Given I click the menu button
And I click on chevron for wallet number 1
When I click unlock button: 4
When I click "enable" button: 4
Then I see account unlock drawer with all elements in popup mode

@LW-11023
Scenario: Popup View - Accounts menu - Unlocking account error when wrong password
Given I click the menu button
And I click on chevron for wallet number 1
And I click unlock button: 4
And I click "enable" button: 4
When I fill invalid password on the account unlock drawer
And I click "Confirm" button on the account unlock drawer
Then I see wallet unlock error

@LW-11022
Scenario Outline: Popup View - Accounts menu - Closing unlock drawer when <action>
Scenario Outline: Popup View - Accounts menu - Closing "enable" drawer when <action>
Given I click the menu button
And I click on chevron for wallet number 1
And I see unlock button: 4
And I click unlock button: 4
And I see "enable" button: 4
And I click "enable" button: 4
When <action>
Then I do not see account unlock drawer with all elements in popup mode
And I see unlock button: 4
And I see "enable" button: 4
Examples:
| action |
| I close the drawer by clicking back button |
| action |
| I close the drawer by clicking back button |
| I click "Cancel" button on the account unlock drawer |

@LW-9332
Scenario: Popup View - Accounts menu - Unlocking account
Given I see address for account: 0 and wallet "MultiAccActive1" on empty state banner
And I click the menu button
And I click on chevron for wallet number 1
When I click unlock button: 4
When I click "enable" button: 4
And I fill valid password on the account unlock drawer
And I click "Confirm" button on the account unlock drawer
Then I see "Account #3 activated" toast
Expand All @@ -64,7 +64,7 @@ Feature: Wallet accounts
When I see address for account: 3 and wallet "MultiAccActive1" on empty state banner
And I click the menu button
And I click on chevron for wallet number 1
Then I do not see unlock button: 4
Then I do not see "enable" button: 4

@LW-9333
Scenario: Popup View - Accounts menu - Switching account
Expand All @@ -85,3 +85,44 @@ Feature: Wallet accounts
Then "Accounts" menu is displayed
And I click on back arrow button on "Accounts" menu
And I see address for account: 0 and wallet "MultiAccActive1" on empty state banner

@LW-11052 @LW-9322 @LW-9323
Scenario: Popup View - Accounts menu - Disable button not displayed for active account
Given I click the menu button
When I click on chevron for wallet number 1
Then I do not see "disable" button: 1
And I see "disable" button: 2
And I see "disable" button: 3
And I see "enable" button: 4

@LW-11051
Scenario: Popup View - Accounts menu - Disable account modal displayed
Given I click the menu button
And I click on chevron for wallet number 1
When I click "disable" button: 2
Then I see "Hold Up!" account disable modal

@LW-11050
Scenario: Popup View - Accounts menu - Disable account modal cancel click
Given I click the menu button
And I click on chevron for wallet number 1
And I click "disable" button: 2
And I see "Hold Up!" account disable modal
When I click "Cancel" on "Hold Up!" account disable modal
Then I do not see "Hold Up!" account disable modal
And I see "disable" button: 2

@LW-11049
Scenario: Popup View - Accounts menu - Disable account
Given I click the menu button
And I click on chevron for wallet number 1
And I click "disable" button: 2
And I see "Hold Up!" account disable modal
When I click "Disable" on "Hold Up!" account disable modal
Then I do not see "Hold Up!" account disable modal
And I see "enable" button: 2
And I do not see "disable" button: 2
When I click account item: 2
Then "Accounts" menu is displayed
When I click "enable" button: 2
Then I see account unlock drawer with all elements in popup mode
25 changes: 20 additions & 5 deletions packages/e2e-tests/src/steps/AccountsSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import WalletAccountsMenuItem from '../elements/accounts/WalletAccountsMenuItem'
import WalletAccountsUnlockDrawerAssert from '../assert/WalletAccountsUnlockDrawerAssert';
import { getTestWallet, TestWalletName } from '../support/walletConfiguration';
import WalletAccountsUnlockDrawer from '../elements/accounts/WalletAccountsUnlockDrawer';
import HoldUpDisableAccountDialog from '../elements/accounts/HoldUpDisableAccountDialog';

When(/^I click on chevron for wallet number (\d)$/, async (walletIndex: number) => {
await new WalletOption(walletIndex).clickOnAccountsMenuButton();
Expand All @@ -28,18 +29,22 @@ Then(/^each account item contains icon, logo and path$/, async () => {
});

When(
/^I (see|do not see|click) unlock button: (\d+)$/,
async (action: 'see' | 'do not see' | 'click', accountNumber: number) => {
/^I (see|do not see|click) "(enable|disable)" button: (\d+)$/,
async (action: 'see' | 'do not see' | 'click', expectedButton: 'enable' | 'disable', accountNumber: number) => {
const accountItem = new WalletAccountsMenuItem(accountNumber);
const button = await (expectedButton === 'enable'
? accountItem.accountEnableButton
: accountItem.accountDisableButton);

switch (action) {
case 'see':
await accountItem.accountEnableButton.waitForDisplayed();
await button.waitForDisplayed();
break;
case 'do not see':
await accountItem.accountEnableButton.waitForDisplayed({ reverse: true });
await button.waitForDisplayed({ reverse: true });
break;
case 'click':
await accountItem.accountEnableButton.click();
await button.click();
break;
default:
throw new Error(`Unsupported action: ${action}`);
Expand Down Expand Up @@ -82,3 +87,13 @@ Then(/^I see wallet unlock error$/, async () => {
Then(/^I see "Account #(\d+) activated" toast$/, async (accountNumber: number) => {
await WalletAccountsUnlockDrawerAssert.assertSeeAccountActivatedToast(accountNumber);
});

Then(/^I (see|do not see) "Hold Up!" account disable modal$/, async (shouldSee: 'see' | 'do not see') => {
await WalletAccountsAssert.assertSeeHoldUpModal(shouldSee === 'see');
});

Then(/^I click "(Cancel|Disable)" on "Hold Up!" account disable modal$/, async (button: 'Cancel' | 'Disable') => {
await (button === 'Cancel'
? HoldUpDisableAccountDialog.clickCancelButton()
: HoldUpDisableAccountDialog.clickConfirmButton());
});

0 comments on commit 1c78d28

Please sign in to comment.