-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ESSNTL-4196): Tie URLs to chrome isBeta (#1817)
- Loading branch information
Showing
3 changed files
with
69 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
47 changes: 23 additions & 24 deletions
47
src/components/InventoryGroupDetail/GroupDetailInfo.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
<GroupDetailInfo /> | ||
<GroupDetailInfo {...params}/> | ||
); | ||
|
||
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'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters