Skip to content

Commit

Permalink
refactor(config): sw-625 generate routes (RedHatInsights#1045)
Browse files Browse the repository at this point in the history
* authentication, redirect errorRoute ref
* build, spelling, jest, local run nav
* config, generate products, routes
* productView, replaced routerHelpers array ref
* productViewMissing, updated routerHelpers
* redirect, simplify, prep router npm update
* redux, viewReducer, updated routerHelpers
* router, prep router npm update
* routerHelpers, refactor, removed unused funcs
  • Loading branch information
cdcabrera committed Feb 3, 2023
1 parent 0894b61 commit 628f57e
Show file tree
Hide file tree
Showing 57 changed files with 4,025 additions and 1,830 deletions.
1 change: 1 addition & 0 deletions config/cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"hoverable",
"ibmpower",
"ibmz",
"iife",
"ipsum",
"keycloak",
"kubernetes",
Expand Down
15 changes: 8 additions & 7 deletions config/jest.setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,21 @@ global.mockWindowLocation = async (
{ url = 'https://ci.foo.redhat.com/subscriptions/rhel', location: locationProps = {} } = {}
) => {
const updatedUrl = new URL(url);
const { location } = window;
delete window.location;
// mock
window.location = {
const updatedLocation = {
href: updatedUrl.href,
search: updatedUrl.search,
hash: updatedUrl.hash,
pathname: updatedUrl.pathname,
replace: Function.prototype,
...locationProps
};
await callback(window.location);
// restore
window.location = location;

const { mockClear } = mockObjectProperty(window, 'location', updatedLocation);
await callback(updatedLocation);

return {
mockClear
};
};

// FixMe: revisit squashing log and group messaging, redux leaks log messaging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,93 +318,8 @@ exports[`Authentication Component should return a redirect on 418 error: 418 err
}
>
<Redirect
isForced={false}
isReplace={true}
route="/optin"
routes={
[
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhel",
"path": "/rhel",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "openshift-container",
"path": "/openshift-container",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "openshift-dedicated",
"path": "/openshift-dedicated",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhacs",
"path": "/rhacs",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhods",
"path": "/rhods",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhosak",
"path": "/streams",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "satellite",
"path": "/satellite",
"redirect": null,
},
{
"activateOnError": true,
"component": "optinView/optinView",
"disabled": false,
"exact": true,
"id": "optin",
"path": "/optin",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productViewMissing",
"disabled": false,
"exact": true,
"id": "missing",
"path": "/",
"redirect": "/",
},
]
}
url={null}
/>
</ContextProvider>
Expand All @@ -423,93 +338,8 @@ exports[`Authentication Component should return a redirect on a specific 403 err
}
>
<Redirect
isForced={false}
isReplace={true}
route="/optin"
routes={
[
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhel",
"path": "/rhel",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "openshift-container",
"path": "/openshift-container",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "openshift-dedicated",
"path": "/openshift-dedicated",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhacs",
"path": "/rhacs",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhods",
"path": "/rhods",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhosak",
"path": "/streams",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "satellite",
"path": "/satellite",
"redirect": null,
},
{
"activateOnError": true,
"component": "optinView/optinView",
"disabled": false,
"exact": true,
"id": "optin",
"path": "/optin",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productViewMissing",
"disabled": false,
"exact": true,
"id": "missing",
"path": "/",
"redirect": "/",
},
]
}
url={null}
/>
</ContextProvider>
Expand All @@ -528,93 +358,8 @@ exports[`Authentication Component should return a redirect on a specific 403 err
}
>
<Redirect
isForced={false}
isReplace={true}
route="/optin"
routes={
[
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhel",
"path": "/rhel",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "openshift-container",
"path": "/openshift-container",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "openshift-dedicated",
"path": "/openshift-dedicated",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhacs",
"path": "/rhacs",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhods",
"path": "/rhods",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "rhosak",
"path": "/streams",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productView",
"disabled": false,
"exact": true,
"id": "satellite",
"path": "/satellite",
"redirect": null,
},
{
"activateOnError": true,
"component": "optinView/optinView",
"disabled": false,
"exact": true,
"id": "optin",
"path": "/optin",
"redirect": null,
},
{
"activateOnError": false,
"component": "productView/productViewMissing",
"disabled": false,
"exact": true,
"id": "missing",
"path": "/",
"redirect": "/",
},
]
}
url={null}
/>
</ContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,38 @@ exports[`AuthenticationContext should apply a hook for retrieving auth data from
}
`;

exports[`AuthenticationContext should apply a hook for retrieving auth data from multiple selectors: success dispatch 1`] = `
[
[
[Function],
],
[
[
{
"payload": Promise {},
"type": "PLATFORM_INIT",
},
{
"meta": {
"data": {
"name": "subscriptions",
},
},
"payload": Promise {},
"type": "PLATFORM_APP_NAME",
},
{
"payload": Promise {},
"type": "PLATFORM_GLOBAL_FILTER_HIDE",
},
],
],
[
[Function],
],
]
`;

exports[`AuthenticationContext should apply a hook for retrieving auth data from multiple selectors: success response 1`] = `
{
"data": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('AuthenticationContext', () => {
expect(context).toMatchSnapshot('specific properties');
});

it('should apply a hook for retrieving auth data from multiple selectors', () => {
it('should apply a hook for retrieving auth data from multiple selectors', async () => {
const { result: errorResponse } = shallowHook(() =>
useGetAuthorization({
useSelectorsResponse: () => ({
Expand All @@ -29,8 +29,10 @@ describe('AuthenticationContext', () => {

expect(errorResponse).toMatchSnapshot('error response');

const { result: successResponse } = shallowHook(() =>
const mockDispatch = jest.fn();
const { result: successResponse } = await mountHook(() =>
useGetAuthorization({
useDispatch: () => mockDispatch,
useSelectorsResponse: () => ({
fulfilled: true,
data: {
Expand All @@ -47,6 +49,7 @@ describe('AuthenticationContext', () => {
})
);

expect(mockDispatch.mock.calls).toMatchSnapshot('success dispatch');
expect(successResponse).toMatchSnapshot('success response');

const { result: mockStoreSuccessResponse } = shallowHook(() => useGetAuthorization(), {
Expand Down
2 changes: 1 addition & 1 deletion src/components/authentication/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Authentication = ({ appName, children, isDisabled, t, useGetAuthorization:
(errorCodes && errorCodes.includes(rhsmConstants.RHSM_API_RESPONSE_ERRORS_CODE_TYPES.OPTIN)) ||
errorStatus === 418
) {
return <Redirect route={routerHelpers.getErrorRoute.path} />;
return <Redirect route={routerHelpers.errorRoute.path} />;
}

return (
Expand Down
Loading

0 comments on commit 628f57e

Please sign in to comment.