From 344458b7d4fea60843257b7dc078cb3bc98b4a79 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 08:41:41 +0000 Subject: [PATCH 1/6] fix(deps): update dependency axios to v1 --- package.json | 2 +- pnpm-lock.yaml | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 014e9f1a8..0fac5c3fc 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ }, "dependencies": { "@primer/octicons-react": "19.8.0", - "axios": "0.27.2", + "axios": "1.5.1", "date-fns": "2.30.0", "electron-updater": "6.1.4", "final-form": "4.20.10", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7e3362eda..bcbe86733 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: 19.8.0 version: 19.8.0(react@18.2.0) axios: - specifier: 0.27.2 - version: 0.27.2 + specifier: 1.5.1 + version: 1.5.1 date-fns: specifier: 2.30.0 version: 2.30.0 @@ -1541,11 +1541,12 @@ packages: resolution: {integrity: sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==} dev: true - /axios@0.27.2: - resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} + /axios@1.5.1: + resolution: {integrity: sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==} dependencies: follow-redirects: 1.15.2 form-data: 4.0.0 + proxy-from-env: 1.1.0 transitivePeerDependencies: - debug dev: false @@ -4649,6 +4650,10 @@ packages: requiresBuild: true optional: true + /proxy-from-env@1.1.0: + resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + dev: false + /psl@1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} dev: true From c381461940e7514cd1630093ef4c467afbe4ff68 Mon Sep 17 00:00:00 2001 From: Brendan Mulholland Date: Mon, 2 Oct 2023 10:45:26 +0200 Subject: [PATCH 2/6] Use new adapter setting See https://github.com/axios/axios/pull/5277 --- src/hooks/useNotifications.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useNotifications.test.ts b/src/hooks/useNotifications.test.ts index b9ab59296..593689b4a 100644 --- a/src/hooks/useNotifications.test.ts +++ b/src/hooks/useNotifications.test.ts @@ -9,7 +9,7 @@ import { mockedUser } from '../__mocks__/mockedData'; describe('hooks/useNotifications.ts', () => { beforeEach(() => { - axios.defaults.adapter = require('axios/lib/adapters/http'); + axios.defaults.adapter = 'http'; }); describe('fetchNotifications', () => { From 3cf31f5f5f5a76c13fd15f2146f1cb6f846a00cc Mon Sep 17 00:00:00 2001 From: Brendan Mulholland Date: Tue, 3 Oct 2023 12:12:32 +0200 Subject: [PATCH 3/6] Fix tests --- jest.config.js | 20 ++++++++++++++++++++ package.json | 12 ------------ src/hooks/useNotifications.test.ts | 2 ++ 3 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 jest.config.js diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 000000000..da0781231 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,20 @@ +const config = { + "preset": "ts-jest/presets/js-with-ts", + "setupFiles": [ + "/src/__helpers__/setupEnvVars.js" + ], + "testEnvironment": "jsdom", + "coverageThreshold": { + "global": { + "lines": 90 + } + }, + "transformIgnorePatterns": ["node_modules\/(?!axios)"], + "moduleNameMapper": { + // Force CommonJS build for http adapter to be available. + // via https://github.com/axios/axios/issues/5101#issuecomment-1276572468 + '^axios$': require.resolve('axios'), + }, +} + +module.exports = config; diff --git a/package.json b/package.json index 0fac5c3fc..9e85b0cd0 100644 --- a/package.json +++ b/package.json @@ -48,18 +48,6 @@ "url": "https://github.com/manosim/gitify/issues" }, "homepage": "https://www.gitify.io/", - "jest": { - "preset": "ts-jest/presets/js-with-ts", - "setupFiles": [ - "/src/__helpers__/setupEnvVars.js" - ], - "testEnvironment": "jsdom", - "coverageThreshold": { - "global": { - "lines": 90 - } - } - }, "build": { "appId": "com.electron.gitify", "productName": "Gitify", diff --git a/src/hooks/useNotifications.test.ts b/src/hooks/useNotifications.test.ts index 593689b4a..dce5e9e18 100644 --- a/src/hooks/useNotifications.test.ts +++ b/src/hooks/useNotifications.test.ts @@ -9,6 +9,8 @@ import { mockedUser } from '../__mocks__/mockedData'; describe('hooks/useNotifications.ts', () => { beforeEach(() => { + // axios will default to using the XHR adapter which can't be intercepted + // by nock. So, configure axios to use the node adapter. axios.defaults.adapter = 'http'; }); From 968ef26f5812c0c4d38fe447c1aff210fa5c3132 Mon Sep 17 00:00:00 2001 From: Brendan Mulholland Date: Tue, 3 Oct 2023 12:14:47 +0200 Subject: [PATCH 4/6] Remove unnecessary transform --- jest.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index da0781231..f412fe027 100644 --- a/jest.config.js +++ b/jest.config.js @@ -9,7 +9,6 @@ const config = { "lines": 90 } }, - "transformIgnorePatterns": ["node_modules\/(?!axios)"], "moduleNameMapper": { // Force CommonJS build for http adapter to be available. // via https://github.com/axios/axios/issues/5101#issuecomment-1276572468 From 98a923369cd9513b19f70a4f907bb7e51abc5f5e Mon Sep 17 00:00:00 2001 From: Brendan Mulholland Date: Tue, 3 Oct 2023 12:19:20 +0200 Subject: [PATCH 5/6] chore(deps): Remove history dependency --- package.json | 1 - pnpm-lock.yaml | 30 ------------------------------ 2 files changed, 31 deletions(-) diff --git a/package.json b/package.json index 9e85b0cd0..1e0113315 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,6 @@ "date-fns": "2.30.0", "electron-updater": "6.1.4", "final-form": "4.20.10", - "history": "4.10.1", "lodash": "4.17.21", "menubar": "9.3.0", "nprogress": "0.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bcbe86733..d4ff47e59 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,9 +20,6 @@ dependencies: final-form: specifier: 4.20.10 version: 4.20.10 - history: - specifier: 4.10.1 - version: 4.10.1 lodash: specifier: 4.17.21 version: 4.17.21 @@ -2975,17 +2972,6 @@ packages: dependencies: function-bind: 1.1.1 - /history@4.10.1: - resolution: {integrity: sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==} - dependencies: - '@babel/runtime': 7.21.5 - loose-envify: 1.4.0 - resolve-pathname: 3.0.0 - tiny-invariant: 1.3.1 - tiny-warning: 1.0.3 - value-equal: 1.0.1 - dev: false - /hosted-git-info@4.1.0: resolution: {integrity: sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA==} engines: {node: '>=10'} @@ -4911,10 +4897,6 @@ packages: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} engines: {node: '>=8'} - /resolve-pathname@3.0.0: - resolution: {integrity: sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==} - dev: false - /resolve.exports@2.0.2: resolution: {integrity: sha512-X2UW6Nw3n/aMgDVy+0rSqgHlv39WZAlZrXCdnbyEiKm17DSqHX4MmQMaST3FbeWR5FTuRcUwYAziZajji0Y7mg==} engines: {node: '>=10'} @@ -5385,18 +5367,10 @@ packages: any-promise: 1.3.0 dev: true - /tiny-invariant@1.3.1: - resolution: {integrity: sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==} - dev: false - /tiny-typed-emitter@2.1.0: resolution: {integrity: sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==} dev: false - /tiny-warning@1.0.3: - resolution: {integrity: sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==} - dev: false - /tmp-promise@3.0.3: resolution: {integrity: sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==} dependencies: @@ -5630,10 +5604,6 @@ packages: convert-source-map: 1.9.0 dev: true - /value-equal@1.0.1: - resolution: {integrity: sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==} - dev: false - /verror@1.10.0: resolution: {integrity: sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==} engines: {'0': node >=0.6.0} From ed2c25fd203cad52bb6223a43826148567312058 Mon Sep 17 00:00:00 2001 From: Afonso Jorge Ramos Date: Fri, 20 Oct 2023 18:58:58 +0100 Subject: [PATCH 6/6] chore: update tests to remove `history` --- src/components/Sidebar.test.tsx | 7 ++----- src/routes/Login.test.tsx | 16 ++++++---------- src/routes/LoginEnterprise.test.tsx | 16 ++++++---------- src/routes/LoginWithToken.test.tsx | 19 ++++++++----------- src/routes/Settings.test.tsx | 15 ++++++--------- 5 files changed, 28 insertions(+), 45 deletions(-) diff --git a/src/components/Sidebar.test.tsx b/src/components/Sidebar.test.tsx index 5372c5a20..94c5bf878 100644 --- a/src/components/Sidebar.test.tsx +++ b/src/components/Sidebar.test.tsx @@ -1,7 +1,5 @@ import { fireEvent, render, screen } from '@testing-library/react'; -import { createMemoryHistory } from 'history'; import * as React from 'react'; -import { Router } from 'react-router'; import { MemoryRouter } from 'react-router-dom'; import * as TestRenderer from 'react-test-renderer'; @@ -20,7 +18,6 @@ jest.mock('react-router-dom', () => ({ describe('components/Sidebar.tsx', () => { const fetchNotifications = jest.fn(); - const history = createMemoryHistory(); beforeEach(() => { fetchNotifications.mockReset(); @@ -81,9 +78,9 @@ describe('components/Sidebar.tsx', () => { it('go to the settings route', () => { const { getByLabelText } = render( - + - + , ); fireEvent.click(getByLabelText('Settings')); diff --git a/src/routes/Login.test.tsx b/src/routes/Login.test.tsx index fe70f27a0..77419ade4 100644 --- a/src/routes/Login.test.tsx +++ b/src/routes/Login.test.tsx @@ -1,8 +1,6 @@ import React from 'react'; import TestRenderer from 'react-test-renderer'; -import { Router } from 'react-router'; import { MemoryRouter } from 'react-router-dom'; -import { createMemoryHistory } from 'history'; import { render, fireEvent } from '@testing-library/react'; const { ipcRenderer } = require('electron'); @@ -17,8 +15,6 @@ jest.mock('react-router-dom', () => ({ })); describe('routes/Login.tsx', () => { - const history = createMemoryHistory(); - beforeEach(() => { mockNavigate.mockReset(); jest.spyOn(ipcRenderer, 'send'); @@ -37,17 +33,17 @@ describe('routes/Login.tsx', () => { it('should redirect to notifications once logged in', () => { const { rerender } = render( - + - + , ); rerender( - + - + , ); @@ -58,9 +54,9 @@ describe('routes/Login.tsx', () => { it('should navigate to login with github enterprise', () => { const { getByLabelText } = render( - + - , + , ); fireEvent.click(getByLabelText('Login with GitHub Enterprise')); diff --git a/src/routes/LoginEnterprise.test.tsx b/src/routes/LoginEnterprise.test.tsx index c85b231fd..f6c31c0f2 100644 --- a/src/routes/LoginEnterprise.test.tsx +++ b/src/routes/LoginEnterprise.test.tsx @@ -1,9 +1,7 @@ import * as React from 'react'; import * as TestRenderer from 'react-test-renderer'; import { fireEvent, render } from '@testing-library/react'; -import { Router } from 'react-router'; import { MemoryRouter } from 'react-router-dom'; -import { createMemoryHistory } from 'history'; const { ipcRenderer } = require('electron'); @@ -19,8 +17,6 @@ jest.mock('react-router-dom', () => ({ })); describe('routes/LoginEnterprise.js', () => { - const history = createMemoryHistory(); - const mockAccounts: AuthState = { enterpriseAccounts: [], user: null, @@ -47,9 +43,9 @@ describe('routes/LoginEnterprise.js', () => { it('let us go back', () => { const { getByLabelText } = render( - + - + , ); @@ -86,9 +82,9 @@ describe('routes/LoginEnterprise.js', () => { it('should receive a logged-in enterprise account', () => { const { rerender } = render( - + - + , ); @@ -101,9 +97,9 @@ describe('routes/LoginEnterprise.js', () => { }, }} > - + - + , ); diff --git a/src/routes/LoginWithToken.test.tsx b/src/routes/LoginWithToken.test.tsx index c4f5ccb12..a1e0d0eb4 100644 --- a/src/routes/LoginWithToken.test.tsx +++ b/src/routes/LoginWithToken.test.tsx @@ -1,9 +1,7 @@ import React from 'react'; import TestRenderer from 'react-test-renderer'; import { act, fireEvent, render, waitFor } from '@testing-library/react'; -import { Router } from 'react-router'; import { MemoryRouter } from 'react-router-dom'; -import { createMemoryHistory } from 'history'; import { shell } from 'electron'; import { AppContext } from '../context/App'; @@ -16,7 +14,6 @@ jest.mock('react-router-dom', () => ({ })); describe('routes/LoginWithToken.js', () => { - const history = createMemoryHistory(); const openExternalMock = jest.spyOn(shell, 'openExternal'); const mockValidateToken = jest.fn(); @@ -43,9 +40,9 @@ describe('routes/LoginWithToken.js', () => { it('let us go back', () => { const { getByLabelText } = render( - + - , + , ); fireEvent.click(getByLabelText('Go Back')); @@ -77,9 +74,9 @@ describe('routes/LoginWithToken.js', () => { it("should click on the 'personal access tokens' link and open the browser", async () => { const { getByText } = render( - + - + , ); @@ -93,9 +90,9 @@ describe('routes/LoginWithToken.js', () => { const { getByLabelText, getByTitle } = render( - + - + , ); @@ -119,9 +116,9 @@ describe('routes/LoginWithToken.js', () => { const { getByLabelText, getByTitle } = render( - + - + , ); diff --git a/src/routes/Settings.test.tsx b/src/routes/Settings.test.tsx index a5aedeac6..d8565a1fc 100644 --- a/src/routes/Settings.test.tsx +++ b/src/routes/Settings.test.tsx @@ -1,9 +1,7 @@ import React from 'react'; import TestRenderer, { act } from 'react-test-renderer'; import { render, fireEvent } from '@testing-library/react'; -import { Router } from 'react-router'; import { MemoryRouter } from 'react-router-dom'; -import { createMemoryHistory } from 'history'; const { ipcRenderer } = require('electron'); @@ -18,7 +16,6 @@ jest.mock('react-router-dom', () => ({ })); describe('routes/Settings.tsx', () => { - const history = createMemoryHistory(); const updateSetting = jest.fn(); beforeEach(() => { @@ -50,9 +47,9 @@ describe('routes/Settings.tsx', () => { - + - + , ); @@ -74,9 +71,9 @@ describe('routes/Settings.tsx', () => { await act(async () => { const { getByLabelText: getByLabelTextLocal } = render( - + - + , ); @@ -222,9 +219,9 @@ describe('routes/Settings.tsx', () => { await act(async () => { const { getByLabelText: getByLabelTextLocal } = render( - + - + , ); getByLabelText = getByLabelTextLocal;