From 09b3100cca493904e736d4cf202c6ee11e873a03 Mon Sep 17 00:00:00 2001 From: fantonangeli Date: Fri, 18 Oct 2024 19:02:53 +0200 Subject: [PATCH] Fixed Variables card rendering when the value is null --- .../WorkflowDetails/WorkflowDetails.tsx | 2 +- .../WorkflowDefinitionList.test.tsx | 2 +- .../tests/components/WorkflowDetails.test.tsx | 89 +++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 packages/runtime-tools-swf-enveloped-components/tests/components/WorkflowDetails.test.tsx 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(); + } + } + ); +});