Skip to content

Commit 104176e

Browse files
feat: allow fixtures on E2E (#1268)
* feat: update locators and toggle fixtures to use with simulator * feat: use path aliases for readable imports, prepare MWC e2e tests * feat: update run script and work in progress for the new test structure * feat: extends path usage, creates the first tests for playground-next * feat: implements personalSign on the playground-next for e2e usage * feat: always display terminate to avoid flaky tests * feat: removes unecessary logs * feat: work in progress * feat: updates the Utils package to allow to start the app with fixtures * chore: updates koa to solve vulnerability * chore: updates configs and adds a logger * chore: removes non needed references in the code * chore: fixes dependency list * chore: removes unused page object models * feat: adds context switching feature to improve flakiness * feat: add new dapp requirements * feat: cleans wdio configs * chore: updates locators * chore: removes unused test dapp reference * feat: adds automatic context switching via helpers
1 parent e1764d4 commit 104176e

74 files changed

Lines changed: 3901 additions & 2838 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

e2e/.dapps.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DEVNEXT_DAPP_URL=http://192.111.111.111:3333/demo
1+
METAMASK_TEST_DAPP_URL=http://192.111.111.111:3333

e2e/.ios.env.example

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BUNDLE_ID=
2-
DEVICE_NAME=
3-
PLATFORM_VERSION=
4-
APP_PATH=
5-
AUTOMATION_NAME=
2+
DEVICE_NAME=iPhone 16 Pro
3+
PLATFORM_VERSION=18.2
4+
APP_PATH=METAMASK_APP_PATH
5+
AUTOMATION_NAME=XCUITest
66
DEVICE_UDID=
77

e2e/README.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Node version
44

5-
`nvm use 18`
5+
`nvm use 20`
66

77
### Setup:
88

@@ -12,38 +12,29 @@
1212

1313
`export SRP=TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST`
1414

15-
### Env files needed:
15+
## Create an iOS simulator and Android emulator
1616

17-
.ios.env:
1817

19-
- BUNDLE_ID=
20-
- DEVICE_NAME=
21-
- PLATFORM_VERSION=
22-
- APP_PATH=
23-
- AUTOMATION_NAME=
24-
- DEVICE_UDID=
18+
### Complete your platform related env files:
19+
`cp .ios.env.example .ios.env`
2520

26-
.android.env:
27-
28-
- BUNDLE_ID=
29-
- DEVICE_NAME=
30-
- PLATFORM_VERSION=
31-
- APP_PATH=
32-
- AUTOMATION_NAME=
33-
- APP_ACTIVITY=
21+
`cp .android.env.example .android.env`
3422

3523
.dapps.env:
24+
```
25+
DEVNEXT_DAPP_URL=
26+
WAGMI_TEST_DAPP_URL=
27+
```
3628

37-
- REACT_DAPP_URL=
38-
- TEST_DAPP_URL=
29+
# iOS
30+
### Create an iOS simulator
3931

40-
.env:
32+
### Run tests on iOS:
4133

42-
- BROWSERSTACK_USERNAME=
43-
- BROWSERSTACK_ACCESS_KEY=
34+
`yarn test:ios:jssdk:e2e:local`
4435

45-
### Run tests:
36+
### Run tests on Android:
4637

47-
`yarn test:ios`
38+
`yarn test:android:jssdk:e2e:local`
4839

4940
#### Currently setup to run locally

e2e/babel.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
},
10+
],
11+
'@babel/preset-typescript',
12+
],
13+
plugins: [
14+
[
15+
'module-resolver',
16+
{
17+
root: ['.'],
18+
alias: {
19+
'@': './test',
20+
'@util': './util',
21+
'@specs': './test/specs',
22+
'@screens': './src/screens',
23+
'@fixtures': './src/fixtures',
24+
},
25+
},
26+
],
27+
],
28+
};

