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 939616ff3f..879722bde9 100644 --- a/awx/ui_next/src/screens/Job/JobDetail/JobDetail.test.jsx +++ b/awx/ui_next/src/screens/Job/JobDetail/JobDetail.test.jsx @@ -4,64 +4,74 @@ import { mountWithContexts } from '@testUtils/enzymeHelpers'; import { sleep } from '@testUtils/testUtils'; import JobDetail from './JobDetail'; import { JobsAPI, ProjectUpdatesAPI } from '@api'; +import mockJobData from '../shared/data.job.json'; jest.mock('@api'); describe('', () => { - let job; - - beforeEach(() => { - job = { - name: 'Foo', - summary_fields: {}, - }; - }); - test('initially renders succesfully', () => { - mountWithContexts(); + mountWithContexts(); }); test('should display a Close button', () => { - const wrapper = mountWithContexts(); + const wrapper = mountWithContexts(); expect(wrapper.find('Button[aria-label="close"]').length).toBe(1); wrapper.unmount(); }); test('should display details', () => { - job.status = 'Successful'; - job.started = '2019-07-02T17:35:22.753817Z'; - job.finished = '2019-07-02T17:35:34.910800Z'; + const wrapper = mountWithContexts(); - const wrapper = mountWithContexts(); - const details = wrapper.find('Detail'); - - function assertDetail(detail, label, value) { - expect(detail.prop('label')).toEqual(label); - expect(detail.prop('value')).toEqual(value); + function assertDetail(label, value) { + expect(wrapper.find(`Detail[label="${label}"] dt`).text()).toBe(label); + expect(wrapper.find(`Detail[label="${label}"] dd`).text()).toBe(value); } - assertDetail(details.at(0), 'Status', 'Successful'); - assertDetail(details.at(1), 'Started', job.started); - assertDetail(details.at(2), 'Finished', job.finished); + assertDetail('Status', 'Successful'); + assertDetail('Started', mockJobData.started); + assertDetail('Finished', mockJobData.finished); + assertDetail('Template', mockJobData.summary_fields.job_template.name); + assertDetail('Job Type', 'Run'); + assertDetail('Launched By', mockJobData.summary_fields.created_by.username); + assertDetail('Inventory', mockJobData.summary_fields.inventory.name); + assertDetail('Project', mockJobData.summary_fields.project.name); + assertDetail('Revision', mockJobData.scm_revision); + assertDetail('Playbook', mockJobData.playbook); + assertDetail('Verbosity', '0 (Normal)'); + assertDetail('Environment', mockJobData.custom_virtualenv); + assertDetail('Execution Node', mockJobData.execution_node); + assertDetail( + 'Instance Group', + mockJobData.summary_fields.instance_group.name + ); + assertDetail('Job Slice', '0/1'); + assertDetail('Credentials', 'SSH: Demo Credential'); }); test('should display credentials', () => { - job.summary_fields.credentials = [ - { - id: 1, - name: 'Foo', - cloud: false, - kind: 'ssh', - }, - ]; - const wrapper = mountWithContexts(); + const wrapper = mountWithContexts(); const credentialChip = wrapper.find('CredentialChip'); expect(credentialChip.prop('credential')).toEqual( - job.summary_fields.credentials[0] + mockJobData.summary_fields.credentials[0] ); }); + + test('should display successful job status icon', () => { + const wrapper = mountWithContexts(); + 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 wrapper = mountWithContexts(); + const statusDetail = wrapper.find('Detail[label="Project"]'); + expect(statusDetail.find('StatusIcon__SuccessfulTop')).toHaveLength(1); + expect(statusDetail.find('StatusIcon__SuccessfulBottom')).toHaveLength(1); + }); + test('should properly delete job', async () => { job = { name: 'Rage', diff --git a/awx/ui_next/src/screens/Job/JobOutput/JobOutput.test.jsx b/awx/ui_next/src/screens/Job/JobOutput/JobOutput.test.jsx index 7762efdb76..987a1ab88f 100644 --- a/awx/ui_next/src/screens/Job/JobOutput/JobOutput.test.jsx +++ b/awx/ui_next/src/screens/Job/JobOutput/JobOutput.test.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { mountWithContexts, waitForElement } from '@testUtils/enzymeHelpers'; import JobOutput from './JobOutput'; import { JobsAPI } from '@api'; -import mockJobData from './data.job.json'; +import mockJobData from '../shared/data.job.json'; import mockJobEventsData from './data.job_events.json'; jest.mock('@api'); diff --git a/awx/ui_next/src/screens/Job/JobOutput/data.job.json b/awx/ui_next/src/screens/Job/shared/data.job.json similarity index 100% rename from awx/ui_next/src/screens/Job/JobOutput/data.job.json rename to awx/ui_next/src/screens/Job/shared/data.job.json diff --git a/awx/ui_next/src/screens/Organization/OrganizationAccess/__snapshots__/OrganizationAccessItem.test.jsx.snap b/awx/ui_next/src/screens/Organization/OrganizationAccess/__snapshots__/OrganizationAccessItem.test.jsx.snap index 8e8c16a6dd..043a609933 100644 --- a/awx/ui_next/src/screens/Organization/OrganizationAccess/__snapshots__/OrganizationAccessItem.test.jsx.snap +++ b/awx/ui_next/src/screens/Organization/OrganizationAccess/__snapshots__/OrganizationAccessItem.test.jsx.snap @@ -321,9 +321,9 @@ exports[` initially renders succesfully 1`] = ` "componentStyle": ComponentStyle { "componentId": "DetailList-sc-12g7m4-0", "isStatic": false, - "lastClassName": "gmERnX", + "lastClassName": "eYaZBv", "rules": Array [ - "display:grid;grid-gap:20px;align-items:baseline;", + "display:grid;grid-gap:20px;align-items:flex-start;", [Function], ], }, @@ -341,15 +341,15 @@ exports[` initially renders succesfully 1`] = ` stacked={true} >
initially renders succesfully 1`] = ` "componentStyle": ComponentStyle { "componentId": "DetailList-sc-12g7m4-0", "isStatic": false, - "lastClassName": "gmERnX", + "lastClassName": "eYaZBv", "rules": Array [ - "display:grid;grid-gap:20px;align-items:baseline;", + "display:grid;grid-gap:20px;align-items:flex-start;", [Function], ], }, @@ -504,15 +504,15 @@ exports[` initially renders succesfully 1`] = ` stacked={true} >