diff --git a/awx/ui_next/src/components/Workflow/WorkflowActionTooltip.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowActionTooltip.test.jsx new file mode 100644 index 0000000000..aa3c6ba4e4 --- /dev/null +++ b/awx/ui_next/src/components/Workflow/WorkflowActionTooltip.test.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import WorkflowActionTooltip from './WorkflowActionTooltip'; + +describe('WorkflowActionTooltip', () => { + test('successfully mounts', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + }); +}); diff --git a/awx/ui_next/src/components/Workflow/WorkflowActionTooltipItem.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowActionTooltipItem.test.jsx new file mode 100644 index 0000000000..ed6067a3c0 --- /dev/null +++ b/awx/ui_next/src/components/Workflow/WorkflowActionTooltipItem.test.jsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import WorkflowActionTooltipItem from './WorkflowActionTooltipItem'; + +describe('WorkflowActionTooltipItem', () => { + test('successfully mounts', () => { + const wrapper = mount(); + expect(wrapper).toHaveLength(1); + }); +}); diff --git a/awx/ui_next/src/components/Workflow/WorkflowHelp.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowHelp.test.jsx new file mode 100644 index 0000000000..1102709889 --- /dev/null +++ b/awx/ui_next/src/components/Workflow/WorkflowHelp.test.jsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import WorkflowHelp from './WorkflowHelp'; + +describe('WorkflowHelp', () => { + test('successfully mounts', () => { + const wrapper = mount(); + expect(wrapper).toHaveLength(1); + }); +}); diff --git a/awx/ui_next/src/components/Workflow/WorkflowKey.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowKey.test.jsx new file mode 100644 index 0000000000..6fac4c4ef8 --- /dev/null +++ b/awx/ui_next/src/components/Workflow/WorkflowKey.test.jsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { mountWithContexts } from '@testUtils/enzymeHelpers'; +import WorkflowKey from './WorkflowKey'; + +describe('WorkflowKey', () => { + test('renders the expected content', () => { + const wrapper = mountWithContexts(); + expect(wrapper).toHaveLength(1); + }); +}); diff --git a/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.jsx b/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.jsx index 4252351798..5180ab3bba 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.jsx @@ -38,7 +38,7 @@ function WorkflowLinkHelp({ link, i18n }) {
{i18n._(t`Run`)}
-
{linkType}
+ ); } diff --git a/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.test.jsx new file mode 100644 index 0000000000..8bf8779243 --- /dev/null +++ b/awx/ui_next/src/components/Workflow/WorkflowLinkHelp.test.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { mountWithContexts } from '@testUtils/enzymeHelpers'; +import WorkflowLinkHelp from './WorkflowLinkHelp'; + +describe('WorkflowLinkHelp', () => { + test('successfully mounts', () => { + const wrapper = mountWithContexts(); + expect(wrapper).toHaveLength(1); + }); + test('renders the expected content for an on success link', () => { + const link = { + linkType: 'success', + }; + const wrapper = mountWithContexts(); + expect(wrapper.find('#workflow-link-help-type').text()).toBe('On Success'); + }); + test('renders the expected content for an on failure link', () => { + const link = { + linkType: 'failure', + }; + const wrapper = mountWithContexts(); + expect(wrapper.find('#workflow-link-help-type').text()).toBe('On Failure'); + }); + test('renders the expected content for an always link', () => { + const link = { + linkType: 'always', + }; + const wrapper = mountWithContexts(); + expect(wrapper.find('#workflow-link-help-type').text()).toBe('Always'); + }); +}); diff --git a/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.jsx b/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.jsx index 07d56c623b..ce25921463 100644 --- a/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.jsx +++ b/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.jsx @@ -104,11 +104,11 @@ function WorkflowNodeHelp({ node, i18n }) {
{i18n._(t`Name`)}
-
{node.unifiedJobTemplate.name}
+
{node.unifiedJobTemplate.name}
{i18n._(t`Type`)}
-
{nodeType}
+
{nodeType}
)} {node.job && ( @@ -116,13 +116,15 @@ function WorkflowNodeHelp({ node, i18n }) {
{i18n._(t`Job Status`)}
-
{jobStatus}
+
{jobStatus}
{node.job.elapsed && (
{i18n._(t`Elapsed`)}
-
{secondsToHHMMSS(node.job.elapsed)}
+
+ {secondsToHHMMSS(node.job.elapsed)} +
)} diff --git a/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.test.jsx new file mode 100644 index 0000000000..01e771a140 --- /dev/null +++ b/awx/ui_next/src/components/Workflow/WorkflowNodeHelp.test.jsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { mountWithContexts } from '@testUtils/enzymeHelpers'; +import WorkflowNodeHelp from './WorkflowNodeHelp'; + +describe('WorkflowNodeHelp', () => { + test('successfully mounts', () => { + const wrapper = mountWithContexts(); + expect(wrapper).toHaveLength(1); + }); + test('renders the expected content for a completed job template job', () => { + const node = { + job: { + elapsed: 9000, + status: 'successful', + }, + unifiedJobTemplate: { + name: 'Foo Job Template', + unified_job_type: 'job', + }, + }; + const wrapper = mountWithContexts(); + expect(wrapper.find('#workflow-node-help-name').text()).toBe( + 'Foo Job Template' + ); + expect(wrapper.find('#workflow-node-help-type').text()).toBe( + 'Job Template' + ); + expect(wrapper.find('#workflow-node-help-status').text()).toBe( + 'Successful' + ); + expect(wrapper.find('#workflow-node-help-elapsed').text()).toBe('02:30:00'); + }); +}); diff --git a/awx/ui_next/src/components/Workflow/WorkflowNodeTypeLetter.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowNodeTypeLetter.test.jsx new file mode 100644 index 0000000000..24313f1f54 --- /dev/null +++ b/awx/ui_next/src/components/Workflow/WorkflowNodeTypeLetter.test.jsx @@ -0,0 +1,121 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import { PauseIcon } from '@patternfly/react-icons'; +import WorkflowNodeTypeLetter from './WorkflowNodeTypeLetter'; + +describe('WorkflowNodeTypeLetter', () => { + test('renders JT when type=job_template', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.text()).toBe('JT'); + }); + test('renders JT when unified_job_type=job', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.text()).toBe('JT'); + }); + test('renders P when type=project', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.text()).toBe('P'); + }); + test('renders P when unified_job_type=project_update', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.text()).toBe('P'); + }); + test('renders I when type=inventory_source', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.text()).toBe('I'); + }); + test('renders I when unified_job_type=inventory_update', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.text()).toBe('I'); + }); + test('renders W when type=workflow_job_template', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.text()).toBe('W'); + }); + test('renders W when unified_job_type=workflow_job', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.text()).toBe('W'); + }); + test('renders puse icon when type=workflow_approval_template', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.containsMatchingElement()); + }); + test('renders W when unified_job_type=workflow_approval', () => { + const wrapper = mount( + + + + ); + expect(wrapper).toHaveLength(1); + expect(wrapper.containsMatchingElement()); + }); +}); diff --git a/awx/ui_next/src/components/Workflow/WorkflowTools.test.jsx b/awx/ui_next/src/components/Workflow/WorkflowTools.test.jsx new file mode 100644 index 0000000000..42fb97b259 --- /dev/null +++ b/awx/ui_next/src/components/Workflow/WorkflowTools.test.jsx @@ -0,0 +1,54 @@ +import React from 'react'; +import { mountWithContexts } from '@testUtils/enzymeHelpers'; +import WorkflowTools from './WorkflowTools'; + +describe('WorkflowTools', () => { + test('renders the expected content', () => { + const wrapper = mountWithContexts( + {}} + onPan={() => {}} + onPanToMiddle={() => {}} + onZoomChange={() => {}} + zoomPercentage={100} + /> + ); + expect(wrapper).toHaveLength(1); + }); + test('clicking zoom buttons passes callback correctly updated scale', () => { + const zoomChange = jest.fn(); + const wrapper = mountWithContexts( + {}} + onPan={() => {}} + onPanToMiddle={() => {}} + onZoomChange={zoomChange} + zoomPercentage={95.7} + /> + ); + wrapper.find('PlusIcon').simulate('click'); + expect(zoomChange).toHaveBeenCalledWith(1.1); + wrapper.find('MinusIcon').simulate('click'); + expect(zoomChange).toHaveBeenCalledWith(0.8); + }); + test('clicking pan buttons passes callback correct string direction', () => { + const pan = jest.fn(); + const wrapper = mountWithContexts( + {}} + onPan={pan} + onPanToMiddle={() => {}} + onZoomChange={() => {}} + zoomPercentage={100} + /> + ); + wrapper.find('CaretLeftIcon').simulate('click'); + expect(pan).toHaveBeenCalledWith('left'); + wrapper.find('CaretUpIcon').simulate('click'); + expect(pan).toHaveBeenCalledWith('up'); + wrapper.find('CaretRightIcon').simulate('click'); + expect(pan).toHaveBeenCalledWith('right'); + wrapper.find('CaretDownIcon').simulate('click'); + expect(pan).toHaveBeenCalledWith('down'); + }); +});