Skip to content

Commit

Permalink
Merge pull request #3032 from Emurgo/denis/fix-e2e-transfer-funds
Browse files Browse the repository at this point in the history
Denis/fix e2e transfer funds
  • Loading branch information
Nebyt committed Oct 27, 2022
2 parents c66b15c + 3ea718f commit fe1c843
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 113 deletions.
23 changes: 12 additions & 11 deletions packages/yoroi-extension/features/installation-procedure.feature
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
Feature: Installation procedure

@it-98
Scenario: User Selects Language at first launch (IT-98)
Given I have opened the extension
And I am on the language selection screen
And I open language selection dropdown
And I select Japanese language
When I submit the language selection form
Then I should not see the language selection screen anymore
And I should have Japanese language set

@it-51
Scenario: Terms of Use are not accepted if user didn’t confirm it and close/reload the browser page (IT-51)
Given I have opened the extension
And I am on the language selection screen
And I have selected English language
Given I am on the "Terms of use" screen
When I refresh the page
And I click on "I agree with the terms of use" checkbox
When I submit the "Terms of use" form
Then I should not see the "Terms of use" screen anymore
And I should have "Terms of use" accepted
And I should have "Terms of use" accepted

@it-98
Scenario: User Selects Language at first launch (IT-98)
Given I have opened the extension
And I am on the language selection screen
And I open language selection dropdown
And I select Japanese language
When I submit the language selection form
Then I should not see the language selection screen anymore
And I should have Japanese language set
2 changes: 1 addition & 1 deletion packages/yoroi-extension/features/migration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Feature: Migration

Examples:
| amount | fee |
| 1.000000 | 0.168845 |
| 1.000000 | 0.180065 |

@it-140
Scenario: Upgrade from version that adds bip44 support (IT-140)
Expand Down
5 changes: 5 additions & 0 deletions packages/yoroi-extension/features/pages/basicSetupPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const continueButton: LocatorObject = {
locator: '//button[text()="Continue"]',
method: 'xpath',
};

