diff --git a/packages/runtime-tools-swf-enveloped-components/src/workflowDetails/envelope/components/WorkflowDetails/WorkflowDetails.tsx b/packages/runtime-tools-swf-enveloped-components/src/workflowDetails/envelope/components/WorkflowDetails/WorkflowDetails.tsx index be5db3021d4..5f2ea170b45 100644 --- a/packages/runtime-tools-swf-enveloped-components/src/workflowDetails/envelope/components/WorkflowDetails/WorkflowDetails.tsx +++ b/packages/runtime-tools-swf-enveloped-components/src/workflowDetails/envelope/components/WorkflowDetails/WorkflowDetails.tsx @@ -252,7 +252,7 @@ const WorkflowDetails: React.FC = ({ isEnvelopeConnectedTo const renderWorkflowVariables = (): JSX.Element => { return ( - {Object.keys(updateJson).length > 0 && ( + {updateJson && Object.keys(updateJson).length > 0 && ( { + beforeEach(() => { + jest.clearAllMocks(); + }); + + test("should render the workflow details correctly", () => { + const component = render( + + ); + + expect(component.queryByText("6d114")).toBeInTheDocument(); + }); + + test.each([ + [undefined, false], + [null, false], + [{}, false], + [{ workflowdata: {} }, true], + [sampleWorkflowDetails.variables, true], + ])( + "should render the workflow Variables card correctly when variables is `%j`", + (variablesMock, variablesCardVisible) => { + const workflowDetailsMock = { ...sampleWorkflowDetails, variables: variablesMock }; + const component = render( + + ); + + if (variablesCardVisible) { + expect(component.queryByText("Variables")).toBeInTheDocument(); + expect(component.queryByText("workflowdata")).toBeInTheDocument(); + } else { + expect(component.queryByText("Variables")).not.toBeInTheDocument(); + } + } + ); +});