diff --git a/awx/ui/src/screens/Credential/Credential.js b/awx/ui/src/screens/Credential/Credential.js index ce0509146dd0..79c766a2d86a 100644 --- a/awx/ui/src/screens/Credential/Credential.js +++ b/awx/ui/src/screens/Credential/Credential.js @@ -22,14 +22,19 @@ import { CredentialsAPI } from 'api'; import CredentialDetail from './CredentialDetail'; import CredentialEdit from './CredentialEdit'; -const jobTemplateCredentialTypes = [ - 'machine', - 'cloud', - 'net', - 'ssh', - 'vault', - 'kubernetes', - 'cryptography', +const unacceptableCredentialTypes = [ + 'centrify_vault_kv', + 'aim', + 'conjur', + 'hashivault_kv', + 'hashivault_ssh', + 'azure_kv', + 'thycotic_dsv', + 'thycotic_tss', + 'galaxy_api_token', + 'insights', + 'registry', + 'scm', ]; function Credential({ setBreadcrumb }) { @@ -86,7 +91,10 @@ function Credential({ setBreadcrumb }) { id: 1, }, ]; - if (jobTemplateCredentialTypes.includes(credential?.kind)) { + if ( + !unacceptableCredentialTypes.includes(credential?.kind) && + credential !== null + ) { tabsArray.push({ name: t`Job Templates`, link: `/credentials/${id}/job_templates`, @@ -115,12 +123,14 @@ function Credential({ setBreadcrumb }) { ); } + if (hasContentLoading) { + return ; + } return ( {showCardHeader && } - {hasContentLoading && } {!hasContentLoading && credential && ( ({ describe('', () => { let wrapper; + afterEach(() => { + jest.clearAllMocks(); + + wrapper.unmount(); + }); test('initially renders user-based machine credential successfully', async () => { CredentialsAPI.readDetail.mockResolvedValueOnce({ @@ -61,6 +67,19 @@ describe('', () => { }); }); + test('should not render job template tab', async () => { + CredentialsAPI.readDetail.mockResolvedValueOnce({ + data: { ...mockCyberArkCredential, kind: 'registry' }, + }); + const expectedTabs = ['Back to Credentials', 'Details', 'Access']; + await act(async () => { + wrapper = mountWithContexts( {}} />); + }); + wrapper.find('RoutedTabs li').forEach((tab, index) => { + expect(tab.text()).toEqual(expectedTabs[index]); + }); + }); + test('should show content error when user attempts to navigate to erroneous route', async () => { const history = createMemoryHistory({ initialEntries: ['/credentials/2/foobar'], @@ -85,3 +104,4 @@ describe('', () => { await waitForElement(wrapper, 'ContentError', (el) => el.length === 1); }); }); +describe(' should not show job template tab', () => {});