export const confirmSelectedLanguageButton: LocatorObject = {
locator: `${LANGUAGE_SELECTION_FORM} > .LanguageSelectionForm_centeredBox > .MuiButton-primary`,
method: 'css'
};
// ToS page
export const termsOfUseComponent: LocatorObject = {
locator: '.TermsOfUseForm_component',
Expand Down
29 changes: 14 additions & 15 deletions packages/yoroi-extension/features/pages/walletVotingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,49 @@
import type { LocatorObject } from '../support/webdriver';

export const registerButton: LocatorObject = {
locator: '.Voting_registerButton > .primary',
locator: '.Voting_registerButton > .MuiButton-primary',
method: 'css',
};

export const generatePinDialog: LocatorObject = {
locator: '.GeneratePinDialog_dialog',
method: 'css',
};
export const generatedPinButton: LocatorObject = {
locator: '.GeneratePinDialog_dialog > .Dialog_actions > .primary',
method: 'css',

export const confirmButton: LocatorObject = {
locator: '//button[@id="primaryButton"]',
method: 'xpath',
};

export const generatedPinStepElement: LocatorObject = {
locator: '.GeneratePinDialog_pin > span',
method: 'css',
};

export const confirmPinDialog: LocatorObject = {
locator: '.ConfirmPinDialog_dialog',
method: 'css',
};

export const pinInput: LocatorObject = { locator: "input[name='pin']", method: 'css' };
export const confirmPinButton: LocatorObject = {
locator: '.ConfirmPinDialog_dialog > .Dialog_actions > .primary',
method: 'css',
};

export const confirmPinDialogError: LocatorObject = {
locator:
'.ConfirmPinDialog_dialog .ConfirmPinDialog_pinInputContainer .FormFieldOverridesClassic_error',
method: 'css',
locator: '//p[starts-with(@id, "pin-") and contains(@id, "-helper-text")]',
method: 'xpath',
};

export const registerDialog: LocatorObject = { locator: '.RegisterDialog_dialog', method: 'css' };
export const registerDialogNextButton: LocatorObject = {
locator: '.RegisterDialog_dialog > .Dialog_actions > .primary',
method: 'css',
};

export const votingRegTxDialog: LocatorObject = {
locator: '.VotingRegTxDialog_dialog',
method: 'css',
};

export const votingRegTxDialogError: LocatorObject = {
locator: '.VotingRegTxDialog_error',
method: 'css',
};

export const qrCodeDialog: LocatorObject = { locator: '.QrCodeDialog_dialog', method: 'css' };

export const errorBlock: LocatorObject = { locator: '.ErrorBlock_component > span', method: 'css' };
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Given(/^I am on the "Terms of use" screen$/, async function () {

When(/^I click on "I agree with the terms of use" checkbox$/, async function () {
this.webDriverLogger.info(`Step: I click on "I agree with the terms of use" checkbox`);
const checkbox = await getTosCheckbox();
await this.waitForElement(termsOfUseComponent);
const checkbox = await getTosCheckbox(this);
await checkbox.click();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import { Given, When, Then } from 'cucumber';
import { expect } from 'chai';
import languageSelection, { clickContinue } from '../support/helpers/language-selection-helpers';
import { ensureLanguageIsSelected } from '../support/helpers/language-selection-helpers';
import {
confirmSelectedLanguageButton,
japaneseLaguageSelection,
languageSelectionForm,
languageSelectionFromDropdown,
} from '../pages/basicSetupPage';

Given(/^I have selected English language$/, async function () {
await languageSelection.ensureLanguageIsSelected(this, { language: 'en-US' });
await ensureLanguageIsSelected(this, { language: 'en-US' });
});

When(/^I am on the language selection screen$/, async function () {
Expand All @@ -22,11 +23,11 @@ When(/^I open language selection dropdown$/, async function () {
});

When(/^I select Japanese language$/, async function () {
return this.click(japaneseLaguageSelection);
await this.click(japaneseLaguageSelection);
});

When(/^I submit the language selection form$/, async function () {
await clickContinue(this);
await this.click(confirmSelectedLanguageButton);
});

Then(/^I should not see the language selection screen anymore$/, async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ import { When, Then } from 'cucumber';
import { By, Key } from 'selenium-webdriver';
import { votingTab } from '../pages/walletPage';
import {
confirmPinButton,
confirmButton,
confirmPinDialog,
confirmPinDialogError,
errorBlock,
generatedPinButton,
generatedPinStepElement,
generatePinDialog,
pinInput,
qrCodeDialog,
registerButton,
registerDialog,
registerDialogNextButton,
votingRegTxDialog,
votingRegTxDialogError,
} from '../pages/walletVotingPage';
import i18n from '../support/helpers/i18n-helpers';
import { expect } from 'chai';

When(/^I go to the voting page$/, async function () {
await this.click(votingTab);
Expand All @@ -41,7 +40,7 @@ Then(/^I see the Auto generated Pin Steps$/, async function () {
});

When(/^I click next on the generated pin step$/, async function () {
await this.click(generatedPinButton);
await this.click(confirmButton);
});

Then(/^I see the confirm Pin step$/, async function () {
Expand All @@ -54,15 +53,15 @@ Then(/^I enter the generated pin$/, async function () {
});

When(/^I click next on the confirm pin step$/, async function () {
await this.click(confirmPinButton);
await this.click(confirmButton);
});

Then(/^I see register step with spending password$/, async function () {
await this.waitForElement(registerDialog);
});

When(/^I click next on the register step$/, async function () {
await this.click(registerDialogNextButton);
await this.click(confirmButton);
});

Then(/^I see confirm transaction step$/, async function () {
Expand All @@ -80,12 +79,13 @@ Then(/^I enter the wrong pin$/, async function () {
});

Then(/^I see should see pin mismatch error$/, async function () {
const errorMessage = await i18n.formatMessage(this.driver, {
const expectedErrorMessage = await i18n.formatMessage(this.driver, {
id: 'global.errors.pinDoesNotMatch',
});

// following selector is used as the error is deeply nested
await this.waitUntilText(confirmPinDialogError, errorMessage);
await this.waitForElement(confirmPinDialogError);
const realErrorMessage = await this.getText(confirmPinDialogError);
expect(realErrorMessage, 'The error message is different').to.be.equal(expectedErrorMessage);

// clear the wrong pin at the end
// we are doing backspace 4 times for pin length of 4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
// @flow

import i18n from './i18n-helpers';
import { By } from 'selenium-webdriver';
import { languageSelectionForm } from '../../pages/basicSetupPage';
import {
languageSelectionForm,
confirmSelectedLanguageButton
} from '../../pages/basicSetupPage';

const LANGUAGE_SELECTION_FORM = '.LanguageSelectionForm_component';

const languageSelection = {
waitForVisible: async (
client: any,
{ isHidden }: {| isHidden: boolean, |} = {}
): Promise<void> => {
if (isHidden) {
return client.waitForElementNotPresent(languageSelectionForm);
}
return client.waitForElement(languageSelectionForm);
},
ensureLanguageIsSelected: async (
client: any,
{ language }: {| language: string, |} = {}
): Promise<void> => {
await languageSelection.waitForVisible(client.driver);
await i18n.setActiveLanguage(client.driver, { language });
await clickContinue(client);
await languageSelection.waitForVisible(client.driver, { isHidden: true });
export const waitForVisibleLanguageSelection = async (
customWorld: any,
{ isHidden }: {| isHidden: boolean, |} = {}
): Promise<void> => {
if (isHidden) {
return customWorld.waitForElementNotPresent(languageSelectionForm);
}
return customWorld.waitForElement(languageSelectionForm);
};

export const clickContinue = async (world: Object) => {
const parentComponent = await world.driver.findElement(By.css(LANGUAGE_SELECTION_FORM));
const continueButton = await parentComponent.findElement(By.xpath('//button'));
await continueButton.click();
}

export default languageSelection;
export const ensureLanguageIsSelected = async (
customWorld: any,
{ language }: {| language: string, |}
): Promise<void> => {
await waitForVisibleLanguageSelection(customWorld);
await i18n.setActiveLanguage(customWorld.driver, { language });
await customWorld.click(confirmSelectedLanguageButton);
await waitForVisibleLanguageSelection(customWorld, { isHidden: true });
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import BigNumber from 'bignumber.js';
import { expect } from 'chai';
import { truncateAddress } from '../../../app/utils/formatters';
import {
networks,
Expand Down Expand Up @@ -77,10 +78,14 @@ export async function checkTotalAmountIsCorrect(
const decimalPlaces = assetInfo.Metadata.numberOfDecimals;
const ticker = getTokenName(assetInfo);
const amountPerUnit = new BigNumber(10).pow(decimalPlaces);
const totalAmountFormatted = `${totalAmount
const expectedTotalAmountFormatted = `${totalAmount
.dividedBy(amountPerUnit)
.toFormat(decimalPlaces)} ${ticker}`;
await world.waitUntilText(amountField, totalAmountFormatted);

await world.waitForElement(amountField);
const realAmountText = await world.getText(amountField);

expect(expectedTotalAmountFormatted).to.be.equal(realAmountText);
}

export async function checkFinalBalanceIsCorrect(
Expand All @@ -99,7 +104,10 @@ export async function checkFinalBalanceIsCorrect(
const network = networks.CardanoMainnet;
const assetInfo = defaultAssets.filter(asset => asset.NetworkId === network.NetworkId)[0];
const ticker = getTokenName(assetInfo);
const finalBalance = `${finalAmount} ${ticker}`;
const expectedBalance = `${finalAmount} ${ticker}`;

await world.waitForElement(totalAmountField);
const realFinalBalanceText = await world.getText(totalAmountField);

await world.waitUntilText(totalAmountField, finalBalance);
expect(expectedBalance).to.be.equal(realFinalBalanceText);
}

0 comments on commit fe1c843

Please sign in to comment.