From e6cd4525067ab9861ccfdb13b5557f988c39bcc5 Mon Sep 17 00:00:00 2001 From: Pedro Figueiredo Date: Tue, 22 Aug 2023 15:06:18 +0100 Subject: [PATCH] fix: Remove sentry warning on `undefined` `TokenListController` (#20547) * fix sentry warning * correct test * switch to using spyOn method --- app/scripts/migrations/088.test.ts | 16 ++++++++++------ app/scripts/migrations/088.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/scripts/migrations/088.test.ts b/app/scripts/migrations/088.test.ts index ca672f982..e60446109 100644 --- a/app/scripts/migrations/088.test.ts +++ b/app/scripts/migrations/088.test.ts @@ -724,7 +724,9 @@ describe('migration #88', () => { expect(newStorage.data).toStrictEqual(oldData); }); - it('captures an exception if it has no TokenListController property', async () => { + it('logs a warning if it has no TokenListController property', async () => { + const mockWarnFn = jest.spyOn(console, 'warn'); + const oldData = { TokensController: {}, NftController: { @@ -760,13 +762,15 @@ describe('migration #88', () => { }; await migrate(oldStorage); - expect(sentryCaptureExceptionMock).toHaveBeenCalledTimes(1); - expect(sentryCaptureExceptionMock).toHaveBeenCalledWith( + expect(mockWarnFn).toHaveBeenCalledTimes(1); + expect(mockWarnFn).toHaveBeenCalledWith( new Error(`typeof state.TokenListController is undefined`), ); }); - it('captures an exception if the TokenListController property is not an object', async () => { + it('logs a warning if the TokenListController property is not an object', async () => { + const mockWarnFn = jest.spyOn(console, 'warn'); + const oldData = { TokensController: {}, NftController: { @@ -803,8 +807,8 @@ describe('migration #88', () => { }; await migrate(oldStorage); - expect(sentryCaptureExceptionMock).toHaveBeenCalledTimes(1); - expect(sentryCaptureExceptionMock).toHaveBeenCalledWith( + expect(mockWarnFn).toHaveBeenCalledTimes(1); + expect(mockWarnFn).toHaveBeenCalledWith( new Error(`typeof state.TokenListController is boolean`), ); }); diff --git a/app/scripts/migrations/088.ts b/app/scripts/migrations/088.ts index 5ede1b0fa..031a1184e 100644 --- a/app/scripts/migrations/088.ts +++ b/app/scripts/migrations/088.ts @@ -164,7 +164,7 @@ function migrateData(state: Record): void { ); } } else { - global.sentry?.captureException?.( + console.warn( new Error( `typeof state.TokenListController is ${typeof state.TokenListController}`, ),