1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

Remove integration tests (#8959)

The remaining integration tests are all covered by e2e tests, so
they're no longer needed.

All associated scripts, fixtures, and dependencies have also been
removed.
This commit is contained in:
Mark Stacey 2020-07-10 12:22:36 -03:00 committed by GitHub
parent d53c4f824e
commit 2856af2336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 35 additions and 3868 deletions

View File

@ -19,9 +19,6 @@ workflows:
- prep-build-storybook:
requires:
- prep-deps
- prep-scss:
requires:
- prep-deps
- test-lint:
requires:
- prep-deps
@ -45,14 +42,6 @@ workflows:
requires:
- prep-deps
- prep-build
- test-integration-flat-chrome:
requires:
- prep-deps
- prep-scss
- test-integration-flat-firefox:
requires:
- prep-deps
- prep-scss
- all-tests-pass:
requires:
- test-lint
@ -63,8 +52,6 @@ workflows:
- test-mozilla-lint
- test-e2e-chrome
- test-e2e-firefox
- test-integration-flat-chrome
- test-integration-flat-firefox
- benchmark:
requires:
- prep-build-test
@ -176,25 +163,6 @@ jobs:
paths:
- .out
prep-scss:
docker:
- image: circleci/node@sha256:e16740707de2ebed45c05d507f33ef204902349c7356d720610b5ec6a35d3d88
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Get Scss Cache key
# this allows us to checksum against a whole directory
command: find ui/app/css -type f -exec md5sum {} \; | sort -k 2 > scss_checksum
- run:
name: Build for integration tests
command: yarn test:integration:build
- persist_to_workspace:
root: .
paths:
- ui/app/css/output
test-lint:
docker:
- image: circleci/node@sha256:e16740707de2ebed45c05d507f33ef204902349c7356d720610b5ec6a35d3d88
@ -401,33 +369,6 @@ jobs:
name: test:mozilla-lint
command: NODE_OPTIONS=--max_old_space_size=3072 yarn mozilla-lint
test-integration-flat-firefox:
docker:
- image: circleci/node@sha256:e16740707de2ebed45c05d507f33ef204902349c7356d720610b5ec6a35d3d88
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Install Firefox
command: ./.circleci/scripts/firefox-install
- run:
name: test:integration:flat
command: yarn test:flat
test-integration-flat-chrome:
environment:
browsers: '["Chrome"]'
docker:
- image: circleci/node@sha256:e16740707de2ebed45c05d507f33ef204902349c7356d720610b5ec6a35d3d88
steps:
- checkout
- attach_workspace:
at: .
- run:
name: test:integration:flat
command: yarn test:flat
all-tests-pass:
docker:
- image: circleci/node@sha256:e16740707de2ebed45c05d507f33ef204902349c7356d720610b5ec6a35d3d88

View File

@ -7,17 +7,10 @@ test-builds/**
docs/**
coverage/
development/bundle.js
development/states.js
app/scripts/lib/extension-instance.js
app/scripts/chromereload.js
app/vendor/**
ui/lib/blockies.js
test/integration/bundle.js
test/integration/jquery-3.1.0.min.js
test/integration/helpers.js
package-lock.json

7
.gitignore vendored
View File

@ -32,13 +32,6 @@ dist
builds/
builds.zip
development/bundle.js
development/states.js
test/integration/bundle.js
test/background.js
test/bundle.js
test/test-bundle.js
test-artifacts
test-builds

View File

@ -1,26 +0,0 @@
module.exports = {
'confirm sig requests': {
signMessage: (_, cb) => {
const stateUpdate = {
unapprovedMsgs: {},
unapprovedMsgCount: 0,
}
return cb(null, stateUpdate)
},
signPersonalMessage: (_, cb) => {
const stateUpdate = {
unapprovedPersonalMsgs: {},
unapprovedPersonalMsgCount: 0,
}
return cb(null, stateUpdate)
},
signTypedMessage: (_, cb) => {
const stateUpdate = {
unapprovedTypedMessages: {},
unapprovedTypedMessagesCount: 0,
}
return cb(null, stateUpdate)
},
},
}

View File

@ -1,27 +0,0 @@
/* eslint-disable import/no-dynamic-require */
const fs = require('fs')
const path = require('path')
const promisify = require('pify')
const enLocaleMessages = require('../app/_locales/en/messages.json')
const writeFile = promisify(fs.writeFile)
start().catch(console.error)
async function start () {
const statesPath = path.join(__dirname, 'states')
const stateFilesNames = await promisify(fs.readdir)(statesPath)
const states = {}
await Promise.all(stateFilesNames.map(async (stateFileName) => {
const stateFilePath = path.join(__dirname, 'states', stateFileName)
const state = require(stateFilePath)
state.localeMessages = { en: enLocaleMessages, current: {} }
const stateName = stateFileName.split('.')[0].replace(/-/g, ' ', 'g')
states[stateName] = state
}))
const generatedFileContent = `module.exports = ${JSON.stringify(states)}`
const generatedFilePath = path.join(__dirname, 'states.js')
await writeFile(generatedFilePath, generatedFileContent)
}

View File

@ -1,60 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>MetaMask</title>
</head>
<body>
<script src="./bundle.js" type="text/javascript" charset="utf-8"></script>
<style>
html, body, #test-container, .super-dev-container {
height: 100%;
width: 100%;
position: relative;
background: white;
}
#app-content {
background: #F7F7F7;
}
</style>
<script>
liveReloadCode(Date.now(), 300)
function liveReloadCode(lastUpdate, updateRate) {
setTimeout(iter, updateRate)
function iter() {
var xhr = new XMLHttpRequest()
xhr.open('GET', '/-/live-reload')
xhr.onreadystatechange = function() {
if(xhr.readyState !== 4) {
return
}
try {
var change = JSON.parse(xhr.responseText).lastUpdate
if(lastUpdate < change) {
return reload()
}
} catch(err) {
}
xhr =
xhr.onreadystatechange = null
setTimeout(iter, updateRate)
}
xhr.send(null)
}
}
function reload() {
window.location.reload()
}
</script>
</body>
</html>

View File

