mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Sentry e2e test (#15715)
This commit is contained in:
parent
341f761dd7
commit
fe78890dd2
@ -11,6 +11,7 @@ const METAMASK_DEBUG = process.env.METAMASK_DEBUG;
|
|||||||
const METAMASK_ENVIRONMENT = process.env.METAMASK_ENVIRONMENT;
|
const METAMASK_ENVIRONMENT = process.env.METAMASK_ENVIRONMENT;
|
||||||
const SENTRY_DSN_DEV = process.env.SENTRY_DSN_DEV;
|
const SENTRY_DSN_DEV = process.env.SENTRY_DSN_DEV;
|
||||||
const METAMASK_BUILD_TYPE = process.env.METAMASK_BUILD_TYPE;
|
const METAMASK_BUILD_TYPE = process.env.METAMASK_BUILD_TYPE;
|
||||||
|
const IN_TEST = process.env.IN_TEST;
|
||||||
/* eslint-enable prefer-destructuring */
|
/* eslint-enable prefer-destructuring */
|
||||||
|
|
||||||
// This describes the subset of Redux state attached to errors sent to Sentry
|
// This describes the subset of Redux state attached to errors sent to Sentry
|
||||||
@ -71,7 +72,13 @@ export const SENTRY_STATE = {
|
|||||||
export default function setupSentry({ release, getState }) {
|
export default function setupSentry({ release, getState }) {
|
||||||
if (!release) {
|
if (!release) {
|
||||||
throw new Error('Missing release');
|
throw new Error('Missing release');
|
||||||
} else if (METAMASK_DEBUG) {
|
} else if (METAMASK_DEBUG && !IN_TEST) {
|
||||||
|
/**
|
||||||
|
* Workaround until the following issue is resolved
|
||||||
|
* https://github.com/MetaMask/metamask-extension/issues/15691
|
||||||
|
* The IN_TEST condition allows the e2e tests to run with both
|
||||||
|
* yarn start:test and yarn build:test
|
||||||
|
*/
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
"dist": "yarn build dist",
|
"dist": "yarn build dist",
|
||||||
"build": "yarn lavamoat:build",
|
"build": "yarn lavamoat:build",
|
||||||
"build:dev": "node development/build/index.js",
|
"build:dev": "node development/build/index.js",
|
||||||
"start:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' yarn build testDev",
|
"start:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://fake@sentry.io/0000000 yarn build testDev",
|
||||||
"benchmark:chrome": "SELENIUM_BROWSER=chrome node test/e2e/benchmark.js",
|
"benchmark:chrome": "SELENIUM_BROWSER=chrome node test/e2e/benchmark.js",
|
||||||
"mv3:stats:chrome": "SELENIUM_BROWSER=chrome ENABLE_MV3=true node test/e2e/mv3-perf-stats/index.js",
|
"mv3:stats:chrome": "SELENIUM_BROWSER=chrome ENABLE_MV3=true node test/e2e/mv3-perf-stats/index.js",
|
||||||
"user-actions-benchmark:chrome": "SELENIUM_BROWSER=chrome node test/e2e/user-actions-benchmark.js",
|
"user-actions-benchmark:chrome": "SELENIUM_BROWSER=chrome node test/e2e/user-actions-benchmark.js",
|
||||||
"benchmark:firefox": "SELENIUM_BROWSER=firefox node test/e2e/benchmark.js",
|
"benchmark:firefox": "SELENIUM_BROWSER=firefox node test/e2e/benchmark.js",
|
||||||
"build:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' yarn build test",
|
"build:test": "SEGMENT_HOST='https://api.segment.io' SEGMENT_WRITE_KEY='FAKE' SENTRY_DSN_DEV=https://fake@sentry.io/0000000 yarn build test",
|
||||||
"build:test:flask": "yarn build test --build-type flask",
|
"build:test:flask": "yarn build test --build-type flask",
|
||||||
"build:test:mv3": "ENABLE_MV3=true yarn build test",
|
"build:test:mv3": "ENABLE_MV3=true yarn build test",
|
||||||
"test": "yarn lint && yarn test:unit && yarn test:unit:jest",
|
"test": "yarn lint && yarn test:unit && yarn test:unit:jest",
|
||||||
|
@ -25,6 +25,24 @@ async function setupMocking(server, testSpecificMock) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await server
|
||||||
|
.forPost('https://sentry.io/api/0000000/envelope/')
|
||||||
|
.thenCallback(() => {
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
json: {},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
await server
|
||||||
|
.forPost('https://sentry.io/api/0000000/store/')
|
||||||
|
.thenCallback(() => {
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
json: {},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
await server
|
await server
|
||||||
.forGet('https://www.4byte.directory/api/v1/signatures/')
|
.forGet('https://www.4byte.directory/api/v1/signatures/')
|
||||||
.thenCallback(() => {
|
.thenCallback(() => {
|
||||||
|
67
test/e2e/tests/errors.spec.js
Normal file
67
test/e2e/tests/errors.spec.js
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
const { strict: assert } = require('assert');
|
||||||
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
||||||
|
|
||||||
|
describe('Sentry errors', function () {
|
||||||
|
async function mockSegment(mockServer) {
|
||||||
|
mockServer.reset();
|
||||||
|
await mockServer.forAnyRequest().thenPassThrough();
|
||||||
|
return await mockServer
|
||||||
|
.forPost('https://sentry.io/api/0000000/store/')
|
||||||
|
.thenCallback(() => {
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
json: {},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ganacheOptions = {
|
||||||
|
accounts: [
|
||||||
|
{
|
||||||
|
secretKey:
|
||||||
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
||||||
|
balance: convertToHexValue(25000000000000000000),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
it('should send error events', async function () {
|
||||||
|
await withFixtures(
|
||||||
|
{
|
||||||
|
fixtures: 'metrics-enabled',
|
||||||
|
ganacheOptions,
|
||||||
|
title: this.test.title,
|
||||||
|
failOnConsoleError: false,
|
||||||
|
},
|
||||||
|
async ({ driver, mockServer }) => {
|
||||||
|
const mockedEndpoint = await mockSegment(mockServer);
|
||||||
|
await driver.navigate();
|
||||||
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
|
// Trigger error
|
||||||
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
||||||
|
await driver.fill(
|
||||||
|
'input[placeholder="Search, public address (0x), or ENS"]',
|
||||||
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
||||||
|
);
|
||||||
|
await driver.fill('input[placeholder="0"]', `-01`);
|
||||||
|
// Wait for Sentry request
|
||||||
|
await driver.wait(async () => {
|
||||||
|
const isPending = await mockedEndpoint.isPending();
|
||||||
|
return isPending === false;
|
||||||
|
}, 10000);
|
||||||
|
const [mockedRequest] = await mockedEndpoint.getSeenRequests();
|
||||||
|
const mockJsonBody = mockedRequest.body.json;
|
||||||
|
const { level, extra } = mockJsonBody;
|
||||||
|
const [{ type, value }] = mockJsonBody.exception.values;
|
||||||
|
const { participateInMetaMetrics } = extra.appState.store.metamask;
|
||||||
|
// Verify request
|
||||||
|
assert.equal(type, 'BigNumber Error');
|
||||||
|
assert.equal(
|
||||||
|
value,
|
||||||
|
'new BigNumber() not a base 16 number: 0x-de0b6b3a7640000',
|
||||||
|
);
|
||||||
|
assert.equal(level, 'error');
|
||||||
|
assert.equal(participateInMetaMetrics, true);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
@ -30,6 +30,7 @@ describe('Segment metrics', function () {
|
|||||||
fixtures: 'metrics-enabled',
|
fixtures: 'metrics-enabled',
|
||||||
ganacheOptions,
|
ganacheOptions,
|
||||||
title: this.test.title,
|
title: this.test.title,
|
||||||
|
failOnConsoleError: false,
|
||||||
},
|
},
|
||||||
async ({ driver, mockServer }) => {
|
async ({ driver, mockServer }) => {
|
||||||
const mockedEndpoints = await mockSegment(mockServer);
|
const mockedEndpoints = await mockSegment(mockServer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user