diff --git a/ui/src/__tests__/components/header/DomainDetails.test.js b/ui/src/__tests__/components/header/DomainDetails.test.js index 5fea6139b46..64ef27272d0 100644 --- a/ui/src/__tests__/components/header/DomainDetails.test.js +++ b/ui/src/__tests__/components/header/DomainDetails.test.js @@ -123,6 +123,60 @@ describe('DomainDetails', () => { expect(screen.getByText(organization)).toBeInTheDocument(); }); + it('should hide cloud account details when showCloudAccountDetails is false', () => { + const domainMetadata = { + modified: '2020-02-12T21:44:37.792Z', + ypmId: 'test', + org: 'test', + auditEnabled: true, + account: 'aws-account-123', + gcpProject: 'gcp-project-456', + environment: 'qa', + }; + const domainData = buildDomainDataForState(domainMetadata); + const state = { + ...getStateWithDomainData(domainData), + domains: { + featureFlag: { + enabled: true, + showCloudAccountDetails: false, + }, + }, + }; + + renderWithRedux(, state); + + expect(screen.queryByText('AWS ACCOUNT ID')).toBeNull(); + expect(screen.queryByText('GCP PROJECT ID')).toBeNull(); + expect(screen.queryByText('Onboard to AWS')).toBeNull(); + }); + + it('should show cloud account details when showCloudAccountDetails is true', () => { + const domainMetadata = { + modified: '2020-02-12T21:44:37.792Z', + ypmId: 'test', + org: 'test', + auditEnabled: true, + account: 'aws-account-123', + environment: 'qa', + }; + const domainData = buildDomainDataForState(domainMetadata); + const state = { + ...getStateWithDomainData(domainData), + domains: { + featureFlag: { + enabled: true, + showCloudAccountDetails: true, + }, + }, + }; + + renderWithRedux(, state); + + expect(screen.getByText('AWS ACCOUNT ID')).toBeInTheDocument(); + expect(screen.getByText('GCP PROJECT ID')).toBeInTheDocument(); + }); + it('shows N/A when organization is empty and orgDomain is empty', () => { const organization = ''; const orgDomain = ''; diff --git a/ui/src/__tests__/redux/selectors/domains.test.js b/ui/src/__tests__/redux/selectors/domains.test.js index 1027f8e2014..d49bfbf01fb 100644 --- a/ui/src/__tests__/redux/selectors/domains.test.js +++ b/ui/src/__tests__/redux/selectors/domains.test.js @@ -24,6 +24,7 @@ import { selectShowInstances, selectShowProviders, selectShowMicrosegmentation, + selectShowCloudAccountDetails, selectUserLink, selectHeaderDetails, selectProductMasterLink, @@ -192,6 +193,30 @@ describe('test domains selectors', () => { expect(selectShowMicrosegmentation(state)).toEqual(false); }); }); + describe('test selectShowCloudAccountDetails selector', () => { + it('should return true by default', () => { + expect(selectShowCloudAccountDetails(stateWithDomainsData)).toEqual( + true + ); + }); + it('should return false when explicitly disabled', () => { + const state = { + domains: { + featureFlag: { + enabled: true, + showCloudAccountDetails: false, + }, + }, + }; + expect(selectShowCloudAccountDetails(state)).toEqual(false); + }); + it('should return true when not set in object', () => { + const state = { + domains: { featureFlag: { enabled: true } }, + }; + expect(selectShowCloudAccountDetails(state)).toEqual(true); + }); + }); describe('test selectUserLink selector', () => { it('should return user link', () => { const userLink = { diff --git a/ui/src/components/header/DomainDetails.js b/ui/src/components/header/DomainDetails.js index a3003f12033..bce901ecc0e 100644 --- a/ui/src/components/header/DomainDetails.js +++ b/ui/src/components/header/DomainDetails.js @@ -37,6 +37,7 @@ import { import { selectProductMasterLink, selectTimeZone, + selectShowCloudAccountDetails, } from '../../redux/selectors/domains'; import { makeRolesExpires } from '../../redux/actions/roles'; import { makePoliciesExpires } from '../../redux/actions/policies'; @@ -548,22 +549,26 @@ class DomainDetails extends React.Component { AUDIT ENABLED - - - {this.props.domainDetails.account - ? this.props.domainDetails.account - : 'N/A'} - - AWS ACCOUNT ID - - - - {this.props.domainDetails.gcpProject - ? this.props.domainDetails.gcpProject - : 'N/A'} - - GCP PROJECT ID - + {this.props.showCloudAccountDetails && ( + + + + {this.props.domainDetails.account + ? this.props.domainDetails.account + : 'N/A'} + + AWS ACCOUNT ID + + + + {this.props.domainDetails.gcpProject + ? this.props.domainDetails.gcpProject + : 'N/A'} + + GCP PROJECT ID + + + )} More Details - {showOnBoardToAWS && ( + {this.props.showCloudAccountDetails && showOnBoardToAWS ? (