Skip to content

Commit

Permalink
test: e2e - add maintenance scenarios for re-creating test wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
ljagiela committed Jan 3, 2025
1 parent dac724b commit 4b1a669
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 38 deletions.
14 changes: 11 additions & 3 deletions packages/e2e-tests/src/assert/transactionsPageAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ class TransactionsPageAssert {

await browser.waitUntil(
async () =>
(
await TransactionsPage.transactionsTableItemTokensAmount(rowIndex).getText()
).includes(expectedTransactionRowAssetDetails.tokensAmount),
(await TransactionsPage.transactionsTableItemTokensAmount(rowIndex).getText()).includes(
expectedTransactionRowAssetDetails.tokensAmount
),
{
timeout: 8000,
interval: 1000,
Expand Down Expand Up @@ -194,6 +194,14 @@ class TransactionsPageAssert {
expectedColors
);
}

assertCounterShowingMoreTransactionsThan = async (expectedMaxNumber: number) => {
const transactionsCounterValue = Number((await TransactionsPage.counter.getText()).slice(1, -1));
expect(transactionsCounterValue).to.be.greaterThan(
expectedMaxNumber,
`transactions count is lower than ${expectedMaxNumber}, aborting`
);
};
}

export default new TransactionsPageAssert();
15 changes: 14 additions & 1 deletion packages/e2e-tests/src/elements/newTransaction/coinConfigure.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
import { ChainablePromiseElement } from 'webdriverio';
import { ChainablePromiseElement, ChainablePromiseArray } from 'webdriverio';
import { setInputFieldValue } from '../../utils/inputFieldUtils';
import { browser } from '@wdio/globals';

Expand Down Expand Up @@ -31,6 +31,10 @@ export class CoinConfigure {
return $(`${this.CONTAINER}${this.TOKEN_NAME}`);
}

get nameElements(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $$(`${this.CONTAINER}${this.TOKEN_NAME}`);
}

get balanceValueElement(): ChainablePromiseElement<WebdriverIO.Element> {
return $(`${this.CONTAINER}${this.TOKEN_VALUE}`);
}
Expand Down Expand Up @@ -111,6 +115,15 @@ export class CoinConfigure {
await this.assetMaxButton.click();
};

getAllTokenNames = async (): Promise<string[]> => {
const tab = await this.nameElements;
const names: string[] = [];
for (const i of tab) {
names.push(await i.getText());
}
return names;
};

clickToLoseFocus = async (): Promise<void> => {
await this.drawerNavigationHeader.click();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import CommonDrawerElements from '../CommonDrawerElements';
import testContext from '../../utils/testContext';
import { generateRandomString } from '../../utils/textUtils';
import { TokenSearchResult } from './tokenSearchResult';
import { ChainablePromiseElement, ChainablePromiseArray } from 'webdriverio';

class TokenSelectionPage extends CommonDrawerElements {
private TOKENS_BUTTON = '//input[@data-testid="asset-selector-button-tokens"]';
Expand All @@ -24,43 +25,43 @@ class TokenSelectionPage extends CommonDrawerElements {
private SEARCH_INPUT = '[data-testid="asset-selector"] [data-testid="search-input"]';
public NFT_IMAGE = '[data-testid="nft-image"]';

get tokensButton() {
get tokensButton(): ChainablePromiseElement<WebdriverIO.Element> {
return $(this.TOKENS_BUTTON).parentElement().parentElement();
}

get nftsButton() {
get nftsButton(): ChainablePromiseElement<WebdriverIO.Element> {
return $(this.NFTS_BUTTON).parentElement().parentElement();
}

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

get nftImages() {
get nftImages(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return this.assetSelectorContainer.$$(this.NFT_IMAGE);
}

get tokens() {
get tokens(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return $$(this.TOKEN_ROW);
}

tokenItem(nameOrIndex: string | number) {
return new TokenSearchResult(nameOrIndex);
}

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

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

get nftContainers() {
get nftContainers(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return this.assetSelectorContainer.$$(this.NFT_CONTAINER);
}

get nftNames() {
get nftNames(): ChainablePromiseArray<WebdriverIO.ElementArray> {
return this.assetSelectorContainer.$$(this.NFT_ITEM_NAME);
}

Expand All @@ -82,35 +83,35 @@ class TokenSelectionPage extends CommonDrawerElements {
return this.nftContainers[index].$(this.NFT_ITEM_SELECTED_CHECKMARK);
}

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

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

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

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

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class RecoveryPhrasePage extends CommonOnboardingElements {
await ChooseRecoveryMethodPage.nextButton.click();
if (flowType === 'Create') {
await this.clickOnCopyToClipboardButton();
testContext.save('newCreatedWalletMnemonic', await clipboard.read());
await this.nextButton.click();
}
if (fillValues) {
Expand Down
12 changes: 8 additions & 4 deletions packages/e2e-tests/src/elements/onboarding/walletSetupPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,19 @@ class WalletSetupPage extends CommonOnboardingElements {
async goToWalletSetupPage(
flowType: 'Create' | 'Restore',
mnemonicWords: string[] = [],
fillValues = false
fillValues = false,
walletName?: string,
walletPassword?: string
): Promise<void> {
await recoveryPhrasePage.goToMnemonicVerificationPage(flowType, mnemonicWords, true);
await recoveryPhrasePage.nextButton.waitForClickable();
await recoveryPhrasePage.nextButton.click();
if (fillValues) {
await this.setWalletNameInput('TestAutomationWallet');
await this.setWalletPasswordInput('N_8J@bne87A');
await this.setWalletPasswordConfirmInput('N_8J@bne87A');
const name = walletName === undefined ? 'TestAutomationWallet' : walletName.slice(0, 20);
await this.setWalletNameInput(name);
const password = walletPassword === 'default' ? String(process.env.WALLET_1_PASSWORD) : 'N_8J@bne87A';
await this.setWalletPasswordInput(password);
await this.setWalletPasswordConfirmInput(password);
}
}
}
Expand Down
42 changes: 42 additions & 0 deletions packages/e2e-tests/src/features/WalletMaintenance.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@Pending
@WalletMaintenance
Feature: Maintenance feature

# this feature is for maintenance purposes only

# scenario below creates new wallet, transfers all funds from desired wallet and
# prints its data that can be later pasted into walletConfiguration file
# replace wallet_name in the Examples sections and let the test finish
# you may still need to manually do the delegation for some wallets

@RecreateWalletAndTransferAllFunds
Scenario Outline: Extended View - Check if wallet has more than 1000 transactions, if yes then create a new one, transfer all funds and generate wallet repository entry
Given I create new wallet with name: "<wallet_name>" and save wallet information
And I click "Receive" button on page header
And I click "Copy" button on "Receive" page for default wallet address
And I open wallet: "<wallet_name>" in: extended mode
And I navigate to Transactions extended page
And Transactions counter is showing value higher than 900
And I navigate to Staking extended page
And I save identifiers of stake pools currently in use
And I click "Send" button on page header
And I fill address input with copied address
And If available: I add all available Token types to bundle 1
And I click MAX button for all selected tokens
And If available: I add all available NFT types to bundle 1
And I click "Review transaction" button on "Send" page
And I click "Confirm" button on "Transaction summary" page
When I enter correct password and confirm the transaction
Then The Transaction submitted screen is displayed in extended mode
And I print wallet "<wallet_name>" data for walletConfiguration file
Examples:
| wallet_name |
| WalletAnalyticsReceiveSimpleTransaction2E2E |

@CreateNewWallet
Scenario Outline: Extended View - Create a new wallet and print data
Given I create new wallet with name: "<wallet_name>" and save wallet information
And I print wallet "<wallet_name>" data for walletConfiguration file
Examples:
| wallet_name |
| TestAutomationWallet |
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: Delegating funds to new pool E2E

@LW-2685 @Smoke
Scenario: Extended view - Staking - Delegating funds to new pool (if not staked yet) E2E.
Given I create new wallet and save wallet information
Given I create new wallet with name: "newCreatedWallet" and save wallet information
And Wallet is synced
When I open header menu
Then I don't see any toast message
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/src/hooks/beforeTagHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Before({ tags: '@pending or @Pending' }, async () => 'skipped');

Before(
{
tags: '@OnboardingCreateWallet or @Staking-initial-E2E or @OnboardingRestoreWallet or @OnboardingHardwareWallet or @TrezorOnboarding or @OnboardingCreatePaperWallet or @OnboardingRestorePaperWallet'
tags: '@OnboardingCreateWallet or @Staking-initial-E2E or @OnboardingRestoreWallet or @OnboardingHardwareWallet or @TrezorOnboarding or @OnboardingCreatePaperWallet or @OnboardingRestorePaperWallet or @WalletMaintenance'
},
async () => {
await extendedView.visit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import extensionUtils from '../utils/utils';
import { byron, shelley } from '../data/AddressData';
import { AssetInput } from '../elements/newTransaction/assetInput';
import { AddressInput } from '../elements/AddressInput';
import CommonDrawerElements from '../elements/CommonDrawerElements';

export default new (class NewTransactionExtendedPageObject {
async setTwoAssetsForBundle(bundleIndex: number, assetValue1: number, assetValue2: number) {
Expand Down Expand Up @@ -64,13 +65,17 @@ export default new (class NewTransactionExtendedPageObject {
await TokenSelectionPage.clickTokensButton();
const tokens = await TokenSelectionPage.getTokensInfo();
let tokensCount = tokens.length;
for (const token of tokens) {
tokensCount--;
await TokenSelectionPage.clickOnToken(token.name);
if (tokensCount) {
await new AssetInput(bundleIndex).clickAddAssetButton();
await TokenSelectionPage.clickTokensButton();
if (tokensCount > 0) {
for (const token of tokens) {
tokensCount--;
await TokenSelectionPage.clickOnToken(token.name);
if (tokensCount) {
await new AssetInput(bundleIndex).clickAddAssetButton();
await TokenSelectionPage.clickTokensButton();
}
}
} else {
await new CommonDrawerElements().clickHeaderBackButton();
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/e2e-tests/src/steps/commonSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ Then(/^I open wallet: "([^"]*)" in: (extended|popup) mode$/, async (walletName:

await localStorageInitializer.initialiseBasicLocalStorageData(walletName);
await localStorageInitializer.initializeShowMultiAddressDiscoveryModal(false);
await localStorageInitializer.disableShowingMultidelegationBetaBanner();
if (mode === 'popup') {
await popupView.visit();
}
Expand Down
15 changes: 10 additions & 5 deletions packages/e2e-tests/src/steps/onboardingSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import SecureYourPaperWalletPage from '../elements/onboarding/SecureYourPaperWal
import SaveYourPaperWalletPageAssert from '../assert/onboarding/SaveYourPaperWalletPageAssert';
import SaveYourPaperWalletPage from '../elements/onboarding/SaveYourPaperWalletPage';
import ScanYourPrivateQrCodePageAssert from '../assert/onboarding/ScanYourPrivateQrCodePageAssert';
import LocalStorageInitializer from '../fixture/localStorageInitializer';

const mnemonicWords: string[] = getTestWallet(TestWalletName.TestAutomationWallet).mnemonic ?? [];
const invalidMnemonicWords: string[] = getTestWallet(TestWalletName.InvalidMnemonic).mnemonic ?? [];
Expand Down Expand Up @@ -194,13 +195,13 @@ Then(/^I do not see autocomplete options list$/, async () => {
await onboardingRecoveryPhrasePageAssert.assertNotSeeMnemonicAutocompleteOptions();
});

Given(/^I create new wallet and save wallet information$/, async () => {
// issue LW-11288 - please remove when it will be fixed / check on CI is needed
Given(/^I create new wallet with name: "([^"]*)" and save wallet information$/, async (walletName: string) => {
await browser.pause(1000);
await OnboardingMainPage.createWalletButton.click();
await OnboardingWalletSetupPage.goToWalletSetupPage('Create', mnemonicWords, true);
await OnboardingWalletSetupPage.goToWalletSetupPage('Create', mnemonicWords, true, walletName, 'default');
await OnboardingWalletSetupPageAssert.assertSeeWalletSetupPage();
await OnboardingWalletSetupPage.clickEnterWalletButton();
await LocalStorageInitializer.disableShowPinExtension();
await TopNavigationAssert.assertLogoPresent();
await settingsExtendedPageObject.switchNetworkAndCloseDrawer('Preprod', 'extended');
const newCreatedWallet = JSON.stringify(await getWalletsFromRepository());
Expand Down Expand Up @@ -258,8 +259,12 @@ Given(
/^I enter wallet name: "([^"]*)", password: "([^"]*)" and password confirmation: "([^"]*)"$/,
async (walletName: string, password: string, passwordConfirmation: string) => {
await OnboardingWalletSetupPage.setWalletNameInput(walletName);
await OnboardingWalletSetupPage.setWalletPasswordInput(password);
await OnboardingWalletSetupPage.setWalletPasswordConfirmInput(passwordConfirmation);
await OnboardingWalletSetupPage.setWalletPasswordInput(
password === 'default' ? String(process.env.WALLET_1_PASSWORD) : password
);
await OnboardingWalletSetupPage.setWalletPasswordConfirmInput(
passwordConfirmation === 'default' ? String(process.env.WALLET_1_PASSWORD) : passwordConfirmation
);
}
);

Expand Down
13 changes: 13 additions & 0 deletions packages/e2e-tests/src/steps/sendTransactionSimpleSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { parseWalletAddress } from '../utils/parseWalletAddress';
import { AddressType } from '../enums/AddressTypeEnum';
import clipboard from 'clipboardy';
import walletAddressPage from '../elements/walletAddressPage';
import { CoinConfigure } from '../elements/newTransaction/coinConfigure';

Given(/I have several contacts whose start with the same characters/, async () => {
await indexedDB.clearAddressBook();
Expand Down Expand Up @@ -146,6 +147,13 @@ When(/^I select amount: (\d*) of asset type: (Tokens|NFTs)$/, async (amount: num
await TokenSelectionPage.addAmountOfAssets(amount, assetType);
});

When(/^I click MAX button for all selected tokens$/, async () => {
const tokenNames = await new CoinConfigure(1).getAllTokenNames();
for (const tokenName of tokenNames) {
await new CoinConfigure(1, tokenName).clickMaxButton();
}
});

When(/^I deselect (Tokens|NFTs) (\d*)$/, async (assetType: 'Tokens' | 'NFTs', index: number) => {
await TokenSelectionPage.deselectToken(assetType, index);
});
Expand Down Expand Up @@ -256,6 +264,11 @@ When(/^I fill bundle with copied address and ([^"]*) ADA$/, async (adaValue: str
await TransactionNewPage.coinConfigure(1, Asset.CARDANO.ticker).fillTokenValue(Number.parseFloat(adaValue));
});

When(/^I fill address input with copied address$/, async () => {
const addressInput = new AddressInput(1);
await addressInput.fillAddress(await clipboard.read());
});

When(/^I fill bundle with saved unused address and ([^"]*) ADA$/, async (adaValue: string) => {
const addressInput = new AddressInput(1);
await addressInput.fillAddress(await walletAddressPage.getSavedLastAddress());
Expand Down
4 changes: 4 additions & 0 deletions packages/e2e-tests/src/steps/transactionsSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,7 @@ Then(/^I save tx hash value "([^"]*)"$/, async (hash: string) => {
Logger.log(`saving tx hash: ${hash}`);
testContext.save('txHashValue', hash);
});

Then(/^Transactions counter is showing value higher than (\d+)$/, async (transactionsMaxNumber: number) => {
await transactionsPageAssert.assertCounterShowingMoreTransactionsThan(transactionsMaxNumber);
});
Loading

0 comments on commit 4b1a669

Please sign in to comment.