Skip to content

Commit

Permalink
fix(VULN-2507): Upgrade react-router-dom to v6 (#1905)
Browse files Browse the repository at this point in the history
Fixes https://issues.redhat.com/browse/VULN-2507.

---------

Co-authored-by: Michael Johnson <micjohns@newbeginnings.usersys.redhat.com>
Co-authored-by: Georgii Karataev <georgkarat@gmail.com>
  • Loading branch information
3 people authored Sep 11, 2023
1 parent 22e36c3 commit 0406a7e
Show file tree
Hide file tree
Showing 45 changed files with 8,352 additions and 13,788 deletions.
15 changes: 15 additions & 0 deletions config/cypress.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ const { config: webpackConfig, plugins } = config({
rootFolder: resolve(__dirname, '../')
});

webpackConfig.module.rules.push({
resolve: {
alias: {
'@redhat-cloud-services/frontend-components/useChrome': resolve(
__dirname,
'./overrideChrome.js'
),
'../useChrome': resolve(
__dirname,
'./overrideChrome.js'
)
}
}
});

plugins.push(
new webpack.DefinePlugin({
insights: {
Expand Down
7 changes: 6 additions & 1 deletion config/dev.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ plugins.push(
exposes: {
'./RootApp': resolve(__dirname, '../src/AppEntry'),
'./SystemDetail': resolve(__dirname, '../src/index.js')
}
},
shared: [
{
'react-router-dom': { singleton: true, requiredVersion: '*' }
}
]
})
);

Expand Down
6 changes: 6 additions & 0 deletions config/overrideChrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default () => ({
updateDocumentTitle: () => undefined,
isBeta: () => true,
getApp: () => 'patch',
getBundle: () => 'insights'
});
7 changes: 6 additions & 1 deletion config/prod.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ plugins.push(
exposes: {
'./RootApp': resolve(__dirname, '../src/AppEntry'),
'./SystemDetail': resolve(__dirname, '../src/index.js')
}
},
shared: [
{
'react-router-dom': { singleton: true, requiredVersion: '*' }
}
]
})
);

Expand Down
51 changes: 40 additions & 11 deletions config/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { configure, mount, render, shallow } from 'enzyme';
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
import React from 'react';
import 'babel-polyfill';
import { TextDecoder, TextEncoder } from 'util';

configure({ adapter: new Adapter() });

Expand All @@ -12,20 +13,22 @@ global.React = React;
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => ({
__esModule: true,
default: () => ({
updateDocumentTitle: jest.fn(),
appAction: jest.fn(),
appObjectId: jest.fn(),
on: jest.fn(),
isBeta: jest.fn(),
hideGlobalFilter: jest.fn()
updateDocumentTitle: jest.fn(),
appAction: jest.fn(),
appObjectId: jest.fn(),
on: () => { },
isBeta: jest.fn(),
hideGlobalFilter: () => { },
getApp: () => 'vulnerability',
getBundle: () => 'insights',
}),
useChrome: () => ({
isBeta: jest.fn(),
chrome: jest.fn(),
updateDocumentTitle: jest.fn(),
hideGlobalFilter: jest.fn()
isBeta: jest.fn(),
chrome: jest.fn(),
updateDocumentTitle: jest.fn(),
hideGlobalFilter: jest.fn()
}),
}));
}));

window.insights = {
chrome: {
Expand Down Expand Up @@ -83,4 +86,30 @@ global.window.__scalprum__ = {
};

jest.useFakeTimers('modern').setSystemTime(new Date('2020-01-01').getTime());

jest.mock('@redhat-cloud-services/frontend-components/Inventory', () => ({
InventoryTable: (props) => <div {...props} />,
}));

jest.mock('@redhat-cloud-services/frontend-components/AsyncComponent', () => {
return {
__esModule: true,
default: () => (<div>AsyncComponent</div>)
};
});

jest.mock('@redhat-cloud-services/frontend-components-pdf-generator', () => {
return {
__esModule: true,
Section: () => (<div />),
Panel: () => (<div />),
PanelItem: () => (<div />),
InsightsLabel: () => (<div />),
Table: () => (<div />),
Paragraph: () => (<div />)
};
});

// Required for React 18 but not provided by jsdom env. See: /~https://github.com/jsdom/jsdom/issues/2524
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
Loading

0 comments on commit 0406a7e

Please sign in to comment.