From 6391c8f4e0c86ea0851ee934291e56c8aba92001 Mon Sep 17 00:00:00 2001 From: Hai Nguyen <59686060+haihuynh-bluecat@users.noreply.github.com> Date: Wed, 22 May 2024 14:10:59 +0700 Subject: [PATCH] feat: rename parameter contains bam to a generic name (ENG-54964) (#34) Co-authored-by: Stephen Le --- ...M.test.js => HeaderAuthentication.test.js} | 18 ++++++------ .../__snapshots__/Header.test.js.snap | 4 +-- ...snap => HeaderAuthentication.test.js.snap} | 12 ++++---- jest.config.js | 2 +- src/header/Header.js | 4 +-- .../{HeaderBAM.js => HeaderAuthentication.js} | 28 ++++++++++--------- ...aderBAM.less => HeaderAuthentication.less} | 4 +-- src/header/index.js | 2 +- ...ies.js => HeaderAuthentication.stories.js} | 10 +++---- 9 files changed, 44 insertions(+), 40 deletions(-) rename __tests__/components/{HeaderBAM.test.js => HeaderAuthentication.test.js} (74%) rename __tests__/components/__snapshots__/{HeaderBAM.test.js.snap => HeaderAuthentication.test.js.snap} (89%) rename src/header/{HeaderBAM.js => HeaderAuthentication.js} (71%) rename src/header/{HeaderBAM.less => HeaderAuthentication.less} (97%) rename stories/{HeaderBAM.stories.js => HeaderAuthentication.stories.js} (87%) diff --git a/__tests__/components/HeaderBAM.test.js b/__tests__/components/HeaderAuthentication.test.js similarity index 74% rename from __tests__/components/HeaderBAM.test.js rename to __tests__/components/HeaderAuthentication.test.js index 5bc44ab..9931f19 100644 --- a/__tests__/components/HeaderBAM.test.js +++ b/__tests__/components/HeaderAuthentication.test.js @@ -21,16 +21,16 @@ SOFTWARE. */ import { shallow } from 'enzyme'; -import HeaderBAM from '../../src/header/HeaderBAM'; +import HeaderAuthentication from '../../src/header/HeaderAuthentication'; -jest.unmock('../../src/header/HeaderBAM'); +jest.unmock('../../src/header/HeaderAuthentication'); jest.mock('../../src/hooks/usePlatformData', () => jest.fn(() => { return { data: { user: { - bam_info: { + authentication_info: { alias: 'Bam1', url: '192.168.10.2', }, @@ -40,15 +40,17 @@ jest.mock('../../src/hooks/usePlatformData', () => }), ); -describe('HeaderBAM', () => { +describe('HeaderAuthentication', () => { describe('Rendering', () => { - it('Render HeaderBAM component with default props', () => { - const wrapper = shallow(); + it('Render HeaderAuthentication component with default props', () => { + const wrapper = shallow(); expect(wrapper.getElement()).toMatchSnapshot(); }); - it('Render HeaderBAM component with props', () => { - const wrapper = shallow(); + it('Render HeaderAuthentication component with props', () => { + const wrapper = shallow( + , + ); expect(wrapper.getElement()).toMatchSnapshot(); }); }); diff --git a/__tests__/components/__snapshots__/Header.test.js.snap b/__tests__/components/__snapshots__/Header.test.js.snap index e7fd094..4c30166 100644 --- a/__tests__/components/__snapshots__/Header.test.js.snap +++ b/__tests__/components/__snapshots__/Header.test.js.snap @@ -19,7 +19,7 @@ exports[`Header Rendering Render Header component with default props 1`] = `
- + @@ -49,7 +49,7 @@ exports[`Header Rendering Render Header component with props 1`] = `
- + diff --git a/__tests__/components/__snapshots__/HeaderBAM.test.js.snap b/__tests__/components/__snapshots__/HeaderAuthentication.test.js.snap similarity index 89% rename from __tests__/components/__snapshots__/HeaderBAM.test.js.snap rename to __tests__/components/__snapshots__/HeaderAuthentication.test.js.snap index 578e8db..90010a0 100644 --- a/__tests__/components/__snapshots__/HeaderBAM.test.js.snap +++ b/__tests__/components/__snapshots__/HeaderAuthentication.test.js.snap @@ -1,12 +1,12 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`HeaderBAM Rendering Render HeaderBAM component with default props 1`] = ` +exports[`HeaderAuthentication Rendering Render HeaderAuthentication component with default props 1`] = `
- BAM   +   `; -exports[`HeaderBAM Rendering Render HeaderBAM component with props 1`] = ` +exports[`HeaderAuthentication Rendering Render HeaderAuthentication component with props 1`] = `
- BAM   +   {
- + diff --git a/src/header/HeaderBAM.js b/src/header/HeaderAuthentication.js similarity index 71% rename from src/header/HeaderBAM.js rename to src/header/HeaderAuthentication.js index 9a83139..6141803 100644 --- a/src/header/HeaderBAM.js +++ b/src/header/HeaderAuthentication.js @@ -23,35 +23,37 @@ import PropTypes from 'prop-types'; import usePlatformData from '../hooks/usePlatformData'; import { SvgIcon } from '@bluecateng/pelagos'; import { faLink } from '@fortawesome/free-solid-svg-icons'; -import './HeaderBAM.less'; +import './HeaderAuthentication.less'; /** - * HeaderBAM component displays the connected BAM alias and URL.
+ * HeaderAuthentication component displays the connected Authentication + * service alias and URL.
* This component is intended to be nested inside the PlatformDataContext * as it will require access to PlatformData. */ -const HeaderBAM = ({ className }) => { +const HeaderAuthentication = ({ className }) => { const { data } = usePlatformData(); - const bamAlias = data?.user?.bam_info?.alias; - const bamLink = data?.user?.bam_info?.url; + const authenticationAlias = data?.user?.authentication_info?.alias; + const authenticationLink = data?.user?.authentication_info?.url; + const authenticationService = data?.user?.authentication_info?.service; return ( <> - {bamAlias ? ( + {authenticationAlias ? ( @@ -60,9 +62,9 @@ const HeaderBAM = ({ className }) => { ); }; -HeaderBAM.propTypes = { +HeaderAuthentication.propTypes = { /** The component class name(s). */ className: PropTypes.string, }; -export default HeaderBAM; +export default HeaderAuthentication; diff --git a/src/header/HeaderBAM.less b/src/header/HeaderAuthentication.less similarity index 97% rename from src/header/HeaderBAM.less rename to src/header/HeaderAuthentication.less index a0dd685..af3bcb3 100644 --- a/src/header/HeaderBAM.less +++ b/src/header/HeaderAuthentication.less @@ -19,8 +19,8 @@ // SOFTWARE. @import '~@bluecateng/pelagos/less/spacing'; -.HeaderBAM { - &__bam { +.HeaderAuthentication { + &__authentication { & span { color: var(--text-secondary); display: flex; diff --git a/src/header/index.js b/src/header/index.js index 51f2a9d..ec61c91 100644 --- a/src/header/index.js +++ b/src/header/index.js @@ -21,7 +21,7 @@ SOFTWARE. */ export { default as Header } from './Header'; export { default as HeaderAccountMenu } from './HeaderAccountMenu'; -export { default as HeaderBAM } from './HeaderBAM'; +export { default as HeaderAuthentication } from './HeaderAuthentication'; export { default as HeaderHelpMenu } from './HeaderHelpMenu'; export { default as HeaderHomeNav } from './HeaderHomeNav'; export { default as HeaderLogo } from './HeaderLogo'; diff --git a/stories/HeaderBAM.stories.js b/stories/HeaderAuthentication.stories.js similarity index 87% rename from stories/HeaderBAM.stories.js rename to stories/HeaderAuthentication.stories.js index 37684cb..9b036af 100644 --- a/stories/HeaderBAM.stories.js +++ b/stories/HeaderAuthentication.stories.js @@ -19,14 +19,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import HeaderBAM from '../src/header/HeaderBAM'; +import HeaderAuthentication from '../src/header/HeaderAuthentication'; import PlatformDataContext from '../src/components/PlatformDataContext'; const mockValue = { data: { user: { // eslint-disable-next-line camelcase - bam_info: { + authentication_info: { alias: 'BAM-9.5.0', url: '#', }, @@ -35,8 +35,8 @@ const mockValue = { }; export default { - title: 'Components/HeaderBAM', - component: HeaderBAM, + title: 'Components/HeaderAuthentication', + component: HeaderAuthentication, decorators: [ (Story) => ( @@ -48,6 +48,6 @@ export default { export const Normal = { args: { - className: 'TestHeaderBAM', + className: 'TestHeaderAuthentication', }, };