@ -1,156 +0,0 @@
/* MOCK DEV
*
* This is a utility module.
* It initializes a minimalist browserifiable project
* that contains the Metamask UI, with a local background process.
*
* Includes a state reset button for restoring to initial state.
*
* This is a convenient way to develop and test the plugin
* without having to re-open the plugin or even re-build it.
*/
import log from 'loglevel'
import React from 'react'
import { render } from 'react-dom'
import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import * as qs from 'qs'
import Selector from './selector'
import * as actions from '../ui/app/store/actions'
import Root from '../ui/app/pages'
import rootReducer from '../ui/app/ducks'
import MetamaskController from '../app/scripts/metamask-controller'
import firstTimeState from '../app/scripts/first-time-state'
import ExtensionPlatform from '../app/scripts/platforms/extension'
const backGroundConnectionModifiers = require('./backGroundConnectionModifiers')
const noop = function () {}
// the states file is generated before this file is run, but after `lint` is run
const states = require('./states') /* eslint-disable-line import/no-unresolved */
window.log = log
log.setLevel('debug')
const routerPath = window.location.href.split('#')[1]
let queryString = {}
let selectedView
if (routerPath) {
queryString = qs.parse(routerPath.split('?')[1])
}
selectedView = queryString.view || 'confirm sig requests'
const firstState = states[selectedView]
updateQueryParams(selectedView)
function updateQueryParams (newView) {
queryString.view = newView
const params = qs.stringify(queryString)
const locationPaths = window.location.href.split('#')
const routerPath = locationPaths[1] || ''
const newPath = locationPaths[0] + '#' + routerPath.split('?')[0] + `?${params}`
if (window.location.href !== newPath) {
window.location.href = newPath
}
}
//
// MetaMask Controller
//
// some extension platform APIs must be mocked
function mockPlatformApis () {
global.platform.getVersion = () => '0.0.0'
}
const controller = new MetamaskController({
// User confirmation callbacks:
showUnconfirmedMessage: noop,
showUnapprovedTx: noop,
platform: {},
// initial state
initState: firstTimeState,
})
global.metamaskController = controller
global.platform = new ExtensionPlatform()
mockPlatformApis()
//
// User Interface
//
actions._setBackgroundConnection(controller.getApi())
function updateState (stateName) {
selectedView = stateName
updateQueryParams(stateName)
const newState = states[selectedView]
return {
type: 'GLOBAL_FORCE_UPDATE',
value: newState,
}
}
function modifyBackgroundConnection (backgroundConnectionModifier) {
const modifiedBackgroundConnection = Object.assign({}, controller.getApi(), backgroundConnectionModifier)
actions._setBackgroundConnection(modifiedBackgroundConnection)
}
// parse opts
const store = createStore(
(state, action) =>
(action.type === 'GLOBAL_FORCE_UPDATE'
? action.value
: rootReducer(state, action)),
firstState,
applyMiddleware(thunkMiddleware),
)
// start app
startApp()
function startApp () {
const body = document.body
const container = document.createElement('div')
container.id = 'test-container'
body.appendChild(container)
render(
<div className="super-dev-container">
<button
onClick={(ev) => {
ev.preventDefault()
store.dispatch(updateState('terms'))
}}
style={{
margin: '19px 19px 0px 19px',
}}
>
Reset State
</button>
<Selector
states={states}
selectedKey={selectedView}
updateState={updateState}
store={store}
modifyBackgroundConnection={modifyBackgroundConnection}
backGroundConnectionModifiers={backGroundConnectionModifiers}
/>
<div
id="app-content"
style={{
height: '500px',
width: '360px',
boxShadow: 'grey 0px 2px 9px',
margin: '20px',
}}
>
<Root store={store} />
</div>
</div>,
container,
)
}

View File

@ -1,49 +0,0 @@
import PropTypes from 'prop-types'
import React, { Component } from 'react'
export default class Selector extends Component {
state = {}
render () {
const {
states,
selectedKey,
updateState,
store,
modifyBackgroundConnection,
backGroundConnectionModifiers,
} = this.props
const selected = this.state.selected || selectedKey
return (
<select
style={{ margin: '20px 20px 0px' }}
value={selected}
onChange={(event) => {
const selectedKey = event.target.value
const backgroundConnectionModifier = backGroundConnectionModifiers[selectedKey]
modifyBackgroundConnection(backgroundConnectionModifier || {})
store.dispatch(updateState(selectedKey))
this.setState({ selected: selectedKey })
}}
>
{Object.keys(states).map((stateName, index) => {
return (
<option key={index} value={stateName}>
{stateName}
</option>
)
})}
</select>
)
}
}
Selector.propTypes = {
states: PropTypes.object.isRequired,
selectedKey: PropTypes.string.isRequired,
updateState: PropTypes.func.isRequired,
store: PropTypes.object.isRequired,
modifyBackgroundConnection: PropTypes.func.isRequired,
backGroundConnectionModifiers: PropTypes.object.isRequired,
}

File diff suppressed because one or more lines are too long

View File

