mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Use webRequest to cancel all requests to infura in e2e tests.
This commit is contained in:
parent
649a1d483a
commit
a44f2bb6eb
36
gulpfile.js
36
gulpfile.js
@ -195,6 +195,21 @@ gulp.task('manifest:production', function () {
|
|||||||
.pipe(gulp.dest('./dist/', { overwrite: true }))
|
.pipe(gulp.dest('./dist/', { overwrite: true }))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gulp.task('manifest:testing', function () {
|
||||||
|
return gulp.src([
|
||||||
|
'./dist/firefox/manifest.json',
|
||||||
|
'./dist/chrome/manifest.json',
|
||||||
|
], {base: './dist/'})
|
||||||
|
|
||||||
|
// Exclude chromereload script in production:
|
||||||
|
.pipe(jsoneditor(function (json) {
|
||||||
|
json.permissions = [...json.permissions, 'webRequestBlocking']
|
||||||
|
return json
|
||||||
|
}))
|
||||||
|
|
||||||
|
.pipe(gulp.dest('./dist/', { overwrite: true }))
|
||||||
|
})
|
||||||
|
|
||||||
gulp.task('copy',
|
gulp.task('copy',
|
||||||
gulp.series(
|
gulp.series(
|
||||||
gulp.parallel(...copyTaskNames),
|
gulp.parallel(...copyTaskNames),
|
||||||
@ -212,6 +227,15 @@ gulp.task('dev:copy',
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
gulp.task('test:copy',
|
||||||
|
gulp.series(
|
||||||
|
gulp.parallel(...copyDevTaskNames),
|
||||||
|
'manifest:chrome',
|
||||||
|
'manifest:opera',
|
||||||
|
'manifest:testing'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
// scss compilation and autoprefixing tasks
|
// scss compilation and autoprefixing tasks
|
||||||
|
|
||||||
gulp.task('build:scss', createScssBuildTask({
|
gulp.task('build:scss', createScssBuildTask({
|
||||||
@ -383,6 +407,18 @@ gulp.task('dev',
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
gulp.task('dev:test',
|
||||||
|
gulp.series(
|
||||||
|
'clean',
|
||||||
|
'dev:scss',
|
||||||
|
gulp.parallel(
|
||||||
|
'dev:extension:js',
|
||||||
|
'test:copy',
|
||||||
|
'dev:reload'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
gulp.task('dev:extension',
|
gulp.task('dev:extension',
|
||||||
gulp.series(
|
gulp.series(
|
||||||
'clean',
|
'clean',
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"dist": "gulp dist",
|
"dist": "gulp dist",
|
||||||
"doc": "jsdoc -c development/tools/.jsdoc.json",
|
"doc": "jsdoc -c development/tools/.jsdoc.json",
|
||||||
"publish-docs": "gh-pages -d docs/jsdocs",
|
"publish-docs": "gh-pages -d docs/jsdocs",
|
||||||
|
"start:test": "gulp dev:test",
|
||||||
"test": "npm run test:unit && npm run test:integration && npm run lint",
|
"test": "npm run test:unit && npm run test:integration && npm run lint",
|
||||||
"watch:test:unit": "nodemon --exec \"npm run test:unit\" ./test ./app ./ui",
|
"watch:test:unit": "nodemon --exec \"npm run test:unit\" ./test ./app ./ui",
|
||||||
"test:unit": "cross-env METAMASK_ENV=test mocha --exit --require test/setup.js --recursive \"test/unit/**/*.js\" \"ui/app/**/*.test.js\"",
|
"test:unit": "cross-env METAMASK_ENV=test mocha --exit --require test/setup.js --recursive \"test/unit/**/*.js\" \"ui/app/**/*.test.js\"",
|
||||||
|
@ -76,7 +76,18 @@ describe('Using MetaMask with an existing account', function () {
|
|||||||
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' +
|
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' +
|
||||||
'(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' +
|
'(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' +
|
||||||
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' +
|
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' +
|
||||||
'return window.origFetch(...args); }'
|
'return window.origFetch(...args); };' +
|
||||||
|
'function cancelInfuraRequest(requestDetails) {' +
|
||||||
|
'console.log("Canceling: " + requestDetails.url);' +
|
||||||
|
'return {' +
|
||||||
|
'cancel: true' +
|
||||||
|
'};' +
|
||||||
|
' }' +
|
||||||
|
'window.chrome && window.chrome.webRequest && window.chrome.webRequest.onBeforeRequest.addListener(' +
|
||||||
|
'cancelInfuraRequest,' +
|
||||||
|
'{urls: ["https://*.infura.io/*"]},' +
|
||||||
|
'["blocking"]' +
|
||||||
|
');'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -75,7 +75,18 @@ describe('MetaMask', function () {
|
|||||||
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' +
|
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' +
|
||||||
'(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' +
|
'(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' +
|
||||||
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' +
|
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' +
|
||||||
'return window.origFetch(...args); }'
|
'return window.origFetch(...args); };' +
|
||||||
|
'function cancelInfuraRequest(requestDetails) {' +
|
||||||
|
'console.log("Canceling: " + requestDetails.url);' +
|
||||||
|
'return {' +
|
||||||
|
'cancel: true' +
|
||||||
|
'};' +
|
||||||
|
' }' +
|
||||||
|
'window.chrome && window.chrome.webRequest && window.chrome.webRequest.onBeforeRequest.addListener(' +
|
||||||
|
'cancelInfuraRequest,' +
|
||||||
|
'{urls: ["https://*.infura.io/*"]},' +
|
||||||
|
'["blocking"]' +
|
||||||
|
');'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -80,7 +80,18 @@ describe('MetaMask', function () {
|
|||||||
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' +
|
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.metametrics + '\')) }); } else if ' +
|
||||||
'(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' +
|
'(args[0] === "https://dev.blockscale.net/api/gasexpress.json") { return ' +
|
||||||
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' +
|
'Promise.resolve({ json: () => Promise.resolve(JSON.parse(\'' + fetchMockResponses.gasExpress + '\')) }); } ' +
|
||||||
'return window.origFetch(...args); }'
|
'return window.origFetch(...args); };' +
|
||||||
|
'function cancelInfuraRequest(requestDetails) {' +
|
||||||
|
'console.log("Canceling: " + requestDetails.url);' +
|
||||||
|
'return {' +
|
||||||
|
'cancel: true' +
|
||||||
|
'};' +
|
||||||
|
' }' +
|
||||||
|
'window.chrome && window.chrome.webRequest && window.chrome.webRequest.onBeforeRequest.addListener(' +
|
||||||
|
'cancelInfuraRequest,' +
|
||||||
|
'{urls: ["https://*.infura.io/*"]},' +
|
||||||
|
'["blocking"]' +
|
||||||
|
');'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1015,11 +1026,13 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
||||||
const functionTypeText = await functionType.getText()
|
const functionTypeText = await functionType.getText()
|
||||||
assert.equal(functionTypeText, 'Transfer')
|
assert.equal(functionTypeText, 'Not Found')
|
||||||
|
|
||||||
const confirmDataDiv = await findElement(driver, By.css('.confirm-page-container-content__data-box'))
|
const confirmDataDiv = await findElement(driver, By.css('.confirm-page-container-content__data-box'))
|
||||||
const confirmDataText = await confirmDataDiv.getText()
|
const confirmDataText = await confirmDataDiv.getText()
|
||||||
assert.equal(confirmDataText.match(/0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c97/))
|
|
||||||
|
await delay(regularDelayMs)
|
||||||
|
assert(confirmDataText.match(/0xa9059cbb0000000000000000000000002f318c334780961fb129d2a6c30d0763d9a5c97/))
|
||||||
|
|
||||||
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
const detailsTab = await findElement(driver, By.xpath(`//li[contains(text(), 'Details')]`))
|
||||||
detailsTab.click()
|
detailsTab.click()
|
||||||
@ -1191,7 +1204,7 @@ describe('MetaMask', function () {
|
|||||||
|
|
||||||
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
const functionType = await findElement(driver, By.css('.confirm-page-container-content__function-type'))
|
||||||
const functionTypeText = await functionType.getText()
|
const functionTypeText = await functionType.getText()
|
||||||
assert.equal(functionTypeText, 'Approve')
|
assert.equal(functionTypeText, 'Not Found')
|
||||||
|
|
||||||
const confirmDataDiv = await findElement(driver, By.css('.confirm-page-container-content__data-box'))
|
const confirmDataDiv = await findElement(driver, By.css('.confirm-page-container-content__data-box'))
|
||||||
const confirmDataText = await confirmDataDiv.getText()
|
const confirmDataText = await confirmDataDiv.getText()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user