From c3710aeb2ac85bfd87b99e693dd599a42cf46a5a Mon Sep 17 00:00:00 2001 From: jasquat Date: Tue, 23 May 2023 15:15:30 -0400 Subject: [PATCH] allow running all process model unit tests from the show page w/ burnettk --- .../src/components/ProcessModelTestRun.tsx | 56 ++++++++++++++----- .../src/routes/ProcessModelShow.tsx | 19 ++++++- 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/spiffworkflow-frontend/src/components/ProcessModelTestRun.tsx b/spiffworkflow-frontend/src/components/ProcessModelTestRun.tsx index fe82167e3..9938431a0 100644 --- a/spiffworkflow-frontend/src/components/ProcessModelTestRun.tsx +++ b/spiffworkflow-frontend/src/components/ProcessModelTestRun.tsx @@ -10,10 +10,14 @@ import { } from './ErrorDisplay'; type OwnProps = { - processModelFile: ProcessFile; + processModelFile?: ProcessFile; + buttonType?: string; }; -export default function ProcessModelTestRun({ processModelFile }: OwnProps) { +export default function ProcessModelTestRun({ + processModelFile, + buttonType = 'icon', +}: OwnProps) { const [testCaseResults, setTestCaseResults] = useState(null); const [showTestCaseResultsModal, setShowTestCaseResultsModal] = @@ -32,7 +36,7 @@ export default function ProcessModelTestRun({ processModelFile }: OwnProps) { kind="ghost" className="green-icon" renderIcon={Checkmark} - iconDescription="PASS" + iconDescription="All BPMN unit tests passed" hasIconOnly size="lg" onClick={() => setShowTestCaseResultsModal(true)} @@ -44,7 +48,7 @@ export default function ProcessModelTestRun({ processModelFile }: OwnProps) { kind="ghost" className="red-icon" renderIcon={Close} - iconDescription="FAILS" + iconDescription="BPMN unit tests failed" hasIconOnly size="lg" onClick={() => setShowTestCaseResultsModal(true)} @@ -54,12 +58,17 @@ export default function ProcessModelTestRun({ processModelFile }: OwnProps) { return null; }; - const onProcessModelTestRun = (fileName: string) => { + const onProcessModelTestRun = () => { const httpMethod = 'POST'; setTestCaseResults(null); + let queryParams = ''; + if (processModelFile) { + queryParams = `?test_case_file=${processModelFile.name}`; + } + HttpService.makeCallToBackend({ - path: `${targetUris.processModelTestsPath}?test_case_file=${fileName}`, + path: `${targetUris.processModelTestsPath}${queryParams}`, successCallback: onProcessModelTestRunSuccess, httpMethod, }); @@ -143,17 +152,36 @@ export default function ProcessModelTestRun({ processModelFile }: OwnProps) { ); }; + const buttonElement = () => { + if (buttonType === 'icon') { + return ( + + ); + } + return null; + }; + return ( <> {testCaseResultsModal()} - + + {hasTestCaseFiles ? ( + + ) : null} + {processModelFilesSection()}