e2e/package.json

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,52 @@
22
"name": "metamask-sdk-e2e",
33
"private": true,
44
"type": "commonjs",
5+
"scripts": {
6+
"test:ios:metamask-connector:e2e:local": "wdio run test/configs/local/wdio.ios.app.local.conf.ts --suite metamask_connector",
7+
"test:ios:metamask-connector:e2e:browserstack": "wdio run test/configs/browserstack/wdio.ios.app.browserstack.conf.ts --suite metamask_connector",
8+
"test:android:metamask-connector:e2e:local": "wdio run test/configs/local/wdio.android.app.local.conf.ts --suite metamask_connector",
9+
"test:android:metamask-connector:e2e:browserstack": "wdio run test/configs/browserstack/wdio.android.app.browserstack.conf.ts --suite metamask_connector",
10+
"setup": "yarn install",
11+
"build": "tsc --build",
12+
"clean": "yarn clean:reports && rm -rf node_modules",
13+
"clean:reports": "rm -rf allure-results",
14+
"clean:build": "tsc --build --clean",
15+
"allow-scripts": ""
16+
},
517
"devDependencies": {
18+
"@babel/preset-env": "^7.26.0",
19+
"@babel/preset-typescript": "^7.26.0",
20+
"@metamask/eslint-config": "11.1.0",
21+
"@metamask/eslint-config-nodejs": "11.1.0",
22+
"@metamask/eslint-config-typescript": "11.1.0",
623
"@types/koa": "^2.13.12",
24+
"@types/lodash.merge": "4.6.9",
25+
"@types/module-alias": "^2.0.4",
26+
"@typescript-eslint/eslint-plugin": "5.61.0",
27+
"@typescript-eslint/parser": "5.61.0",
728
"@wdio/allure-reporter": "^8.11.0",
829
"@wdio/appium-service": "^9.2.1",
930
"@wdio/browserstack-service": "^9.1.2",
1031
"@wdio/cli": "latest",
32+
"@wdio/globals": "8.24.6",
1133
"@wdio/local-runner": "latest",
1234
"@wdio/mocha-framework": "latest",
1335
"@wdio/spec-reporter": "latest",
14-
"ts-node": "^10.9.1",
36+
"allure-commandline": "2.23.0",
37+
"appium-adb": "11.0.8",
38+
"babel-plugin-module-resolver": "^5.0.2",
39+
"dotenv": "16.0.3",
40+
"eslint": "8.44.0",
41+
"eslint-config-prettier": "8.8.0",
42+
"eslint-plugin-import": "2.27.5",
43+
"eslint-plugin-jsdoc": "46.4.3",
44+
"eslint-plugin-prettier": "4.2.1",
45+
"koa": "2.14.2",
46+
"module-alias": "^2.2.3",
47+
"prettier": "2.8.8",
48+
"ts-node": "^10.9.2",
1549
"typescript": "^4.9.5",
16-
"wdio-wait-for": "^3.0.9"
17-
},
18-
"scripts": {
19-
"test:android:jssdk:e2e:browserstack": "wdio run test/configs/browserstack/wdio.android.app.browserstack.conf.ts --suite web_dapp",
20-
"test:ios:jssdk:e2e:browserstack": "wdio run test/configs/browserstack/wdio.ios.app.browserstack.conf.ts --suite web_dapp",
21-
"test:ios:jssdk:e2e:local": "wdio run test/configs/local/wdio.ios.app.local.conf.ts --suite web_dapp",
22-
"test:android:jssdk:e2e:local": "wdio run test/configs/local/wdio.android.app.local.conf.ts --suite web_dapp",
23-
"setup": "yarn install",
24-
"build": "tsc --build",
25-
"clean": "yarn clean:reports && rm -rf node_modules",
26-
"clean:reports": "rm -rf allure-results",
27-
"clean:build": "tsc --build --clean",
28-
"allow-scripts": ""
29-
},
30-
"dependencies": {
31-
"@metamask/eslint-config": "^11.1.0",
32-
"@metamask/eslint-config-nodejs": "^11.1.0",
33-
"@metamask/eslint-config-typescript": "^11.1.0",
34-
"@types/lodash.merge": "^4.6.9",
35-
"@typescript-eslint/eslint-plugin": "^5.61.0",
36-
"@typescript-eslint/parser": "^5.61.0",
37-
"@wdio/globals": "^8.24.6",
38-
"allure-commandline": "^2.23.0",
39-
"appium-adb": "^11.0.8",
40-
"axios": "^1.6.2",
41-
"dotenv": "^16.0.3",
42-
"eslint": "^8.44.0",
43-
"eslint-config-prettier": "^8.8.0",
44-
"eslint-plugin-import": "^2.27.5",
45-
"eslint-plugin-jsdoc": "^46.4.3",
46-
"eslint-plugin-prettier": "^4.2.1",
47-
"koa": "^2.14.2",
48-
"prettier": "^2.8.8",
49-
"webdriverio": "^9.2.1"
50+
"wdio-wait-for": "^3.0.9",
51+
"webdriverio": "9.2.1"
5052
}
5153
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import axios from 'axios';
2-
import { FIXTURE_SERVER_URL } from '../../src/Constants';
3-
import FixtureServer from './FixtureServer';
4-
import { FixtureBuilder } from './FixtureBuilder';
1+
import FixtureServer from '@fixtures/FixtureServer';
2+
import { FixtureBuilder } from '@fixtures/FixtureBuilder';
3+
import { FIXTURE_SERVER_URL } from '@util/Constants';
54

