Skip to content

Commit

Permalink
Merge branch 'main' into fix/6537
Browse files Browse the repository at this point in the history
  • Loading branch information
blackdevelopa authored Jun 13, 2023
2 parents 51854da + 1b79574 commit 13dc253
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 78 deletions.
44 changes: 37 additions & 7 deletions wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ dotenv.config({ path: '.e2e.env' });
import generateTestReports from './wdio/utils/generateTestReports';
import ADB from 'appium-adb';
import { gasApiDown, cleanAllMocks } from './wdio/utils/mocks';
import {
startGanache,
stopGanache,
deployMultisig,
deployErc20,
} from './wdio/utils/ganache';
const { removeSync } = require('fs-extra');

export const config = {
Expand Down Expand Up @@ -272,7 +278,6 @@ export const config = {
return capabilities.platformName;
};
const adb = await ADB.createADB();
await adb.reversePort(8000, 8000);
await adb.reversePort(8545, 8545);
},
/**
Expand All @@ -296,9 +301,26 @@ export const config = {
* @param {ITestCaseHookParameter} world world object containing information on pickle and test step
* @param {Object} context Cucumber World object
*/
beforeScenario: ({tags: '@gasApiDown'}, async function (world, context) {
context.mock = gasApiDown();
}),
beforeScenario: async function (world, context) {
const tags = world.pickle.tags;

if(tags.filter(e => e.name === '@ganache').length > 0){
await startGanache();
}

if(tags.filter(e => e.name === '@multisig').length > 0){
const multisig = await deployMultisig();
context.multisig = multisig;
}

if(tags.filter(e => e.name === '@erc20').length > 0){
context.erc20 = await deployErc20();
}

if(tags.filter(e => e.name === '@gasApiDown').length > 0){
context.mock = gasApiDown();
}
},
/**
*
* Runs before a Cucumber Step.
Expand Down Expand Up @@ -331,9 +353,17 @@ export const config = {
* @param {number} result.duration duration of scenario in milliseconds
* @param {Object} context Cucumber World object
*/
afterScenario: ({tags: '@mock'}, async function (world, result, context) {
cleanAllMocks();
}),
afterScenario: async function (world, context) {
const tags = world.pickle.tags;

if(tags.filter(e => e.name === '@ganache').length > 0){
await stopGanache();
}

if(tags.filter(e => e.name === '@mock').length > 0){
cleanAllMocks();
}
},
/**
*
* Runs after a Cucumber Feature.
Expand Down
14 changes: 5 additions & 9 deletions wdio/features/Confirmations/ApproveERC20.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@
@confirmations
@regression

Feature: Approving an ERC20 token from a dapp
Feature: Approve an ERC20 token from a dapp
A user should be able to approve an ERC20 token from a dapp.

Scenario: Import wallet
@ganache
@erc20
Scenario: should approve successfully the default token amount suggested by the dapp
Given the app displayed the splash animation
And I have imported my wallet
And I tap No Thanks on the Enable security check screen
And I tap No thanks on the onboarding welcome tutorial

Scenario: Approve an ERC20 token from a dapp with default amount
Given Ganache server is started
And I close the Whats New modal
And Ganache network is selected
And ERC20 token contract is deployed
When I navigate to the browser
And I am on Home MetaMask website
And I navigate to "test-dapp-erc20"
And I connect my active wallet to the test dapp
And I scroll to the ERC20 section
And I approve ERC20 tokens
Then the transaction is submitted with Transaction Complete! toast appearing
Then Ganache server is stopped
Then the transaction is submitted with Transaction Complete! toast appearing
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,21 @@
@confirmations
@regression

Feature: Sending an ERC20 token from a dapp
A user should be able to send an ERC20 token from a dapp.

Scenario: Import wallet
Feature: Send an ERC20 token
A user should be able to send an ERC20.
@ganache
@erc20
Scenario: should successfully send an ERC20 token from a dapp
Given the app displayed the splash animation
And I have imported my wallet
And I tap No Thanks on the Enable security check screen
And I tap No thanks on the onboarding welcome tutorial

Scenario: Send ERC20 token from a dapp
Given Ganache server is started
And I close the Whats New modal
Given I close the Whats New modal
And Ganache network is selected
And ERC20 token contract is deployed
When I navigate to the browser
And I am on Home MetaMask website
When I navigate to "test-dapp-erc20"
And I connect my active wallet to the test dapp
And I scroll to the ERC20 section
And I transfer ERC20 tokens
Then the transaction is submitted with Transaction Complete! toast appearing
Then Ganache server is stopped
Then the transaction is submitted with Transaction Complete! toast appearing
21 changes: 7 additions & 14 deletions wdio/features/Confirmations/SendEthEOA.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,24 @@
@confirmations
@regression

Feature: Sending ETH to an EOA
Feature: Send ETH to an EOA
A user should be able to send ETH to another EOA address.

Scenario: Import wallet
@ganache
Scenario: should successfully send ETH to an EOA from inside MetaMask wallet
Given the app displayed the splash animation
And I have imported my wallet
And I tap No Thanks on the Enable security check screen
And I tap No thanks on the onboarding welcome tutorial

Scenario Outline: Sending ETH to an EOA from inside MetaMask wallet
Given Ganache server is started
And I close the Whats New modal
And Ganache network is selected
When On the Main Wallet view I tap on the Send Action
And I enter address "<Address>" in the sender's input box
And I enter address "0x1FDb169Ef12954F20A15852980e1F0C122BfC1D6" in the sender's input box
And I tap button "Next" on Send To view
Then I proceed to the amount view
When I type amount "<Amount>" into amount input field
When I type amount "1" into amount input field
And I tap button "Next" on the Amount view
Then I should be taken to the transaction confirmation view
And the token amount <Amount> to be sent is visible
And the token amount 1 to be sent is visible
When I tap button "Send" on Confirm Amount view
Then I am on the main wallet view
And the transaction is submitted with Transaction Complete! toast appearing
Then Ganache server is stopped
Examples:
| Address | Amount |
| 0x1FDb169Ef12954F20A15852980e1F0C122BfC1D6 | 1 |
And the transaction is submitted with Transaction Complete! toast appearing
16 changes: 6 additions & 10 deletions wdio/features/Confirmations/SendEthGasApiDown.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
@confirmations
@regression

Feature: Sending ETH when Gas API is down
Feature: Send ETH with Gas API down
A user should be able to send ETH when the Gas API is down.

Scenario: Import wallet
@ganache
@mock
@gasApiDown
Scenario: should display fallback gas properties on the Gas Edit screen
Given the app displayed the splash animation
And I have imported my wallet
And I tap No Thanks on the Enable security check screen
And I tap No thanks on the onboarding welcome tutorial

@mock
@gasApiDown
Scenario: Display fallback on the Gas Edit screen
Given Ganache server is started
And I close the Whats New modal
And Ganache network is selected
When On the Main Wallet view I tap on the Send Action
Expand All @@ -30,5 +27,4 @@ Feature: Sending ETH when Gas API is down
When I tap Save Gas Values
When I tap button "Send" on Confirm Amount view
Then I am on the main wallet view
And the transaction is submitted with Transaction Complete! toast appearing
And Ganache server is stopped
And the transaction is submitted with Transaction Complete! toast appearing
21 changes: 7 additions & 14 deletions wdio/features/Confirmations/SendEthMultisig.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,25 @@
@confirmations
@regression

Feature: Sending ETH to a Multisig
Feature: Send ETH to a Multisig
A user should be able to send ETH to a Multisig address.

Scenario: Import wallet
@ganache
@multisig
Scenario: should successfully send ETH to a Multisig address from inside MetaMask wallet
Given the app displayed the splash animation
And I have imported my wallet
And I tap No Thanks on the Enable security check screen
And I tap No thanks on the onboarding welcome tutorial

Scenario Outline: Sending ETH to a Multisig address from inside MetaMask wallet
Given Ganache server is started
And I close the Whats New modal
And Ganache network is selected
And Multisig contract is deployed
When On the Main Wallet view I tap on the Send Action
And I enter address "MultisigAddress" in the sender's input box
When I tap button "Next" on Send To view
Then I proceed to the amount view
When I type amount "<Amount>" into amount input field
When I type amount "1" into amount input field
And I tap button "Next" on the Amount view
Then I should be taken to the transaction confirmation view
And the token amount <Amount> to be sent is visible
And the token amount 1 to be sent is visible
When I tap button "Send" on Confirm Amount view
Then I am on the main wallet view
And the transaction is submitted with Transaction Complete! toast appearing
Then Ganache server is stopped
Examples:
| Amount |
| 1 |
And the transaction is submitted with Transaction Complete! toast appearing
1 change: 0 additions & 1 deletion wdio/screen-objects/TransactionConfirmScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
import { ESTIMATED_FEE_TEST_ID } from './testIDs/Screens/TransactionSummaryScreen.testIds';
import { MAX_PRIORITY_FEE_INPUT_TEST_ID, SAVE_GAS_FEE_TEST_ID } from './testIDs/Screens/EditGasFeeScreen.testids';
import Gestures from '../helpers/Gestures';
import { ESTIMATED_FEE_TEST_ID } from './testIDs/Screens/TransactionSummaryScreen.testIds';

class TransactionConfirmScreen {
get confirmAmount() {
Expand Down
2 changes: 1 addition & 1 deletion wdio/step-definitions/send-flow.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Then(/^I tap the Save button/, async () => {

Given(
/^I enter address "([^"]*)?" in the sender's input box/,
async (address) => {
async function (address) {
await CommonScreen.checkNoNotification(); // Notification appears a little late and inteferes with clicking function
switch (address) {
case 'MultisigAddress':
Expand Down
23 changes: 12 additions & 11 deletions wdio/step-definitions/ganache-steps.js → wdio/utils/ganache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Given, Then } from '@wdio/cucumber-framework';
import Accounts from '../helpers/Accounts';
import Ganache from '../../app/util/test/ganache';
import { SMART_CONTRACTS } from '../../app/util/test/smart-contracts';
Expand All @@ -7,24 +6,26 @@ import GanacheSeeder from '../../app/util/test/ganache-seeder';
const ganacheServer = new Ganache();
const validAccount = Accounts.getValidAccount();

Given(/^Ganache server is started$/, async () => {
export const startGanache = async () => {
await ganacheServer.start({ mnemonic: validAccount.seedPhrase });
});
}

Then(/^Ganache server is stopped$/, async () => {
export const stopGanache = async () => {
await ganacheServer.quit();
});
}

Given(/^Multisig contract is deployed$/, async function() {
export const deployMultisig = async () => {
const ganacheSeeder = await new GanacheSeeder(ganacheServer.getProvider());
await ganacheSeeder.deploySmartContract(SMART_CONTRACTS.MULTISIG);
const contractRegistry = ganacheSeeder.getContractRegistry();
this.multisig = await contractRegistry.getContractAddress(SMART_CONTRACTS.MULTISIG);
});
const multisigAddress = await contractRegistry.getContractAddress(SMART_CONTRACTS.MULTISIG);
return multisigAddress;
}

Given(/^ERC20 token contract is deployed$/, async function() {
export const deployErc20 = async () => {
const ganacheSeeder = await new GanacheSeeder(ganacheServer.getProvider());
await ganacheSeeder.deploySmartContract(SMART_CONTRACTS.HST);
const contractRegistry = ganacheSeeder.getContractRegistry();
this.erc20 = await contractRegistry.getContractAddress(SMART_CONTRACTS.HST);
});
const erc20Address = await contractRegistry.getContractAddress(SMART_CONTRACTS.HST);
return erc20Address;
}

0 comments on commit 13dc253

Please sign in to comment.