From fa0658be8229724ccc56acc0e64594d323c79cb1 Mon Sep 17 00:00:00 2001 From: Fabrizio Antonangeli Date: Thu, 24 Oct 2024 14:46:39 +0200 Subject: [PATCH] kie-issues#2654: [SonataFlow] Empty WF Instance page if variables is null (#2683) --- .../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(); + } + } + ); +});