mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #6577 from MetaMask/fix-integration-tests
Fix integration tests: completedUiMigration state and fetch + ethquery mocking
This commit is contained in:
commit
090d4a8367
@ -133,7 +133,8 @@
|
|||||||
"preferences": {
|
"preferences": {
|
||||||
"useNativeCurrencyAsPrimaryCurrency": true,
|
"useNativeCurrencyAsPrimaryCurrency": true,
|
||||||
"showFiatInTestnets": true
|
"showFiatInTestnets": true
|
||||||
}
|
},
|
||||||
|
"completedUiMigration": true
|
||||||
},
|
},
|
||||||
"appState": {
|
"appState": {
|
||||||
"menuOpen": false,
|
"menuOpen": false,
|
||||||
|
@ -156,7 +156,8 @@
|
|||||||
"currentLocale": "en",
|
"currentLocale": "en",
|
||||||
"preferences": {
|
"preferences": {
|
||||||
"useNativeCurrencyAsPrimaryCurrency": true
|
"useNativeCurrencyAsPrimaryCurrency": true
|
||||||
}
|
},
|
||||||
|
"completedUiMigration": true
|
||||||
},
|
},
|
||||||
"appState": {
|
"appState": {
|
||||||
"menuOpen": false,
|
"menuOpen": false,
|
||||||
|
@ -115,7 +115,8 @@
|
|||||||
"preferences": {
|
"preferences": {
|
||||||
"useNativeCurrencyAsPrimaryCurrency": true,
|
"useNativeCurrencyAsPrimaryCurrency": true,
|
||||||
"showFiatInTestnets": true
|
"showFiatInTestnets": true
|
||||||
}
|
},
|
||||||
|
"completedUiMigration": true
|
||||||
},
|
},
|
||||||
"appState": {
|
"appState": {
|
||||||
"menuOpen": false,
|
"menuOpen": false,
|
||||||
|
@ -137,7 +137,8 @@
|
|||||||
"preferences": {
|
"preferences": {
|
||||||
"useNativeCurrencyAsPrimaryCurrency": true,
|
"useNativeCurrencyAsPrimaryCurrency": true,
|
||||||
"showFiatInTestnets": true
|
"showFiatInTestnets": true
|
||||||
}
|
},
|
||||||
|
"completedUiMigration": true
|
||||||
},
|
},
|
||||||
"appState": {
|
"appState": {
|
||||||
"menuOpen": false,
|
"menuOpen": false,
|
||||||
|
@ -116,7 +116,8 @@
|
|||||||
"preferences": {
|
"preferences": {
|
||||||
"useNativeCurrencyAsPrimaryCurrency": true,
|
"useNativeCurrencyAsPrimaryCurrency": true,
|
||||||
"showFiatInTestnets": true
|
"showFiatInTestnets": true
|
||||||
}
|
},
|
||||||
|
"completedUiMigration": true
|
||||||
},
|
},
|
||||||
"appState": {
|
"appState": {
|
||||||
"menuOpen": false,
|
"menuOpen": false,
|
||||||
|
@ -1058,7 +1058,8 @@
|
|||||||
"currentLocale": "en",
|
"currentLocale": "en",
|
||||||
"preferences": {
|
"preferences": {
|
||||||
"useNativeCurrencyAsPrimaryCurrency": true
|
"useNativeCurrencyAsPrimaryCurrency": true
|
||||||
}
|
},
|
||||||
|
"completedUiMigration": true
|
||||||
},
|
},
|
||||||
"appState": {
|
"appState": {
|
||||||
"menuOpen": false,
|
"menuOpen": false,
|
||||||
|
@ -15,16 +15,25 @@ QUnit.test('successful confirmation of sig requests', (assert) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
global.ethQuery = global.ethQuery || {}
|
||||||
|
|
||||||
async function runConfirmSigRequestsTest (assert, done) {
|
async function runConfirmSigRequestsTest (assert, done) {
|
||||||
const selectState = await queryAsync($, 'select')
|
const selectState = await queryAsync($, 'select')
|
||||||
selectState.val('confirm sig requests')
|
selectState.val('confirm sig requests')
|
||||||
reactTriggerChange(selectState[0])
|
reactTriggerChange(selectState[0])
|
||||||
|
|
||||||
|
const realFetch = window.fetch.bind(window)
|
||||||
global.fetch = (...args) => {
|
global.fetch = (...args) => {
|
||||||
if (args[0].match(/chromeextensionmm/)) {
|
if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
|
||||||
|
} else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
|
||||||
|
} else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) })
|
||||||
|
} else if (args[0].match(/chromeextensionmm/)) {
|
||||||
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
||||||
}
|
}
|
||||||
return window.fetch(...args)
|
return realFetch.fetch(...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
const pendingRequestItem = $.find('.transaction-list-item .transaction-list-item__grid')
|
const pendingRequestItem = $.find('.transaction-list-item .transaction-list-item__grid')
|
||||||
|
@ -21,11 +21,18 @@ async function runCurrencyLocalizationTest (assert, done) {
|
|||||||
const selectState = await queryAsync($, 'select')
|
const selectState = await queryAsync($, 'select')
|
||||||
selectState.val('currency localization')
|
selectState.val('currency localization')
|
||||||
|
|
||||||
|
const realFetch = window.fetch.bind(window)
|
||||||
global.fetch = (...args) => {
|
global.fetch = (...args) => {
|
||||||
if (args[0].match(/chromeextensionmm/)) {
|
if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
|
||||||
|
} else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
|
||||||
|
} else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) })
|
||||||
|
} else if (args[0].match(/chromeextensionmm/)) {
|
||||||
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
||||||
}
|
}
|
||||||
return window.fetch(...args)
|
return realFetch.fetch(...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
await timeout(1000)
|
await timeout(1000)
|
||||||
|
@ -25,6 +25,7 @@ global.ethereumProvider = {}
|
|||||||
async function runSendFlowTest (assert, done) {
|
async function runSendFlowTest (assert, done) {
|
||||||
const tempFetch = global.fetch
|
const tempFetch = global.fetch
|
||||||
|
|
||||||
|
const realFetch = window.fetch.bind(window)
|
||||||
global.fetch = (...args) => {
|
global.fetch = (...args) => {
|
||||||
if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
|
if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
|
||||||
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
|
||||||
@ -35,7 +36,7 @@ async function runSendFlowTest (assert, done) {
|
|||||||
} else if (args[0].match(/chromeextensionmm/)) {
|
} else if (args[0].match(/chromeextensionmm/)) {
|
||||||
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
||||||
}
|
}
|
||||||
return window.fetch(...args)
|
return realFetch.fetch(...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('*** start runSendFlowTest')
|
console.log('*** start runSendFlowTest')
|
||||||
|
@ -26,11 +26,18 @@ async function runTxListItemsTest (assert, done) {
|
|||||||
selectState.val('tx list items')
|
selectState.val('tx list items')
|
||||||
reactTriggerChange(selectState[0])
|
reactTriggerChange(selectState[0])
|
||||||
|
|
||||||
|
const realFetch = window.fetch.bind(window)
|
||||||
global.fetch = (...args) => {
|
global.fetch = (...args) => {
|
||||||
if (args[0].match(/chromeextensionmm/)) {
|
if (args[0] === 'https://ethgasstation.info/json/ethgasAPI.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasBasic)) })
|
||||||
|
} else if (args[0] === 'https://ethgasstation.info/json/predictTable.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.ethGasPredictTable)) })
|
||||||
|
} else if (args[0] === 'https://dev.blockscale.net/api/gasexpress.json') {
|
||||||
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.gasExpress)) })
|
||||||
|
} else if (args[0].match(/chromeextensionmm/)) {
|
||||||
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
return Promise.resolve({ json: () => Promise.resolve(JSON.parse(fetchMockResponses.metametrics)) })
|
||||||
}
|
}
|
||||||
return window.fetch(...args)
|
return realFetch.fetch(...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
const metamaskLogo = await queryAsync($, '.app-header__logo-container')
|
const metamaskLogo = await queryAsync($, '.app-header__logo-container')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user