diff --git a/src/js/__mocks__/electron.js b/src/js/__mocks__/electron.js index 63da587c1..5baa1f98d 100644 --- a/src/js/__mocks__/electron.js +++ b/src/js/__mocks__/electron.js @@ -31,6 +31,9 @@ const browserWindow = { loadURL: jest.fn(), webContents: { on: () => {}, + session: { + clearStorageData: jest.fn(), + }, }, on: () => {}, close: jest.fn(), diff --git a/src/js/utils/helpers.test.ts b/src/js/utils/helpers.test.ts index 9c1d003b3..ce4e181df 100644 --- a/src/js/utils/helpers.test.ts +++ b/src/js/utils/helpers.test.ts @@ -105,6 +105,10 @@ describe('utils/helpers.ts', () => { authGithub(undefined, dispatch); + expect( + new BrowserWindow().webContents.session.clearStorageData + ).toHaveBeenCalledTimes(1); + expect(new BrowserWindow().loadURL).toHaveBeenCalledTimes(1); expect(new BrowserWindow().loadURL).toHaveBeenCalledWith( 'https://github.com/login/oauth/authorize?client_id=3fef4433a29c6ad8f22c&scope=user:email,notifications' @@ -127,6 +131,10 @@ describe('utils/helpers.ts', () => { } ); + expect( + new BrowserWindow().webContents.session.clearStorageData + ).toHaveBeenCalledTimes(1); + // @ts-ignore new BrowserWindow().loadURL.mockReset(); diff --git a/src/js/utils/helpers.ts b/src/js/utils/helpers.ts index f3a4324f7..267cf07cd 100644 --- a/src/js/utils/helpers.ts +++ b/src/js/utils/helpers.ts @@ -53,6 +53,9 @@ export function authGithub( const githubUrl = `https://${authOptions.hostname}/login/oauth/authorize`; const authUrl = `${githubUrl}?client_id=${authOptions.clientId}&scope=${Constants.AUTH_SCOPE}`; + const session = authWindow.webContents.session; + session.clearStorageData(); + authWindow.loadURL(authUrl); function handleCallback(url) {