@ -1,482 +0,0 @@
{
"metamask": {
"completedOnboarding": true,
"isInitialized": true,
"isUnlocked": true,
"featureFlags": {"betaUI": true},
"rpcTarget": "https://rawtestrpc.metamask.io/",
"identities": {
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825": {
"address": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"name": "Send Account 1"
},
"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb": {
"address": "0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb",
"name": "Send Account 2"
},
"0x2f8d4a878cfa04a6e60d46362f5644deab66572d": {
"address": "0x2f8d4a878cfa04a6e60d46362f5644deab66572d",
"name": "Send Account 3"
},
"0xd85a4b6a394794842887b8284293d69163007bbb": {
"address": "0xd85a4b6a394794842887b8284293d69163007bbb",
"name": "Send Account 4"
}
},
"abTests": {
"fullScreenVsPopup": "control"
},
"cachedBalances": {},
"unapprovedTxs": {},
"conversionRate": 19855,
"conversionDate": 1489013762,
"noActiveNotices": true,
"frequentRpcList": [],
"network": "3",
"accounts": {
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825": {
"code": "0x",
"balance": "0x47c9d71831c76efe",
"nonce": "0x1b",
"address": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
},
"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb": {
"code": "0x",
"balance": "0x37452b1315889f80",
"nonce": "0xa",
"address": "0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb"
},
"0x2f8d4a878cfa04a6e60d46362f5644deab66572d": {
"code": "0x",
"balance": "0x30c9d71831c76efe",
"nonce": "0x1c",
"address": "0x2f8d4a878cfa04a6e60d46362f5644deab66572d"
},
"0xd85a4b6a394794842887b8284293d69163007bbb": {
"code": "0x",
"balance": "0x0",
"nonce": "0x0",
"address": "0xd85a4b6a394794842887b8284293d69163007bbb"
}
},
"addressBook": [
{
"address": "0x06195827297c7a80a443b6894d3bdb8824b43896",
"name": "Address Book Account 1"
}
],
"tokens": [],
"transactions": {},
"incomingTransactions": {},
"currentNetworkTxList": [],
"unapprovedMsgs": {},
"unapprovedMsgCount": 0,
"unapprovedPersonalMsgs": {},
"unapprovedPersonalMsgCount": 0,
"keyringTypes": [
"Simple Key Pair",
"HD Key Tree"
],
"keyrings": [
{
"type": "HD Key Tree",
"accounts": [
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb",
"0x2f8d4a878cfa04a6e60d46362f5644deab66572d"
]
},
{
"type": "Simple Key Pair",
"accounts": [
"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
]
}
],
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"currentCurrency": "PHP",
"provider": {
"type": "testnet"
},
"send": {
"gasLimit": null,
"gasPrice": null,
"gasTotal": "0xb451dc41b578",
"tokenBalance": null,
"from": "",
"to": "",
"amount": "0x0",
"memo": "",
"errors": {},
"warnings": {},
"maxModeOn": false,
"editingTransactionId": null
},
"currentLocale": "en",
"preferences": {
"useNativeCurrencyAsPrimaryCurrency": true,
"showFiatInTestnets": true
},
"frequentRpcListDetail": []
},
"appState": {
"menuOpen": false,
"currentView": {
"name": "accountDetail",
"detailView": null,
"context": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
},
"accountDetail": {
"subview": "transactions"
},
"sidebar": {},
"modal": {
"modalState": {},
"previousModalState": {}
},
"isLoading": false,
"warning": null,
"scrollToBottom": false,
"forgottenPassword": null
},
"identities": {},
"confirmTransaction": {
"txData": {},
"tokenData": {},
"methodData": {},
"tokenProps": {
"tokenDecimals": "",
"tokenSymbol": ""
},
"fiatTransactionAmount": "",
"fiatTransactionFee": "",
"fiatTransactionTotal": "",
"ethTransactionAmount": "",
"ethTransactionFee": "",
"ethTransactionTotal": "",
"hexGasTotal": "",
"nonce": "",
"fetchingMethodData": false
},
"gas": {
"customData": {
"price": null,
"limit": "0x186a0"
},
"basicEstimates": {
"average": 73,
"avgWait": 10.6,
"blockTime": 13.871657754010695,
"blockNum": 6655504,
"fast": 160,
"fastest": 290,
"fastestWait": 0.5,
"fastWait": 0.6,
"safeLow": 50,
"safeLowWait": 16.1,
"speed": 0.6702462692280712
},
"basicEstimateIsLoading": false,
"gasEstimatesLoading": false,
"priceAndTimeEstimates": [
{
"expectedTime": "1374.1168296452973076627",
"expectedWait": 99.0593088449,
"gasprice": 4.1
},
{
"expectedTime": "1280.88976972896682763716",
"expectedWait": 92.3386225672,
"gasprice": 4.4
},
{
"expectedTime": "1245.13314632680319175597",
"expectedWait": 89.7609477113,
"gasprice": 4.8
},
{
"expectedTime": "1227.99925007911014385881",
"expectedWait": 88.5257747744,
"gasprice": 4.9
},
{
"expectedTime": "965.52572720362993349654",
"expectedWait": 69.6042062402,
"gasprice": 5
},
{
"expectedTime": "917.466895447437420776",
"expectedWait": 66.1396721082,
"gasprice": 5.1
},
{
"expectedTime": "915.81694044041496090521",
"expectedWait": 66.0207277804,
"gasprice": 5.2
},
{
"expectedTime": "902.13145619709089691874",
"expectedWait": 65.034148924,
"gasprice": 5.3
},
{
"expectedTime": "890.83591122200105749896",
"expectedWait": 64.2198594443,
"gasprice": 5.4
},
{
"expectedTime": "879.10469542971335712248",
"expectedWait": 63.3741627006,
"gasprice": 5.5
},
{
"expectedTime": "876.99737395823100420974",
"expectedWait": 63.2222470818,
"gasprice": 5.6
},
{
"expectedTime": "865.96781957003849098957",
"expectedWait": 62.4271327138,
"gasprice": 5.7
},
{
"expectedTime": "865.44839472121496158482",
"expectedWait": 62.3896876688,
"gasprice": 5.8
},
{
"expectedTime": "802.16173170976255602161",
"expectedWait": 57.8273877524,
"gasprice": 6
},
{
"expectedTime": "780.79313908053047074843",
"expectedWait": 56.2869379368,
"gasprice": 6.1
},
{
"expectedTime": "770.04888359616469549233",
"expectedWait": 55.5123906062,
"gasprice": 6.2
},
{
"expectedTime": "745.01007965146736962697",
"expectedWait": 53.7073573226,
"gasprice": 6.3
},
{
"expectedTime": "735.19921111598501681816",
"expectedWait": 53.0000973318,
"gasprice": 6.6
},
{
"expectedTime": "705.68767153912619368694",
"expectedWait": 50.8726270539,
"gasprice": 6.7
},
{
"expectedTime": "705.26438593445239690121",
"expectedWait": 50.8421126329,
"gasprice": 6.9
},
{
"expectedTime": "652.51573119854865429742",
"expectedWait": 47.0394918019,
"gasprice": 7
},
{
"expectedTime": "635.51471669299464383162",
"expectedWait": 45.813898235,
"gasprice": 7.1
},
{
"expectedTime": "634.37181911960854759036",
"expectedWait": 45.7315073922,
"gasprice": 7.2
},
{
"expectedTime": "633.23097691113902888918",
"expectedWait": 45.6492647195,
"gasprice": 7.3
},
{
"expectedTime": "112.7753456245379663928",
"expectedWait": 8.1299111919,
"gasprice": 7.6
},
{
"expectedTime": "102.9665314468898381829",
"expectedWait": 7.4227992986,
"gasprice": 8
},
{
"expectedTime": "100.94784507024919649891",
"expectedWait": 7.2772733339,
"gasprice": 8.1
},
{
"expectedTime": "100.46445647447807351078",
"expectedWait": 7.2424261221,
"gasprice": 8.8
},
{
"expectedTime": "84.91686745986737853339",
"expectedWait": 6.1216091808,
"gasprice": 9
},
{
"expectedTime": "80.39566429296684383503",
"expectedWait": 5.7956781892,
"gasprice": 9.1
},
{
"expectedTime": "78.24522052614759252715",
"expectedWait": 5.6406539084,
"gasprice": 9.2
},
{
"expectedTime": "77.1685119880459882636",
"expectedWait": 5.5630345959,
"gasprice": 9.5
},
{
"expectedTime": "72.43649507646737870178",
"expectedWait": 5.2219061601,
"gasprice": 9.8
},
{
"expectedTime": "71.48259532351443753818",
"expectedWait": 5.1531400638,
"gasprice": 9.9
},
{
"expectedTime": "58.23892805162994573827",
"expectedWait": 4.1984115442,
"gasprice": 10
},
{
"expectedTime": "53.13065124862245917617",
"expectedWait": 3.8301587446,
"gasprice": 10.1
},
{
"expectedTime": "53.03510209647058751971",
"expectedWait": 3.82327066,
"gasprice": 10.3
},
{
"expectedTime": "49.06846157804491912403",
"expectedWait": 3.5373177776,
"gasprice": 11
},
{
"expectedTime": "48.30893330101818116637",
"expectedWait": 3.4825638116,
"gasprice": 11.1
},
{
"expectedTime": "48.25099734861818116715",
"expectedWait": 3.4783872414,
"gasprice": 11.3
},
{
"expectedTime": "47.64416885027272662988",
"expectedWait": 3.4346413165,
"gasprice": 11.9
},
{
"expectedTime": "46.76354741392085498401",
"expectedWait": 3.3711578128,
"gasprice": 12.6
},
{
"expectedTime": "44.99427448545882292232",
"expectedWait": 3.2436119232,
"gasprice": 13
},
{
"expectedTime": "44.61790554199251276697",
"expectedWait": 3.2164796979,
"gasprice": 13.1
},
{
"expectedTime": "42.87832690973048070488",
"expectedWait": 3.0910744534,
"gasprice": 14
},
{
"expectedTime": "42.21224091308663044649",
"expectedWait": 3.0430566888,
"gasprice": 14.9
},
{
"expectedTime": "41.15715335111336842864",
"expectedWait": 2.9669960203,
"gasprice": 15
},
{
"expectedTime": "40.9600723880876999821",
"expectedWait": 2.9527885646,
"gasprice": 15.1
},
{
"expectedTime": "38.89138450301711177472",
"expectedWait": 2.8036580193,
"gasprice": 15.8
},
{
"expectedTime": "37.89655640860213852611",
"expectedWait": 2.7319414219,
"gasprice": 16
},
{
"expectedTime": "37.35265517364705831954",
"expectedWait": 2.692731888,
"gasprice": 17.4
},
{
"expectedTime": "36.79447683873796741798",
"expectedWait": 2.652493126,
"gasprice": 17.8
},
{
"expectedTime": "36.11439350850802090309",
"expectedWait": 2.6034663015,
"gasprice": 19
},
{
"expectedTime": "31.32676199432192471101",
"expectedWait": 2.2583286403,
"gasprice": 20
},
{
"expectedTime": "30.76792490132192471855",
"expectedWait": 2.2180423888,
"gasprice": 20.1
},
{
"expectedTime": "29.94493658520962526441",
"expectedWait": 2.1587136243,
"gasprice": 25
},
{
"expectedTime": "29.53287347625561457478",
"expectedWait": 2.1290082267,
"gasprice": 29
},
{
"expectedTime": "29.09318627175614934008",
"expectedWait": 2.0973114236,
"gasprice": 47
}
],
"priceAndTimeEstimatesLastRetrieved": 1541527901281,
"errors": {}
},
"unconnectedAccount": {
"state": "CLOSED"
},
"history": {
"mostRecentOverviewPage": "/"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>MetaMask</title>
<script>
window.METAMASK_DEBUG = true
window.TEST_MODE = true
</script>
</head>
<body>
<!-- app content -->
<div id="app-content" style="height: 100%"></div>
<script src="./bundle.js" type="text/javascript" charset="utf-8"></script>
</body>
<style>
html, body, #test-container, .super-dev-container {
height: 100%;
width: 100%;
position: relative;
background: white;
}
#app-content {
background: #F7F7F7;
}
</style>
</html>

