From 4c0abf9bcd54f7322c6e62641e9f1dec4a798ddc Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 15 Dec 2022 14:45:35 -0500 Subject: [PATCH 1/2] Fixes a bug that was causing tests to be added to the incorrect task. Clean up UI for a better experience when viewing tests. --- .../routes/process_api_blueprint.py | 2 +- .../src/routes/ProcessModelEditDiagram.tsx | 155 ++++++++++++------ 2 files changed, 102 insertions(+), 55 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index ba2f65c29..cf41767bd 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -1702,7 +1702,7 @@ def script_unit_test_create( extension_elements = None extension_elements_array = script_task_element.xpath( - "//bpmn:extensionElements", + ".//bpmn:extensionElements", namespaces={"bpmn": "http://www.omg.org/spec/BPMN/20100524/MODEL"}, ) if len(extension_elements_array) == 0: diff --git a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx index 1a5c751f7..4ef758480 100644 --- a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx @@ -6,11 +6,11 @@ import { useSearchParams, } from 'react-router-dom'; // @ts-ignore -import { Button, Modal, Stack, Content } from '@carbon/react'; +import { Button, Modal, Content, Tabs, TabList, Tab, TabPanels, TabPanel } from '@carbon/react'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; -import Editor from '@monaco-editor/react'; +import Editor, { DiffEditor } from '@monaco-editor/react'; import MDEditor from '@uiw/react-md-editor'; import ReactDiagramEditor from '../components/ReactDiagramEditor'; @@ -397,6 +397,13 @@ export default function ProcessModelEditDiagram() { }; }; + const jsonEditorOptions = () => { + return Object.assign(generalEditorOptions(), { + minimap: { enabled: false }, + folding: true + }); + } + const setPreviousScriptUnitTest = () => { resetUnitTextResult(); const newScriptIndex = currentScriptUnitTestIndex - 1; @@ -491,11 +498,32 @@ export default function ProcessModelEditDiagram() { } let errorContextElement = null; if (scriptUnitTestResult.context) { + errorStringElement = ( + Unexpected result. Please see the comparison below. + ); + let outputJson = '{}'; + if (currentScriptUnitTest) { + outputJson = JSON.stringify( + JSON.parse(currentScriptUnitTest.expectedOutputJson.value), + null, + ' ' + ); + } + const contextJson = JSON.stringify( + scriptUnitTestResult.context, + null, + ' ' + ); errorContextElement = ( - - Received unexpected output:{' '} - {JSON.stringify(scriptUnitTestResult.context)} - + ); } return ( @@ -539,19 +567,29 @@ export default function ProcessModelEditDiagram() { ); } + const inputJson = JSON.stringify( + JSON.parse(currentScriptUnitTest.inputJson.value), + null, + ' ' + ); + const outputJson = JSON.stringify( + JSON.parse(currentScriptUnitTest.expectedOutputJson.value), + null, + ' ' + ); + return (
-
); } return null; }; - const scriptEditor = () => { + return ( + + ); + }; + const scriptEditorAndTests = () => { let scriptName = ''; if (scriptElement) { scriptName = (scriptElement as any).di.bpmnElement.name; } - return ( - - {scriptUnitTestEditorElement()} + + + Script Editor + Unit Tests + + + {scriptEditor()} + {scriptUnitTestEditorElement()} + + ); }; @@ -858,7 +905,7 @@ export default function ProcessModelEditDiagram() { {appropriateEditor()} {newFileNameBox()} - {scriptEditor()} + {scriptEditorAndTests()} {markdownEditor()} {processModelSelector()}
From 22420d0efbd1d5c80fdffa1a6fa6edc9083bd109 Mon Sep 17 00:00:00 2001 From: jasquat Date: Fri, 16 Dec 2022 13:17:38 -0500 Subject: [PATCH 2/2] merged in main and pyl passes --- .../src/routes/ProcessModelEditDiagram.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx index 4ef758480..544312c86 100644 --- a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx @@ -6,7 +6,16 @@ import { useSearchParams, } from 'react-router-dom'; // @ts-ignore -import { Button, Modal, Content, Tabs, TabList, Tab, TabPanels, TabPanel } from '@carbon/react'; +import { + Button, + Modal, + Content, + Tabs, + TabList, + Tab, + TabPanels, + TabPanel, +} from '@carbon/react'; import Row from 'react-bootstrap/Row'; import Col from 'react-bootstrap/Col'; @@ -399,10 +408,10 @@ export default function ProcessModelEditDiagram() { const jsonEditorOptions = () => { return Object.assign(generalEditorOptions(), { - minimap: { enabled: false }, - folding: true + minimap: { enabled: false }, + folding: true, }); - } + }; const setPreviousScriptUnitTest = () => { resetUnitTextResult();