Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 of 4 - refactor(config): sw-625 generate routes #1045

Merged
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
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