Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/js/__mocks__/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const browserWindow = {
loadURL: jest.fn(),
webContents: {
on: () => {},
session: {
clearStorageData: jest.fn(),
},
},
on: () => {},
close: jest.fn(),
Expand Down
8 changes: 8 additions & 0 deletions src/js/utils/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -127,6 +131,10 @@ describe('utils/helpers.ts', () => {
}
);

expect(
new BrowserWindow().webContents.session.clearStorageData
).toHaveBeenCalledTimes(1);

// @ts-ignore
new BrowserWindow().loadURL.mockReset();

Expand Down
3 changes: 3 additions & 0 deletions src/js/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down