mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Refactor Errors E2E test to no longer rely upon a real error (#17332)
Co-authored-by: Danica Shen <zhaodanica@gmail.com>
This commit is contained in:
parent
b746bd0866
commit
d2c3abea51
@ -43,12 +43,7 @@ describe('Sentry errors', function () {
|
|||||||
await driver.fill('#password', 'correct horse battery staple');
|
await driver.fill('#password', 'correct horse battery staple');
|
||||||
await driver.press('#password', driver.Key.ENTER);
|
await driver.press('#password', driver.Key.ENTER);
|
||||||
// Trigger error
|
// Trigger error
|
||||||
await driver.clickElement('[data-testid="eth-overview-send"]');
|
driver.executeScript('window.stateHooks.throwTestError()');
|
||||||
await driver.fill(
|
|
||||||
'input[placeholder="Search, public address (0x), or ENS"]',
|
|
||||||
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
||||||
);
|
|
||||||
await driver.fill('input[placeholder="0"]', `-01`);
|
|
||||||
// Wait for Sentry request
|
// Wait for Sentry request
|
||||||
await driver.wait(async () => {
|
await driver.wait(async () => {
|
||||||
const isPending = await mockedEndpoint.isPending();
|
const isPending = await mockedEndpoint.isPending();
|
||||||
@ -60,11 +55,8 @@ describe('Sentry errors', function () {
|
|||||||
const [{ type, value }] = mockJsonBody.exception.values;
|
const [{ type, value }] = mockJsonBody.exception.values;
|
||||||
const { participateInMetaMetrics } = extra.appState.store.metamask;
|
const { participateInMetaMetrics } = extra.appState.store.metamask;
|
||||||
// Verify request
|
// Verify request
|
||||||
assert.equal(type, 'BigNumber Error');
|
assert.equal(type, 'TestError');
|
||||||
assert.equal(
|
assert.equal(value, 'Test Error');
|
||||||
value,
|
|
||||||
'new BigNumber() not a base 16 number: 0x-de0b6b3a7640000',
|
|
||||||
);
|
|
||||||
assert.equal(level, 'error');
|
assert.equal(level, 'error');
|
||||||
assert.equal(participateInMetaMetrics, true);
|
assert.equal(participateInMetaMetrics, true);
|
||||||
},
|
},
|
||||||
|
@ -164,6 +164,15 @@ async function startApp(metamaskState, backgroundConnection, opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupDebuggingHelpers(store) {
|
function setupDebuggingHelpers(store) {
|
||||||
|
/**
|
||||||
|
* The following stateHook is a method intended to throw an error, used in
|
||||||
|
* our E2E test to ensure that errors are attempted to be sent to sentry.
|
||||||
|
*/
|
||||||
|
window.stateHooks.throwTestError = async function () {
|
||||||
|
const error = new Error('Test Error');
|
||||||
|
error.name = 'TestError';
|
||||||
|
throw error;
|
||||||
|
};
|
||||||
window.stateHooks.getCleanAppState = async function () {
|
window.stateHooks.getCleanAppState = async function () {
|
||||||
const state = clone(store.getState());
|
const state = clone(store.getState());
|
||||||
state.version = global.platform.getVersion();
|
state.version = global.platform.getVersion();
|
||||||
|
Loading…
Reference in New Issue
Block a user