allow running all process model unit tests from the show page w/ burnettk
This commit is contained in:
parent
e2fe5ea660
commit
16e0952686
|
@ -10,10 +10,14 @@ import {
|
||||||
} from './ErrorDisplay';
|
} from './ErrorDisplay';
|
||||||
|
|
||||||
type OwnProps = {
|
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] =
|
const [testCaseResults, setTestCaseResults] =
|
||||||
useState<TestCaseResults | null>(null);
|
useState<TestCaseResults | null>(null);
|
||||||
const [showTestCaseResultsModal, setShowTestCaseResultsModal] =
|
const [showTestCaseResultsModal, setShowTestCaseResultsModal] =
|
||||||
|
@ -32,7 +36,7 @@ export default function ProcessModelTestRun({ processModelFile }: OwnProps) {
|
||||||
kind="ghost"
|
kind="ghost"
|
||||||
className="green-icon"
|
className="green-icon"
|
||||||
renderIcon={Checkmark}
|
renderIcon={Checkmark}
|
||||||
iconDescription="PASS"
|
iconDescription="All BPMN unit tests passed"
|
||||||
hasIconOnly
|
hasIconOnly
|
||||||
size="lg"
|
size="lg"
|
||||||
onClick={() => setShowTestCaseResultsModal(true)}
|
onClick={() => setShowTestCaseResultsModal(true)}
|
||||||
|
@ -44,7 +48,7 @@ export default function ProcessModelTestRun({ processModelFile }: OwnProps) {
|
||||||
kind="ghost"
|
kind="ghost"
|
||||||
className="red-icon"
|
className="red-icon"
|
||||||
renderIcon={Close}
|
renderIcon={Close}
|
||||||
iconDescription="FAILS"
|
iconDescription="BPMN unit tests failed"
|
||||||
hasIconOnly
|
hasIconOnly
|
||||||
size="lg"
|
size="lg"
|
||||||
onClick={() => setShowTestCaseResultsModal(true)}
|
onClick={() => setShowTestCaseResultsModal(true)}
|
||||||
|
@ -54,12 +58,17 @@ export default function ProcessModelTestRun({ processModelFile }: OwnProps) {
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onProcessModelTestRun = (fileName: string) => {
|
const onProcessModelTestRun = () => {
|
||||||
const httpMethod = 'POST';
|
const httpMethod = 'POST';
|
||||||
setTestCaseResults(null);
|
setTestCaseResults(null);
|
||||||
|
|
||||||
|
let queryParams = '';
|
||||||
|
if (processModelFile) {
|
||||||
|
queryParams = `?test_case_file=${processModelFile.name}`;
|
||||||
|
}
|
||||||
|
|
||||||
HttpService.makeCallToBackend({
|
HttpService.makeCallToBackend({
|
||||||
path: `${targetUris.processModelTestsPath}?test_case_file=${fileName}`,
|
path: `${targetUris.processModelTestsPath}${queryParams}`,
|
||||||
successCallback: onProcessModelTestRunSuccess,
|
successCallback: onProcessModelTestRunSuccess,
|
||||||
httpMethod,
|
httpMethod,
|
||||||
});
|
});
|
||||||
|
@ -143,17 +152,36 @@ export default function ProcessModelTestRun({ processModelFile }: OwnProps) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const buttonElement = () => {
|
||||||
|
if (buttonType === 'icon') {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
kind="ghost"
|
||||||
|
renderIcon={PlayOutline}
|
||||||
|
iconDescription="Run BPMN unit tests defined in this file"
|
||||||
|
hasIconOnly
|
||||||
|
size="lg"
|
||||||
|
onClick={() => onProcessModelTestRun()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (buttonType === 'text') {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
onClick={() => onProcessModelTestRun()}
|
||||||
|
title="Run all BPMN unit tests for this process model"
|
||||||
|
>
|
||||||
|
Run Unit Tests
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{testCaseResultsModal()}
|
{testCaseResultsModal()}
|
||||||
<Button
|
{buttonElement()}
|
||||||
kind="ghost"
|
|
||||||
renderIcon={PlayOutline}
|
|
||||||
iconDescription="Run Test"
|
|
||||||
hasIconOnly
|
|
||||||
size="lg"
|
|
||||||
onClick={() => onProcessModelTestRun(processModelFile.name)}
|
|
||||||
/>
|
|
||||||
{processModelTestRunResultTag()}
|
{processModelTestRunResultTag()}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -83,6 +83,18 @@ export default function ProcessModelShow() {
|
||||||
`${params.process_model_id}`
|
`${params.process_model_id}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let hasTestCaseFiles: boolean = false;
|
||||||
|
|
||||||
|
const isTestCaseFile = (processModelFile: ProcessFile) => {
|
||||||
|
return processModelFile.name.match(/^test_.*\.json$/);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (processModel) {
|
||||||
|
hasTestCaseFiles = !!processModel.files.find(
|
||||||
|
(processModelFile: ProcessFile) => isTestCaseFile(processModelFile)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const processResult = (result: ProcessModel) => {
|
const processResult = (result: ProcessModel) => {
|
||||||
setProcessModel(result);
|
setProcessModel(result);
|
||||||
|
@ -310,7 +322,7 @@ export default function ProcessModelShow() {
|
||||||
</Can>
|
</Can>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (processModelFile.name.match(/^test_.*\.json$/)) {
|
if (isTestCaseFile(processModelFile)) {
|
||||||
elements.push(
|
elements.push(
|
||||||
<Can I="POST" a={targetUris.processModelTestsPath} ability={ability}>
|
<Can I="POST" a={targetUris.processModelTestsPath} ability={ability}>
|
||||||
<ProcessModelTestRun processModelFile={processModelFile} />
|
<ProcessModelTestRun processModelFile={processModelFile} />
|
||||||
|
@ -656,6 +668,11 @@ export default function ProcessModelShow() {
|
||||||
Publish Changes
|
Publish Changes
|
||||||
</Button>
|
</Button>
|
||||||
</Can>
|
</Can>
|
||||||
|
<Can I="POST" a={targetUris.processModelTestsPath} ability={ability}>
|
||||||
|
{hasTestCaseFiles ? (
|
||||||
|
<ProcessModelTestRun buttonType="text" />
|
||||||
|
) : null}
|
||||||
|
</Can>
|
||||||
</Stack>
|
</Stack>
|
||||||
{processModelFilesSection()}
|
{processModelFilesSection()}
|
||||||
<Can I="GET" a={targetUris.processInstanceListPath} ability={ability}>
|
<Can I="GET" a={targetUris.processInstanceListPath} ability={ability}>
|
||||||
|
|
Loading…
Reference in New Issue