65
// checks if server has already been started
76
const isFixtureServerStarted = async () => {
87
try {
9-
const response = await axios.get(FIXTURE_SERVER_URL);
10-
return response.status === 200;
8+
const response = await fetch(FIXTURE_SERVER_URL);
9+
return response.ok;
1110
} catch (error) {
1211
return false;
1312
}
@@ -22,10 +21,10 @@ export const loadFixture = async (
2221
const state = fixture || new FixtureBuilder().build();
2322
fixtureServer.loadJsonState(state);
2423
// Checks if state is loaded
25-
const response = await axios.get(FIXTURE_SERVER_URL);
24+
const response = await fetch(FIXTURE_SERVER_URL);
2625

2726
// Throws if state is not properly loaded
28-
if (response.status !== 200) {
27+
if (!response.ok) {
2928
throw new Error('Not able to load fixtures');
3029
}
3130
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Koa from 'koa';
22
import * as http from "http";
3-
import { FIXTURE_SERVER_HOST, FIXTURE_SERVER_PORT } from '../../src/Constants';
3+
import { FIXTURE_SERVER_HOST, FIXTURE_SERVER_PORT } from '@util/Constants';
44

55
const CURRENT_STATE_KEY = '__CURRENT__';
66
const DEFAULT_STATE_KEY = '__DEFAULT__';

e2e/src/screens/Android/AndroidSettingsOpeningLinksScreen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { ChainablePromiseElement } from 'webdriverio';
2-
import { METAMASK_APP_NAME_ANDROID } from '../../Constants';
3-
import Gestures from '../../Gestures';
4-
import { getSelectorForPlatform } from '../../Utils';
5-
import { AndroidSelector } from '../../Selectors';
2+
import { METAMASK_APP_NAME_ANDROID } from '@util/Constants';
3+
import Gestures from '@util/Gestures';
4+
import { getSelectorForPlatform } from '@util/Utils';
5+
import { AndroidSelector } from '@util/Selectors';
66

77
class AndroidSettingsOpeningLinksScreen {
88
get openingLinksMetaMaskAppOption(): ChainablePromiseElement {

e2e/src/screens/Android/AndroidSettingsScreen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { ChainablePromiseArray, ChainablePromiseElement } from 'webdriverio';
22

33
import { $$ } from '@wdio/globals';
4-
import Gestures from '../../Gestures';
5-
import { getSelectorForPlatform } from '../../Utils';
4+
import Gestures from '@util/Gestures';
5+
import { getSelectorForPlatform } from '@util/Utils';
66
import {
77
IS_RUNNING_IN_BROWSER_STACK,
88
METAMASK_APP_NAME_ANDROID,
9-
} from '../../Constants';
10-
import { AndroidSelector } from '../../Selectors';
9+
} from '@util/Constants';
10+
import { AndroidSelector } from '@util/Selectors';
1111

1212
class AndroidSettingsScreen {
1313
get metaMaskQALinksButton(): ChainablePromiseElement {

0 commit comments

Comments
 (0)