summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsoftwarefactory-project-zuul[bot] <33884098+softwarefactory-project-zuul[bot]@users.noreply.github.com>2020-11-30 15:09:28 +0100
committerGitHub <noreply@github.com>2020-11-30 15:09:28 +0100
commita45f586599f347d58fcf8791c9927d2161b9d19d (patch)
tree5823f1b74b52cb841368cb1449359f4a78b855e6
parentMerge pull request #8659 from mabashian/7989-group-action-buttons (diff)
parentRemove fullWidth prop from machine credential detail field as it's not needed (diff)
downloadawx-a45f586599f347d58fcf8791c9927d2161b9d19d.tar.xz
awx-a45f586599f347d58fcf8791c9927d2161b9d19d.zip
Merge pull request #8655 from mabashian/8606-adhoc-detail-cred
Display machine credential in job details when present Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
-rw-r--r--awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx15
-rw-r--r--awx/ui_next/src/screens/Job/JobDetail/JobDetail.test.jsx79
2 files changed, 64 insertions, 30 deletions
diff --git a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx
index 96c0794d35..4c1dedacee 100644
--- a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx
+++ b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.jsx
@@ -80,6 +80,7 @@ const getLaunchedByDetails = ({ summary_fields = {}, related = {} }) => {
function JobDetail({ job, i18n }) {
const {
+ credential,
credentials,
instance_group: instanceGroup,
inventory,
@@ -237,6 +238,20 @@ function JobDetail({ job, i18n }) {
value={`${job.job_slice_number}/${job.job_slice_count}`}
/>
)}
+ {credential && (
+ <Detail
+ label={i18n._(t`Machine Credential`)}
+ value={
+ <ChipGroup numChips={5} totalChips={1}>
+ <CredentialChip
+ key={credential.id}
+ credential={credential}
+ isReadOnly
+ />
+ </ChipGroup>
+ }
+ />
+ )}
{credentials && credentials.length > 0 && (
<Detail
fullWidth
diff --git a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.test.jsx b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.test.jsx
index 729d043686..4324e30924 100644
--- a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.test.jsx
+++ b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.test.jsx
@@ -10,17 +10,9 @@ jest.mock('../../../api');
describe('<JobDetail />', () => {
let wrapper;
- beforeEach(() => {
- wrapper = mountWithContexts(<JobDetail job={mockJobData} />);
- });
afterEach(() => {
wrapper.unmount();
});
- test('initially renders succesfully', () => {
- wrapper = mountWithContexts(<JobDetail job={mockJobData} />);
-
- expect(wrapper.length).toBe(1);
- });
test('should display details', () => {
function assertDetail(label, value) {
@@ -28,6 +20,26 @@ describe('<JobDetail />', () => {
expect(wrapper.find(`Detail[label="${label}"] dd`).text()).toBe(value);
}
+ wrapper = mountWithContexts(
+ <JobDetail
+ job={{
+ ...mockJobData,
+ summary_fields: {
+ ...mockJobData.summary_fields,
+ credential: {
+ id: 2,
+ name: 'Machine cred',
+ description: '',
+ kind: 'ssh',
+ cloud: false,
+ kubernetes: false,
+ credential_type_id: 1,
+ },
+ },
+ }}
+ />
+ );
+
// StatusIcon adds visibly hidden accessibility text " successful "
assertDetail('Status', ' successful Successful');
assertDetail('Started', '8/8/2019, 7:24:18 PM');
@@ -51,29 +63,30 @@ describe('<JobDetail />', () => {
);
assertDetail('Job Slice', '0/1');
assertDetail('Credentials', 'SSH: Demo Credential');
- });
-
- test('should display credentials', () => {
- const credentialChip = wrapper.find('CredentialChip');
+ assertDetail('Machine Credential', 'SSH: Machine cred');
+ const credentialChip = wrapper.find(
+ `Detail[label="Credentials"] CredentialChip`
+ );
expect(credentialChip.prop('credential')).toEqual(
mockJobData.summary_fields.credentials[0]
);
- });
- test('should display successful job status icon', () => {
const statusDetail = wrapper.find('Detail[label="Status"]');
expect(statusDetail.find('StatusIcon SuccessfulTop')).toHaveLength(1);
expect(statusDetail.find('StatusIcon SuccessfulBottom')).toHaveLength(1);
- });
- test('should display successful project status icon', () => {
- const statusDetail = wrapper.find('Detail[label="Project"]');
- expect(statusDetail.find('StatusIcon SuccessfulTop')).toHaveLength(1);
- expect(statusDetail.find('StatusIcon SuccessfulBottom')).toHaveLength(1);
+ const projectStatusDetail = wrapper.find('Detail[label="Project"]');
+ expect(projectStatusDetail.find('StatusIcon SuccessfulTop')).toHaveLength(
+ 1
+ );
+ expect(
+ projectStatusDetail.find('StatusIcon SuccessfulBottom')
+ ).toHaveLength(1);
});
test('should properly delete job', async () => {
+ wrapper = mountWithContexts(<JobDetail job={mockJobData} />);
wrapper.find('button[aria-label="Delete"]').simulate('click');
await sleep(1);
wrapper.update();
@@ -96,6 +109,7 @@ describe('<JobDetail />', () => {
},
})
);
+ wrapper = mountWithContexts(<JobDetail job={mockJobData} />);
wrapper.find('button[aria-label="Delete"]').simulate('click');
const modal = wrapper.find('Modal');
expect(modal.length).toBe(1);
@@ -109,19 +123,24 @@ describe('<JobDetail />', () => {
});
test('DELETED is shown for required Job resources that have been deleted', () => {
- const newMockJobData = { ...mockJobData };
- newMockJobData.summary_fields.inventory = null;
- newMockJobData.summary_fields.project = null;
- const newWrapper = mountWithContexts(
- <JobDetail job={newMockJobData} />
- ).find('JobDetail');
+ wrapper = mountWithContexts(
+ <JobDetail
+ job={{
+ ...mockJobData,
+ summary_fields: {
+ ...mockJobData.summary_fields,
+ inventory: null,
+ project: null,
+ },
+ }}
+ />
+ );
+ const detail = wrapper.find('JobDetail');
async function assertMissingDetail(label) {
- expect(newWrapper.length).toBe(1);
+ expect(detail.length).toBe(1);
await sleep(0);
- expect(newWrapper.find(`Detail[label="${label}"] dt`).text()).toBe(label);
- expect(newWrapper.find(`Detail[label="${label}"] dd`).text()).toBe(
- 'DELETED'
- );
+ expect(detail.find(`Detail[label="${label}"] dt`).text()).toBe(label);
+ expect(detail.find(`Detail[label="${label}"] dd`).text()).toBe('DELETED');
}
assertMissingDetail('Project');
assertMissingDetail('Inventory');