View File

@ -21,8 +21,6 @@
"test:unit:lax": "mocha --exit --require test/env.js --require test/setup.js --recursive \"test/unit/{,**/!(permissions)}/*.js\" \"ui/app/**/*.test.js\"",
"test:unit:strict": "mocha --exit --require test/env.js --require test/setup.js --recursive \"test/unit/**/permissions/*.js\"",
"test:unit:path": "mocha --exit --require test/env.js --require test/setup.js --recursive",
"test:integration": "yarn test:integration:build && yarn test:flat",
"test:integration:build": "yarn build styles",
"test:e2e:chrome": "SELENIUM_BROWSER=chrome test/e2e/run-all.sh",
"test:web3:chrome": "SELENIUM_BROWSER=chrome test/e2e/run-web3.sh",
"test:web3:firefox": "SELENIUM_BROWSER=firefox test/e2e/run-web3.sh",
@ -30,12 +28,6 @@
"test:coverage": "nyc --silent --check-coverage yarn test:unit:strict && nyc --silent --no-clean yarn test:unit:lax && nyc report --reporter=text --reporter=html",
"test:coverage:strict": "nyc --check-coverage yarn test:unit:strict",
"test:coveralls-upload": "if [ \"$COVERALLS_REPO_TOKEN\" ]; then nyc report --reporter=text-lcov | coveralls; fi",
"test:flat": "yarn test:flat:build && karma start test/flat.conf.js",
"test:flat:build": "yarn test:flat:build:ui && yarn test:flat:build:tests && yarn test:flat:build:locales",
"test:flat:build:tests": "node test/integration/index.js",
"test:flat:build:states": "node development/genStates.js",
"test:flat:build:locales": "mkdir -p dist/chrome && cp -R app/_locales dist/chrome/_locales",
"test:flat:build:ui": "yarn test:flat:build:states && browserify --transform babelify --transform brfs ./development/mock-dev.js -o ./development/bundle.js",
"ganache:start": "./development/run-ganache",
"sentry:publish": "node ./development/sentry-publish.js",
"lint": "eslint . --ext js,json",
@ -162,7 +154,6 @@
"react-tippy": "^1.2.2",
"react-toggle-button": "^2.2.0",
"react-transition-group": "^1.2.1",
"react-trigger-change": "^1.0.2",
"readable-stream": "^2.3.3",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
@ -250,11 +241,6 @@
"gulp-watch": "^5.0.1",
"gulp-zip": "^4.0.0",
"jsdom": "^11.2.0",
"karma": "^4.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-firefox-launcher": "^1.0.1",
"karma-qunit": "^1.2.1",
"koa": "^2.7.0",
"lockfile-lint": "^4.0.0",
"mocha": "^7.2.0",
@ -264,8 +250,6 @@
"nyc": "^15.0.0",
"polyfill-crypto.getrandomvalues": "^1.0.0",
"proxyquire": "^2.1.3",
"qs": "^6.2.0",
"qunitjs": "^2.4.1",
"randomcolor": "^0.5.4",
"rc": "^1.2.8",
"react-devtools": "^4.4.0",
@ -288,7 +272,6 @@
"style-loader": "^0.21.0",
"stylelint": "^9.10.1",
"stylelint-config-standard": "^18.2.0",
"testem": "^2.16.0",
"through2": "^2.0.3",
"ttest": "^2.1.1",
"vinyl-buffer": "^1.0.1",

