Skip to content

Commit

Permalink
[VULN-2507] Upgrade react-router-dom to v6
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Johnson committed Jul 28, 2023
1 parent 805f2be commit 2f00514
Show file tree
Hide file tree
Showing 51 changed files with 8,874 additions and 14,060 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 @@ -31,7 +31,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 @@ -12,7 +12,12 @@ plugins.push(
exposes: {
'./RootApp': resolve(__dirname, '../src/AppEntry'),
'./SystemDetail': resolve(__dirname, '../src/index.js')
}
},
shared: [
{
'react-router-dom': { singleton: true, requiredVersion: '*' }
}
]
})
);

Expand Down
65 changes: 48 additions & 17 deletions config/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,35 @@ 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() });

global.shallow = shallow;
global.render = render;
global.mount = mount;
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()
}),
useChrome: () => ({
isBeta: jest.fn(),
chrome: jest.fn(),
updateDocumentTitle: jest.fn(),
hideGlobalFilter: jest.fn()
}),
}));
jest.mock('@redhat-cloud-services/frontend-components/useChrome', () => {
return {
__esModule: true,
default: () => ({
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()
}),
};
});

window.insights = {
chrome: {
Expand Down Expand Up @@ -83,4 +88,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 2f00514

Please sign in to comment.