diff --git a/src/Utilities/ChromeLoader.js b/src/Utilities/ChromeLoader.js
new file mode 100644
index 000000000..246cf5bc2
--- /dev/null
+++ b/src/Utilities/ChromeLoader.js
@@ -0,0 +1,23 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import useChrome from '@redhat-cloud-services/frontend-components/useChrome';
+
+const ChromeLoader = ({ children }) => {
+ const chrome = useChrome();
+
+ return <>
+ {React.Children.map(children, child => {
+ if (React.isValidElement(child)) {
+ return React.cloneElement(child, { chrome });
+ }
+
+ return child;
+ })}
+ >;
+};
+
+ChromeLoader.propTypes = {
+ children: PropTypes.any
+};
+
+export default ChromeLoader;
diff --git a/src/components/InventoryGroupDetail/GroupDetailInfo.cy.js b/src/components/InventoryGroupDetail/GroupDetailInfo.cy.js
index 539acb02c..9e6b91a30 100644
--- a/src/components/InventoryGroupDetail/GroupDetailInfo.cy.js
+++ b/src/components/InventoryGroupDetail/GroupDetailInfo.cy.js
@@ -1,40 +1,39 @@
import { mount } from '@cypress/react';
import React from 'react';
-import GroupDetailInfo from './GroupDetailInfo';
+import { GroupDetailInfo } from './GroupDetailInfo';
-const mountPage = () =>
+const mountPage = (params) =>
mount(
-
+
);
-before(() => {
- cy.window().then(
- (window) =>
- (window.insights = {
- chrome: {
- isProd: false,
- auth: {
- getUser: () => {
- return Promise.resolve({});
- }
- }
- }
- })
- );
-});
-
describe('group detail information page', () => {
- it('Title is rendered', () => {
- mountPage();
+ beforeEach(() => {
+ mountPage({ chrome: { isBeta: () => false } });
+ });
+
+ it('title is rendered', () => {
cy.get('div[class="pf-c-card__title pf-c-title pf-m-lg card-title"]').should('have.text', 'User access configuration');
});
+
it('button is present', () => {
- mountPage();
- cy.get('button[class="pf-c-button pf-m-secondary"]').should('have.text', 'Manage access');
+ cy.get('a[class="pf-c-button pf-m-secondary"]').should('have.text', 'Manage access');
});
+
it('card text is present', () => {
- mountPage();
cy.get('div[class="pf-c-card__body"]').should
('have.text', 'Manage your inventory group user access configuration under Identity & Access Management > User Access.');
});
+
+ describe('links', () => {
+ it('in stable environment', () => {
+ mountPage({ chrome: { isBeta: () => false } });
+ cy.get('a').should('have.attr', 'href', '/iam/user-access');
+ });
+
+ it('in beta environment', () => {
+ mountPage({ chrome: { isBeta: () => true } });
+ cy.get('a').should('have.attr', 'href', '/beta/iam/user-access');
+ });
+ });
});
diff --git a/src/components/InventoryGroupDetail/GroupDetailInfo.js b/src/components/InventoryGroupDetail/GroupDetailInfo.js
index 24229e050..78914050d 100644
--- a/src/components/InventoryGroupDetail/GroupDetailInfo.js
+++ b/src/components/InventoryGroupDetail/GroupDetailInfo.js
@@ -6,30 +6,41 @@ import {
CardHeader,
CardActions } from '@patternfly/react-core';
import React from 'react';
+import PropTypes from 'prop-types';
+import ChromeLoader from '../../Utilities/ChromeLoader';
-const GroupDetailInfo = () => {
- const address = window.location.href.includes('beta') ? '/beta/iam/user-access' : '/iam/user-access';
+const GroupDetailInfo = ({ chrome }) => {
+ const path = `${chrome.isBeta() ? '/beta' : ''}/iam/user-access`;
return (
-
- User access configuration
+
+ User access configuration
+
- Manage your inventory group user access configuration under
- Identity & Access Management {'>'} User Access.
+ Manage your inventory group user access configuration under
+ Identity & Access Management {'>'} User Access.
);
};
-export default GroupDetailInfo;
+GroupDetailInfo.propTypes = {
+ chrome: PropTypes.object
+};
+
+const GroupDetailInfoWithChrome = () => (
+
+
+
+);
+
+export { GroupDetailInfo };
+export default GroupDetailInfoWithChrome;