diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.test.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.test.jsx index 830fe40c97..fb497bb0ee 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.test.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/Visualizer.test.jsx @@ -192,6 +192,30 @@ describe('Visualizer', () => { ).toHaveBeenCalledWith(8, 9); }); + test('Start Screen shown when no nodes are present', async () => { + WorkflowJobTemplatesAPI.readNodes.mockResolvedValue({ + data: { + count: 0, + results: [], + }, + }); + await act(async () => { + wrapper = mountWithContexts( + + + + ); + }); + wrapper.update(); + expect(wrapper.find('VisualizerStartScreen')).toHaveLength(1); + expect( + wrapper.find('ActionButton#visualizer-toggle-tools').props().isDisabled + ).toBe(true); + expect( + wrapper.find('ActionButton#visualizer-toggle-legend').props().isDisabled + ).toBe(true); + }); + test('Error shown to user when error thrown fetching workflow nodes', async () => { WorkflowJobTemplatesAPI.readNodes.mockRejectedValue(new Error()); await act(async () => { diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.jsx index 92dfd03d32..a62d38dd84 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateVisualizer/VisualizerToolbar.jsx @@ -39,6 +39,7 @@ const ActionButton = styled(Button)` color: white; } `; +ActionButton.displayName = 'ActionButton'; function VisualizerToolbar({ i18n, onClose, onSave, template }) { const dispatch = useContext(WorkflowDispatchContext); @@ -62,7 +63,8 @@ function VisualizerToolbar({ i18n, onClose, onSave, template }) { 0 && showLegend} + isDisabled={totalNodes === 0} onClick={() => dispatch({ type: 'TOGGLE_LEGEND' })} variant="plain" > @@ -72,7 +74,8 @@ function VisualizerToolbar({ i18n, onClose, onSave, template }) { 0 && showTools} + isDisabled={totalNodes === 0} onClick={() => dispatch({ type: 'TOGGLE_TOOLS' })} variant="plain" >