View File

@ -1,68 +0,0 @@
// Karma configuration
// Generated on Mon Sep 11 2017 18:45:48 GMT-0700 (PDT)
module.exports = function (config) {
return {
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: process.cwd(),
// Uncomment to allow for longer timeouts
// browserNoActivityTimeout: 100000000,
browserConsoleLogOptions: {
terminal: false,
},
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['qunit'],
// list of files / patterns to load in the browser
files: [
'test/integration/jquery-3.1.0.min.js',
{ pattern: 'dist/chrome/images/**/*.*', watched: false, included: false, served: true },
{ pattern: 'dist/chrome/fonts/**/*.*', watched: false, included: false, served: true },
{ pattern: 'dist/chrome/_locales/**/*.*', watched: false, included: false, served: true },
],
proxies: {
'/images/': '/base/dist/chrome/images/',
'/fonts/': '/base/dist/chrome/fonts/',
'/_locales/': '/base/dist/chrome/_locales/',
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: process.env.browsers ?
JSON.parse(process.env.browsers)
: ['Chrome', 'Firefox'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 1,
nocache: true,
}
}

View File

@ -1,8 +0,0 @@
const getBaseConfig = require('./base.conf.js')
module.exports = function (config) {
const settings = getBaseConfig(config)
settings.files.push('development/bundle.js')
settings.files.push('test/integration/bundle.js')
config.set(settings)
}

View File

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>QUnit Example</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.0.0.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-2.0.0.js"></script>
<script src="./jquery-3.1.0.min.js"></script>
<script src="helpers.js"></script>
<script src="bundle.js"></script>
<script src="/testem.js"></script>
<iframe src="/development/test.html" height="800px" width="500px">
<p>Your browser does not support iframes</p>
</iframe>
</body>
</html>

View File

@ -1,29 +0,0 @@
const fs = require('fs')
const path = require('path')
const pump = require('pump')
const browserify = require('browserify')
const tests = fs.readdirSync(path.join(__dirname, 'lib'))
const bundlePath = path.join(__dirname, 'bundle.js')
const b = browserify()
const writeStream = fs.createWriteStream(bundlePath)
tests.forEach(function (fileName) {
const filePath = path.join(__dirname, 'lib', fileName)
console.log(`bundling test "${filePath}"`)
b.add(filePath)
})
pump(
b.bundle(),
writeStream,
(err) => {
if (err) {
throw err
}
console.log(`Integration test build completed: "${bundlePath}"`)
process.exit(0)
}
)

File diff suppressed because one or more lines are too long

View File

@ -1,77 +0,0 @@
const reactTriggerChange = require('react-trigger-change')
const {
timeout,
queryAsync,
} = require('../../lib/util')
const fetchMockResponses = require('../../data/fetch-mocks.json')
QUnit.module('confirm sig requests')
QUnit.test('successful confirmation of sig requests', (assert) => {
const done = assert.async()
runConfirmSigRequestsTest(assert).then(done).catch((err) => {
assert.notOk(err, `Error was thrown: ${err.stack}`)
done()
})
})
global.ethQuery = global.ethQuery || {}
async function runConfirmSigRequestsTest (assert) {
const selectState = await queryAsync($, 'select')
selectState.val('confirm sig requests')
reactTriggerChange(selectState[0])
const realFetch = window.fetch.bind(window)
window.fetch = (...args) => {
if (args[0].match(/^http(s)?:\/\/ethgasstation\.info\/json\/ethgasAPI.*/u)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
} else if (args[0].match(/http(s?):\/\/ethgasstation\.info\/json\/predictTable.*/u)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
} else if (args[0].match(/chromeextensionmm/)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
}
return realFetch.fetch(...args)
}
const pendingRequestItem = $.find('.transaction-list-item .transaction-list-item__grid')
if (pendingRequestItem[0]) {
pendingRequestItem[0].click()
}
await timeout(1000)
let confirmSigHeadline = await queryAsync($, '.request-signature__headline')
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
let confirmSigRowValue = await queryAsync($, '.request-signature__row-value')
assert.equal(confirmSigRowValue[0].textContent, 'Hi, Alice!')
assert.equal(confirmSigRowValue[1].textContent, '1337')
let confirmSigSignButton = await queryAsync($, 'button.btn-secondary.btn--large')
confirmSigSignButton[0].click()
await timeout(1000)
confirmSigHeadline = await queryAsync($, '.request-signature__headline')
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
confirmSigRowValue = await queryAsync($, '.request-signature__row-value')
assert.ok(confirmSigRowValue[0].textContent.match(/^#\sTerms\sof\sUse/))
confirmSigSignButton = await queryAsync($, 'button.btn-secondary.btn--large')
confirmSigSignButton[0].click()
await timeout(1000)
confirmSigHeadline = await queryAsync($, '.request-signature__headline')
assert.equal(confirmSigHeadline[0].textContent, 'Your signature is being requested')
const confirmSigMessage = await queryAsync($, '.request-signature__notice')
assert.ok(confirmSigMessage[0].textContent.match(/^Signing\sthis\smessage/))
confirmSigRowValue = await queryAsync($, '.request-signature__row-value')
assert.equal(confirmSigRowValue[0].textContent, '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0')
confirmSigSignButton = await queryAsync($, 'button.btn-secondary.btn--large')
confirmSigSignButton[0].click()
await timeout(2000)
}

View File

@ -1,43 +0,0 @@
const reactTriggerChange = require('../../lib/react-trigger-change')
const {
timeout,
queryAsync,
findAsync,
} = require('../../lib/util')
const fetchMockResponses = require('../../data/fetch-mocks.json')
QUnit.module('currency localization')
QUnit.test('renders localized currency', (assert) => {
const done = assert.async()
runCurrencyLocalizationTest(assert).then(done).catch((err) => {
assert.notOk(err, `Error was thrown: ${err.stack}`)
done()
})
})
async function runCurrencyLocalizationTest (assert) {
console.log('*** start runCurrencyLocalizationTest')
const selectState = await queryAsync($, 'select')
selectState.val('currency localization')
const realFetch = window.fetch.bind(window)
window.fetch = (...args) => {
if (args[0].match(/^http(s)?:\/\/ethgasstation\.info\/json\/ethgasAPI.*/u)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
} else if (args[0].match(/http(s?):\/\/ethgasstation\.info\/json\/predictTable.*/u)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
} else if (args[0].match(/chromeextensionmm/)) {
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
}
return realFetch.fetch(...args)
}
await timeout(1000)
reactTriggerChange(selectState[0])
await timeout(1000)
const txView = await queryAsync($, '.home__main-view')
const heroBalance = await findAsync($(txView), '.eth-overview__balance')
const fiatAmount = await findAsync($(heroBalance), '.eth-overview__secondary-balance')
assert.equal(fiatAmount[0].textContent, '₱102,707.97PHP')
}

View File

@ -1 +0,0 @@
{"meta":{"version":4},"data":{"fiatCurrency":"USD","conversionRate":8.34908448,"conversionDate":1481227505,"wallet":"{\"encSeed\":{\"encStr\":\"Te2KyAGY3S01bgUJ+7d4y3BOvr/8TKrXrkRZ29cGI6dgyedtN+YgTQxElC2td/pzuoXm7KeSfr+yAoFCvMgqFAJwRcX3arHOsMFQie8kp8mL5I65zwdg/HB2QecB4OJHytrxgApv2zZiKEo0kbu2cs8zYIn5wNlCBIHwgylYmHpUDIJcO1B4zg==\",\"nonce\":\"xnxqk4iy70bjt721F+KPLV4PNfBFNyct\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"vNrSjekRKLmaGFf77Uca9+aAebmDlvrBwtAV8YthpQ4OX/mXtLSycmnLsYdk4schaByfJvrm6/Mf9fxzOSaScJk+XvKw5XqNXedkDHtbWrmNnxFpuT+9tuB8Nupr3D9GZK9PgXhJD99/7Bn6Wk7/ne+PIDmbtdmx/SWmrdo3pg==\",\"nonce\":\"zqWq/gtJ5zfUVRWQQJkP/zoYjer6Rozj\"},\"hdIndex\":1,\"encPrivKeys\":{\"e15d894becb0354c501ae69429b05143679f39e0\":{\"key\":\"jBLQ9v1l5LOEY1C3kI8z7LpbJKHP1vpVfPAlz90MNSfa8Oe+XlxKQAGYs8Zb4fWm\",\"nonce\":\"fJyrSRo1t0RMNqp2MsneoJnYJWHQnSVY\"}},\"addresses\":[\"e15d894becb0354c501ae69429b05143679f39e0\"]}},\"encHdRootPriv\":{\"encStr\":\"mbvwiFBQGbjj4BJLmdeYzfYi8jb7gtFtwiCQOPfvmyz4h2/KMbHNGzumM16qRKpifioQXkhnBulMIQHaYg0Jwv1MoFsqHxHmuIAT+QP5XvJjz0MRl6708pHowmIVG+R8CZNTLqzE7XS8YkZ4ElRpTvLEM8Wngi5Sg287mQMP9w==\",\"nonce\":\"i5Tp2lQe92rXQzNhjZcu9fNNhfux6Wf4\"},\"salt\":\"FQpA8D9R/5qSp9WtQ94FILyfWZHMI6YZw6RmBYqK0N0=\",\"version\":2}","config":{"provider":{"type":"testnet"},"selectedAccount":"0xe15d894becb0354c501ae69429b05143679f39e0"},"isEthConfirmed":true,"transactions":[],"gasMultiplier":1}}

View File

@ -1 +0,0 @@
{"meta":{"version":4},"data":{"fiatCurrency":"USD","noticesList":[{"read":true,"date":"Fri Dec 16 2016","title":"Ending Morden Support","body":"Due to [recent events](https://blog.ethereum.org/2016/11/20/from-morden-to-ropsten/), MetaMask is now deprecating support for the Morden Test Network.\n\nUsers will still be able to access Morden through a locally hosted node, but we will no longer be providing hosted access to this network through [Infura](http://infura.io/).\n\nPlease use the new Ropsten Network as your new default test network.\n\nYou can fund your Ropsten account using the buy button on your account page.\n\nBest wishes!\nThe MetaMask Team\n\n","id":0}],"conversionRate":7.07341909,"conversionDate":1482539284,"wallet":"{\"encSeed\":{\"encStr\":\"LZsdN8lJzYkUe1UpmAalnERdgkBFt25gWDdK8kfQUwMAk/27XR+dc+8n5swgoF5qgwhc9LBgliEGNDs1Q/lnuld3aQLabkOeAW4BHS1vS7FxqKrzDS3iyzSuQO6wDQmGno/buuknVgDsKiyjW22hpt7vtVVWA+ZL1P3x6M0+AxGJjeGVrG+E8Q==\",\"nonce\":\"T6O9BmwmTj214XUK3KF0s3iCKo3OlrUD\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"GNNfZevCMlgMVh9y21y1UwrC9qcmH6XYq7v+9UoqbHnzPQJFlxidN5+x/Sldo72a6+5zJpQkkdZ+Q0lePrzvXfuSd3D/RO7WKFIKo9nAQI5+JWwz4INuCmVcmqCv2J4BTLGjrG8fp5pDJ62Bn0XHqkJo3gx3fpvs3cS66+ZKwg==\",\"nonce\":\"HRTlGj44khQs2veYHEF/GqTI1t0yYvyd\"},\"hdIndex\":3,\"encPrivKeys\":{\"e15d894becb0354c501ae69429b05143679f39e0\":{\"key\":\"ZAeZL9VcRUtiiO4VXOQKBFg787PR5R3iymjUeU5vpDRIqOXbjWN6N4ZNR8YpSXl+\",\"nonce\":\"xLsADagS8uqDYae6cImyhxF7o1kBDbPe\"},\"87658c15aefe7448008a28513a11b6b130ef4cd0\":{\"key\":\"ku0mm5s1agRJNAMYIJO0qeoDe+FqcbqdQI6azXF3GL1OLo6uMlt6I4qS+eeravFi\",\"nonce\":\"xdGfSUPKtkW8ge0SWIbbpahs/NyEMzn5\"},\"aa25854c0379e53c957ac9382e720c577fa31fd5\":{\"key\":\"NjpYC9FbiC95CTx/1kwgOHk5LSN9vl4RULEBbvwfVOjqSH8WixNoP3R6I/QyNIs2\",\"nonce\":\"M/HWpXXA9QvuZxEykkGQPJKKdz33ovQr\"}},\"addresses\":[\"e15d894becb0354c501ae69429b05143679f39e0\",\"87658c15aefe7448008a28513a11b6b130ef4cd0\",\"aa25854c0379e53c957ac9382e720c577fa31fd5\"]}},\"encHdRootPriv\":{\"encStr\":\"f+3prUOzl+95aNAV+ad6lZdsYZz120ZsL67ucjj3tiMXf/CC4X8XB9N2QguhoMy6fW+fATUsTdJe8+CbAAyb79V9HY0Pitzq9Yw/g1g0/Ii2JzsdGBriuMsPdwZSVqz+rvQFw/6Qms1xjW6cqa8S7kM2WA5l8RB1Ck6r5zaqbA==\",\"nonce\":\"oGahxNFekVxH9sg6PUCCHIByvo4WFSqm\"},\"salt\":\"N7xYoEA53yhSweOsEphku1UKkIEuZtX2MwLBhVM6RR8=\",\"version\":2}","config":{"provider":{"type":"testnet"},"selectedAccount":"0xe15d894becb0354c501ae69429b05143679f39e0"},"walletNicknames":{"0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9":"Account 1","0xd7c0cd9e7d2701c710d64fc492c7086679bdf7b4":"Account 2","0x1acfb961c5a8268eac8e09d6241a26cbeff42241":"Account 3"},"lostAccounts":["0xe15d894becb0354c501ae69429b05143679f39e0","0x87658c15aefe7448008a28513a11b6b130ef4cd0","0xaa25854c0379e53c957ac9382e720c577fa31fd5"]}}

View File

@ -1,19 +0,0 @@
{
"meta": {
"version": 4
},
"data": {
"fiatCurrency": "USD",
"conversionRate": 9.47316629,
"conversionDate": 1479510994,
"wallet": "{\"encSeed\":{\"encStr\":\"a5tjKtDGlHkua+6Ta5s3wMFWPmsBqaPdMKGmqeI2z1kMbNs3V03HBaCptU7NtMra1DjHKbSNsUToxFUrmrvWBmUejamN16+l1CviwqASsv7kKzpot00/dfyyJgtZwwFP5Je+TAB1V231nRbPidOfeE1cDec5V8KTF8epl6qzsbA25pjeW76Dfw==\",\"nonce\":\"RzID6bAhWfGTSR74xdIh3RaT1+1sLk6F\"},\"ksData\":{\"m/44'/60'/0'/0\":{\"info\":{\"curve\":\"secp256k1\",\"purpose\":\"sign\"},\"encHdPathPriv\":{\"encStr\":\"6nlYAopRbmGcqerRZO08XwgeYaCJg9XRhh4oiYiVVdQtyNPdxvOI9TcE/mqvBiatMwBwA+TmsqTV6eZZe/VDZKYIGajKulQbScd0xQ71JhYfqqmzSG6EH2Pnzwa+aSAsfARgN1JJSaff2+p6wV6Zg5BUDtl72OGEIEfXhcUGwg==\",\"nonce\":\"Ee1KiDqtx7NvYToQUFvjEhKNinNQcXlK\"},\"hdIndex\":1,\"encPrivKeys\":{\"4dd5d356c5a016a220bcd69e82e5af680a430d00\":{\"key\":\"htGRGAH10lGF4M+fvioznmYVIUSWAzwp/yWSIo85psgZZwmCdJY72oyGanYsrFO8\",\"nonce\":\"PkP8XeZ+ok215rzEorvJu9nYTWzkOVr0\"}},\"addresses\":[\"4dd5d356c5a016a220bcd69e82e5af680a430d00\"]}},\"encHdRootPriv\":{\"encStr\":\"TAZAo71a+4IlAaoA66f0w4ts2f+V7ArTSUHRIrMltfAPXz7GfJBmKXNtHPORUYAjRiKqWK6FZnhKLf7Vcng2LG7VnDQwC4xPxzSRZzSEilnoY3V+zRY0HD7Wb/pndb4FliA/buZQmjohO4vezeX0hl70rJlPJEZTyYoWgxbxFA==\",\"nonce\":\"FlJOaLyBEHMaH5fEnYjdHc6nn18+WkRj\"},\"salt\":\"CmuCcWpbqpKUUv+1aE2ZwvQl7EIQ731uFibSq++vwtY=\",\"version\":2}",
"config": {
"provider": {
"type": "testnet"
},
"selectedAddress": "0x4dd5d356c5a016a220bcd69e82e5af680a430d00"
},
"showSeedWords": false,
"isEthConfirmed": true
}
}

View File

@ -1,161 +0,0 @@
// Trigger React's synthetic change events on input, textarea and select elements
// https://github.com/vitalyq/react-trigger-change
/** ****************IMPORTANT NOTE******************/
/* This file is a modification of the */
/* 'react-trigger-change' library linked above. */
/* That library breaks when 'onFocus' events are */
/* added to components under test because it */
/* dispatches focus events to ensure changes are */
/* triggered in some versions of IE. */
/* This modification removes the accomodations */
/* 'react-trigger-change' makes for IE to ensure */
/* our tests can pass in chrome and firefox. */
/** ************************************************/
'use strict'
// Constants and functions are declared inside the closure.
// In this way, reactTriggerChange can be passed directly to executeScript in Selenium.
module.exports = function reactTriggerChange (node) {
const supportedInputTypes = {
color: true,
date: true,
datetime: true,
'datetime-local': true,
email: true,
month: true,
number: true,
password: true,
range: true,
search: true,
tel: true,
text: true,
time: true,
url: true,
week: true,
}
const nodeName = node.nodeName.toLowerCase()
const type = node.type
let event
let descriptor
let initialValue
let initialChecked
let initialCheckedRadio
// Do not try to delete non-configurable properties.
// Value and checked properties on DOM elements are non-configurable in PhantomJS.
function deletePropertySafe (elem, prop) {
const desc = Object.getOwnPropertyDescriptor(elem, prop)
if (desc && desc.configurable) {
delete elem[prop]
}
}
function getCheckedRadio (radio) {
const name = radio.name
let radios
let i
if (name) {
radios = document.querySelectorAll('input[type="radio"][name="' + name + '"]')
for (i = 0; i < radios.length; i += 1) {
if (radios[i].checked) {
return radios[i] !== radio ? radios[i] : null
}
}
}
return null
}
function preventChecking (e) {
e.preventDefault()
if (!initialChecked) {
e.target.checked = false
}
if (initialCheckedRadio) {
initialCheckedRadio.checked = true
}
}
if (nodeName === 'select' ||
(nodeName === 'input' && type === 'file')) {
// IE9-IE11, non-IE
// Dispatch change.
event = document.createEvent('HTMLEvents')
event.initEvent('change', true, false)
node.dispatchEvent(event)
} else if ((nodeName === 'input' && supportedInputTypes[type]) ||
nodeName === 'textarea') {
// React 16
// Cache artificial value property descriptor.
// Property doesn't exist in React <16, descriptor is undefined.
descriptor = Object.getOwnPropertyDescriptor(node, 'value')
// Update inputValueTracking cached value.
// Remove artificial value property.
// Restore initial value to trigger event with it.
initialValue = node.value
node.value = initialValue + '#'
deletePropertySafe(node, 'value')
node.value = initialValue
// React 0.14: IE10-IE11, non-IE
// React 15: non-IE
// React 16: IE10-IE11, non-IE
event = document.createEvent('HTMLEvents')
event.initEvent('input', true, false)
node.dispatchEvent(event)
// React 16
// Restore artificial value property descriptor.
if (descriptor) {
Object.defineProperty(node, 'value', descriptor)
}
} else if (nodeName === 'input' && type === 'checkbox') {
// Invert inputValueTracking cached value.
node.checked = !node.checked
// Dispatch click.
// Click event inverts checked value.
event = document.createEvent('MouseEvents')
event.initEvent('click', true, true)
node.dispatchEvent(event)
} else if (nodeName === 'input' && type === 'radio') {
// Cache initial checked value.
initialChecked = node.checked
// Find and cache initially checked radio in the group.
initialCheckedRadio = getCheckedRadio(node)
// React 16
// Cache property descriptor.
// Invert inputValueTracking cached value.
// Remove artificial checked property.
// Restore initial value, otherwise preventDefault will eventually revert the value.
descriptor = Object.getOwnPropertyDescriptor(node, 'checked')
node.checked = !initialChecked
deletePropertySafe(node, 'checked')
node.checked = initialChecked
// Prevent toggling during event capturing phase.
// Set checked value to false if initialChecked is false,
// otherwise next listeners will see true.
// Restore initially checked radio in the group.
node.addEventListener('click', preventChecking, true)
// Dispatch click.
// Click event inverts checked value.
event = document.createEvent('MouseEvents')
event.initEvent('click', true, true)
node.dispatchEvent(event)
// Remove listener to stop further change prevention.
node.removeEventListener('click', preventChecking, true)
// React 16
// Restore artificial checked property descriptor.
if (descriptor) {
Object.defineProperty(node, 'checked', descriptor)
}
}
}

View File

@ -1,57 +0,0 @@
module.exports = {
timeout,
queryAsync,
findAsync,
pollUntilTruthy,
}
function timeout (time) {
return new Promise((resolve) => {
setTimeout(resolve, time || 1500)
})
}
async function findAsync (container, selector, opts) {
try {
return await pollUntilTruthy(() => {
const result = container.find(selector)
if (result.length > 0) {
return result
}
}, opts)
} catch (err) {
throw new Error(`Failed to find element within interval: "${selector}"`)
}
}
async function queryAsync (jQuery, selector, opts) {
try {
return await pollUntilTruthy(() => {
const result = jQuery(selector)
if (result.length > 0) {
return result
}
}, opts)
} catch (err) {
throw new Error(`Failed to find element within interval: "${selector}"`)
}
}
async function pollUntilTruthy (fn, opts = {}) {
const pollingInterval = opts.pollingInterval || 100
const timeoutInterval = opts.timeoutInterval || 5000
const start = Date.now()
let result
while (!result) {
// check if timedout
const now = Date.now()
if ((now - start) > timeoutInterval) {
throw new Error(`pollUntilTruthy - failed to return truthy within interval`)
}
// check for result
result = fn()
// run again after timeout
await timeout(pollingInterval, timeoutInterval)
}
return result
}

659
yarn.lock

File diff suppressed because it is too large Load Diff