From 849011f69e68ced1f46f71f92d17aa448be92766 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 20 Jun 2022 16:43:47 -0400 Subject: [PATCH] added test to delete a process instance w/ burnettk --- cypress/e2e/process_instances.cy.js | 29 +++++----- cypress/e2e/process_models.cy.js | 33 ++++++++++++ cypress/fixtures/test_bpmn_file_upload.bpmn | 40 ++++++++++++++ cypress/support/commands.js | 4 ++ public/sample.bpmn | 59 --------------------- src/components/FileInput.js | 2 +- src/index.js | 2 + src/routes/ProcessGroupShow.js | 3 +- src/routes/ProcessInstanceList.js | 12 ++--- src/routes/ProcessInstanceShow.js | 43 +++++++++++++++ 10 files changed, 141 insertions(+), 86 deletions(-) create mode 100644 cypress/fixtures/test_bpmn_file_upload.bpmn delete mode 100644 public/sample.bpmn create mode 100644 src/routes/ProcessInstanceShow.js diff --git a/cypress/e2e/process_instances.cy.js b/cypress/e2e/process_instances.cy.js index 75ceb9f..58a60a4 100644 --- a/cypress/e2e/process_instances.cy.js +++ b/cypress/e2e/process_instances.cy.js @@ -17,7 +17,7 @@ describe('process-instances', () => { const bpmnFile = "process_model_one.bpmn"; cy.contains(originalDmnOutputForKevin).should('not.exist');; - runPrimaryBpmnFile(originalDmnOutputForKevin); + cy.runPrimaryBpmnFile(originalDmnOutputForKevin); // Change dmn cy.contains(dmnFile).click(); @@ -25,26 +25,26 @@ describe('process-instances', () => { updateDmnText(originalDmnOutputForKevin, newDmnOutputForKevin); cy.contains('acceptance-tests-model-1').click(); - runPrimaryBpmnFile(newDmnOutputForKevin); + cy.runPrimaryBpmnFile(newDmnOutputForKevin); cy.contains(dmnFile).click(); cy.contains(`Process Model File: ${dmnFile}`); updateDmnText(newDmnOutputForKevin, originalDmnOutputForKevin); cy.contains('acceptance-tests-model-1').click(); - runPrimaryBpmnFile(originalDmnOutputForKevin); + cy.runPrimaryBpmnFile(originalDmnOutputForKevin); // Change bpmn cy.contains(bpmnFile).click(); cy.contains(`Process Model File: ${bpmnFile}`); updateBpmnPythonScript(newPythonScript, bpmnFile); cy.contains('acceptance-tests-model-1').click(); - runPrimaryBpmnFile(dmnOutputForDan); + cy.runPrimaryBpmnFile(dmnOutputForDan); cy.contains(bpmnFile).click(); cy.contains(`Process Model File: ${bpmnFile}`); updateBpmnPythonScript(originalPythonScript, bpmnFile); cy.contains('acceptance-tests-model-1').click(); - runPrimaryBpmnFile(originalDmnOutputForKevin); + cy.runPrimaryBpmnFile(originalDmnOutputForKevin); }); it('can create a new instance and can modify with monaco text editor', () => { @@ -59,22 +59,22 @@ describe('process-instances', () => { cy.contains(`Process Model File: ${bpmnFile}`); updateBpmnPythonScriptWithMonaco(newPythonScript, bpmnFile); cy.contains('acceptance-tests-model-1').click(); - runPrimaryBpmnFile(dmnOutputForMike); + cy.runPrimaryBpmnFile(dmnOutputForMike); cy.contains(bpmnFile).click(); cy.contains(`Process Model File: ${bpmnFile}`); updateBpmnPythonScriptWithMonaco(originalPythonScript, bpmnFile); cy.contains('acceptance-tests-model-1').click(); - runPrimaryBpmnFile(dmnOutputForKevin); + cy.runPrimaryBpmnFile(dmnOutputForKevin); }); it('can paginate items', () => { // make sure we have some process instances - runPrimaryBpmnFile('Very wonderful'); - runPrimaryBpmnFile('Very wonderful'); - runPrimaryBpmnFile('Very wonderful'); - runPrimaryBpmnFile('Very wonderful'); - runPrimaryBpmnFile('Very wonderful'); + cy.runPrimaryBpmnFile('Very wonderful'); + cy.runPrimaryBpmnFile('Very wonderful'); + cy.runPrimaryBpmnFile('Very wonderful'); + cy.runPrimaryBpmnFile('Very wonderful'); + cy.runPrimaryBpmnFile('Very wonderful'); cy.contains('Process Instances').click(); cy.basicPaginationTest(); @@ -119,8 +119,3 @@ function updateBpmnPythonScriptWithMonaco(pythonScript, bpmnFile, elementId="pro cy.wait(500); cy.contains('Save').click(); } - -function runPrimaryBpmnFile(expectedText) { - cy.contains('Run Primary').click(); - cy.contains(expectedText); -} diff --git a/cypress/e2e/process_models.cy.js b/cypress/e2e/process_models.cy.js index 087a45b..f74e6c5 100644 --- a/cypress/e2e/process_models.cy.js +++ b/cypress/e2e/process_models.cy.js @@ -87,6 +87,39 @@ describe('process-models', () => { cy.contains(modelId).should('not.exist'); }); + it('can upload and run a bpmn file', () => { + const uuid = () => Cypress._.random(0, 1e6) + const id = uuid() + const groupId = 'acceptance-tests-group-one'; + const modelDisplayName = `Test Model 2 ${id}`; + const newModelDisplayName = `${modelDisplayName} edited`; + const modelId = `test-model-2-${id}`; + cy.contains(groupId).click(); + cy.createModel(groupId, modelId, modelDisplayName); + cy.contains(`Process Group: ${groupId}`).click(); + cy.contains(modelId); + + cy.contains(modelId).click() + cy.url().should('include', `process-models/${groupId}/${modelId}`); + cy.contains(`Process Model: ${modelId}`); + + cy.get('input[type=file]').selectFile('cypress/fixtures/test_bpmn_file_upload.bpmn') + cy.contains('Submit').click(); + cy.runPrimaryBpmnFile('champion'); + + cy.contains('Process Instances').click(); + cy.getBySel('process-instance-show-link').click(); + cy.contains('Delete process instance').click(); + cy.contains(`Process Instances for ${modelId}`); + cy.contains(`Process Model: ${modelId}`); + cy.contains(modelId).click(); + + cy.contains('Edit process model').click(); + cy.contains('Delete process model').click(); + cy.url().should('include', `process-groups/${groupId}`); + cy.contains(modelId).should('not.exist'); + }); + it('can paginate items', () => { cy.contains('acceptance-tests-group-one').click(); cy.basicPaginationTest(); diff --git a/cypress/fixtures/test_bpmn_file_upload.bpmn b/cypress/fixtures/test_bpmn_file_upload.bpmn new file mode 100644 index 0000000..e9160b8 --- /dev/null +++ b/cypress/fixtures/test_bpmn_file_upload.bpmn @@ -0,0 +1,40 @@ + + + + + Flow_07vd2ar + + + Flow_07vd2ar + Flow_1alkjjb + the_variable = "champion" + + + + Flow_1alkjjb + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 29064fa..81702a9 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -53,6 +53,10 @@ Cypress.Commands.add('createModel', (groupId, modelId, modelDisplayName) => { cy.contains(`Process Model: ${modelId}`); }); +Cypress.Commands.add('runPrimaryBpmnFile', (expectedText) => { + cy.contains('Run Primary').click(); + cy.contains(expectedText); +}); Cypress.Commands.add('basicPaginationTest', () => { cy.get("#pagination-page-dropdown") diff --git a/public/sample.bpmn b/public/sample.bpmn deleted file mode 100644 index 079f15a..0000000 --- a/public/sample.bpmn +++ /dev/null @@ -1,59 +0,0 @@ - - - - - Flow_10jwwqy - - - - Flow_1hd6o66 - - - - Flow_10jwwqy - Flow_0htxke7 - my_var = "Hello World" -Mike = "Awesome" -person = "Kevin" - - - - Flow_0htxke7 - Flow_1hd6o66 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/FileInput.js b/src/components/FileInput.js index 5d6d196..351b6e4 100644 --- a/src/components/FileInput.js +++ b/src/components/FileInput.js @@ -13,7 +13,7 @@ export default class FileInput extends React.Component { handleSubmit(event) { event.preventDefault() - const url = `${BACKEND_BASE_URL}/process-models/${this.props.processModel.id}/file`; + const url = `${BACKEND_BASE_URL}/process-models/${this.props.processModel.process_group_id}/${this.props.processModel.id}/file`; const formData = new FormData(); formData.append('file', this.fileInput.current.files[0]); formData.append('fileName', this.fileInput.current.files[0].name); diff --git a/src/index.js b/src/index.js index 3081cb6..2ced4a2 100644 --- a/src/index.js +++ b/src/index.js @@ -23,6 +23,7 @@ import ProcessInstanceList from "./routes/ProcessInstanceList" import ProcessInstanceReport from "./routes/ProcessInstanceReport" import ProcessModelNew from "./routes/ProcessModelNew" import ProcessModelEdit from "./routes/ProcessModelEdit" +import ProcessInstanceShow from "./routes/ProcessInstanceShow" import ErrorBoundary from "./components/ErrorBoundary" import { Container } from 'react-bootstrap' @@ -49,6 +50,7 @@ root.render( } /> } /> } /> + } /> diff --git a/src/routes/ProcessGroupShow.js b/src/routes/ProcessGroupShow.js index 91e5cdd..5554fc0 100644 --- a/src/routes/ProcessGroupShow.js +++ b/src/routes/ProcessGroupShow.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import { Link, useSearchParams, useNavigate } from "react-router-dom"; +import { Link, useSearchParams } from "react-router-dom"; import { BACKEND_BASE_URL } from '../config'; import { HOT_AUTH_TOKEN } from '../config'; import { useParams } from "react-router-dom"; @@ -10,7 +10,6 @@ import PaginationForTable, { DEFAULT_PER_PAGE, DEFAULT_PAGE } from '../component export default function ProcessGroupShow() { const params = useParams(); const [searchParams] = useSearchParams(); - const navigate = useNavigate(); const [processGroup, setProcessGroup] = useState(null); const [processModels, setProcessModels] = useState([]); diff --git a/src/routes/ProcessInstanceList.js b/src/routes/ProcessInstanceList.js index f59bd0d..72e8993 100644 --- a/src/routes/ProcessInstanceList.js +++ b/src/routes/ProcessInstanceList.js @@ -1,5 +1,5 @@ import React, { useEffect, useState } from "react"; -import { useParams, useSearchParams } from "react-router-dom"; +import { Link, useParams, useSearchParams } from "react-router-dom"; import { BACKEND_BASE_URL } from '../config'; import { HOT_AUTH_TOKEN } from '../config'; @@ -14,7 +14,6 @@ export default function ProcessInstanceList() { const [processInstances, setProcessInstances] = useState([]); const [pagination, setPagination] = useState(null); - const [processGroupId, setProcessGroupId] = useState(null); useEffect(() => { getProcessInstances(); @@ -33,9 +32,6 @@ export default function ProcessInstanceList() { const processInstancesFromApi = result.results; setProcessInstances(processInstancesFromApi); setPagination(result.pagination); - if (processInstancesFromApi[0]) { - setProcessGroupId(processInstancesFromApi[0].process_group_id) - } }, (error) => { console.log(error); @@ -56,7 +52,9 @@ export default function ProcessInstanceList() { } return ( - {row.id} + + {row.id} + {row.process_model_identifier} {row.process_group_id} {start_date.toString()} @@ -91,7 +89,7 @@ export default function ProcessInstanceList() {

Process Instances for {params.process_model_id}

diff --git a/src/routes/ProcessInstanceShow.js b/src/routes/ProcessInstanceShow.js new file mode 100644 index 0000000..291b2f3 --- /dev/null +++ b/src/routes/ProcessInstanceShow.js @@ -0,0 +1,43 @@ +import React, { useEffect, useState } from "react"; +import { useParams, useNavigate } from "react-router-dom"; +import { BACKEND_BASE_URL, HOT_AUTH_TOKEN } from '../config'; +import { Button } from 'react-bootstrap' +import ProcessBreadcrumb from '../components/ProcessBreadcrumb' + +export default function ProcessInstanceShow(props) { + const [error, setError] = useState(null); + const navigate = useNavigate(); + const params = useParams(); + + useEffect(() => { + }, []); + + const deleteProcessInstance = (() => { + fetch(`${BACKEND_BASE_URL}/process-models/${params.process_group_id}/${params.process_model_id}/process-instances/${params.process_instance_id}`, { + headers: new Headers({ + 'Authorization': `Bearer ${HOT_AUTH_TOKEN}` + }), + method: 'DELETE', + }) + .then(res => res.json()) + .then( + (result) => { + navigate(`/process-models/${params.process_group_id}/${params.process_model_id}/process-instances`); + }, + (error) => { + console.log(error); + } + ) + }); + + return ( +
+ + +
+ ) +}