From 68d35c1629e0f45c22b44514c4133f39bc3befad Mon Sep 17 00:00:00 2001 From: mbeisel Date: Mon, 28 Aug 2023 18:08:18 +0200 Subject: [PATCH] add deploymenttests (#81) * add deploymenttests * add logging to test * add port --- .github/workflows/run-npm-test.yml | 7 ++ .../editor/events/EditorEventHandler.js | 2 +- .../editor/util/IoUtilities.js | 4 +- components/bpmn-q/public/index.html | 10 -- .../quantme/quantme-transformation.spec.js | 92 +++---------------- 5 files changed, 24 insertions(+), 91 deletions(-) diff --git a/.github/workflows/run-npm-test.yml b/.github/workflows/run-npm-test.yml index e90d83f1..e0135496 100644 --- a/.github/workflows/run-npm-test.yml +++ b/.github/workflows/run-npm-test.yml @@ -10,6 +10,13 @@ on: jobs: run-test: runs-on: ubuntu-latest + + services: + workflow-test-engine: + image: planqk/workflow-engine-test:latest + ports: + - 8090:8090 + steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/components/bpmn-q/modeler-component/editor/events/EditorEventHandler.js b/components/bpmn-q/modeler-component/editor/events/EditorEventHandler.js index 782ebbd1..6fe4dab7 100644 --- a/components/bpmn-q/modeler-component/editor/events/EditorEventHandler.js +++ b/components/bpmn-q/modeler-component/editor/events/EditorEventHandler.js @@ -31,7 +31,7 @@ export function dispatchWorkflowEvent(type, workflowXml, workflowName) { }, cancelable: true }); - return modelerComponent.dispatchEvent(newEvent); + return modelerComponent?.dispatchEvent?.(newEvent)??true; } /** diff --git a/components/bpmn-q/modeler-component/editor/util/IoUtilities.js b/components/bpmn-q/modeler-component/editor/util/IoUtilities.js index 425f3a36..646d36a9 100644 --- a/components/bpmn-q/modeler-component/editor/util/IoUtilities.js +++ b/components/bpmn-q/modeler-component/editor/util/IoUtilities.js @@ -175,11 +175,11 @@ export async function deployWorkflowToCamunda(workflowName, workflowXml, viewMap }; } else { console.error('Deployment of workflow returned invalid status code: %s', response.status); - return { status: 'failed' }; + return { status: 'failed', message: 'Deployment of workflow returned invalid response: ' + response }; } } catch (error) { console.error('Error while executing post to deploy workflow: ' + error); - return { status: 'failed' }; + return { status: 'failed', message: 'Error while executing post to deploy workflow: ' + error }; } } diff --git a/components/bpmn-q/public/index.html b/components/bpmn-q/public/index.html index b3b752f2..7574a65a 100644 --- a/components/bpmn-q/public/index.html +++ b/components/bpmn-q/public/index.html @@ -172,18 +172,8 @@ } } ] - // const divContainer = document.getElementById('modeler-container'); - // divContainer.append(modelerComponent); modelerComponent.pluginConfigs = pluginConfigs; - - // const exampleWorkflow = ' Flow_1kcmptx Flow_1kcmptx Flow_0d4z11j Flow_0d4z11j '; - // - // function loadWorkflow() { - // modelerComponent.loadWorkflowDiagram(exampleWorkflow); - // } - // setTimeout(loadWorkflow, 8000); - diff --git a/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js b/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js index f569fd92..b1da5827 100644 --- a/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js +++ b/components/bpmn-q/test/tests/quantme/quantme-transformation.spec.js @@ -1,16 +1,18 @@ -const { setPluginConfig, resetConfig } = require("../../../modeler-component/editor/plugin/PluginConfigHandler"); +const { setPluginConfig } = require("../../../modeler-component/editor/plugin/PluginConfigHandler"); +const { deployWorkflowToCamunda } = require("../../../modeler-component/editor/util/IoUtilities"); const { updateQRMs, resetQRMs } = require("../../../modeler-component/extensions/quantme/qrm-manager"); -const { getFoldersInRepository } = require("../../../modeler-component/extensions/quantme/qrm-manager/git-handler"); const { startQuantmeReplacementProcess } = require("../../../modeler-component/extensions/quantme/replacement/QuantMETransformator"); const { validQuantMEDiagram, validQuantMESubprocessDiagram } = require("../helpers/DiagramHelper"); const config = require("../../../modeler-component/extensions/quantme/framework-config/config-manager"); const camundaConfig = require("../../../modeler-component/editor/config/EditorConfigManager"); const chai = require("chai"); +const {createTempModeler} = require("../../../modeler-component/editor/ModelerHandler"); describe('Test the QuantMETransformator of the QuantME extension.', function () { describe('Transformation of QuantME extensions', function () { it('should create a valid native workflow model after two transformations', async function () { + const modeler = createTempModeler(); setPluginConfig([{ name: 'dataflow' }, { name: 'quantme', @@ -34,43 +36,28 @@ describe('Test the QuantMETransformator of the QuantME extension.', function () chai.expect(qrmMaxCut.length).to.equal(1); let allQrms = qrms.concat(qrmMaxCut); - // remove the optimization QRM - let qrmsFirstTransformation = qrms.slice(0, 5).concat(qrms.slice(6)).concat(qrmMaxCut); - let expectedExpandedAttributes = []; - for (let i = 0; i < qrmsFirstTransformation.length; i++) { - let expandedAttributes = extractIsExpandedAttribute(qrmsFirstTransformation[i].replacement); - expectedExpandedAttributes = expectedExpandedAttributes.concat(expandedAttributes); - } - const result = await startQuantmeReplacementProcess(validQuantMESubprocessDiagram, qrmsFirstTransformation, { + const firstTransformationResult = await startQuantmeReplacementProcess(validQuantMESubprocessDiagram, allQrms, { nisqAnalyzerEndpoint: config.getNisqAnalyzerEndpoint(), transformationFrameworkEndpoint: config.getTransformationFrameworkEndpoint(), camundaEndpoint: camundaConfig.getCamundaEndpoint() }); - chai.expect(result.status).to.equal('transformed'); - let expandedFirstTransformation = extractIsExpandedAttribute(result.xml); - chai.expect(expandedFirstTransformation).to.deep.equal(expectedExpandedAttributes); + chai.expect(firstTransformationResult.status).to.equal('transformed'); - chai.expect(result.status).to.equal('transformed'); - expectedExpandedAttributes = []; - allQrms = allQrms.concat(qrms.slice(5, 6)); - for (let i = 0; i < allQrms.length; i++) { - let expandedAttributes = extractIsExpandedAttribute(allQrms[i].replacement); - expectedExpandedAttributes = expectedExpandedAttributes.concat(expandedAttributes); - } - - const transformationResult = await startQuantmeReplacementProcess(result.xml, allQrms, { + const secondTransformationResult = await startQuantmeReplacementProcess(firstTransformationResult.xml, allQrms, { nisqAnalyzerEndpoint: config.getNisqAnalyzerEndpoint(), transformationFrameworkEndpoint: config.getTransformationFrameworkEndpoint(), camundaEndpoint: camundaConfig.getCamundaEndpoint() }); - chai.expect(transformationResult.status).to.equal('transformed'); - let expandedSecondTransformation = extractIsExpandedAttribute(transformationResult.xml); - chai.expect(expandedSecondTransformation).to.deep.equal(expectedExpandedAttributes); + chai.expect(secondTransformationResult.status).to.equal('transformed'); // check that all extension elements are replaced - chai.expect(transformationResult.xml).to.not.contain(']*>/g; - const matches = xmlString.match(regexPattern); - - let expanded = []; - - // Regular expression pattern to extract bpmndi:BPMNShape elements - const shapeRegexPattern = /]*>/g; - - // Regular expression pattern to extract isExpanded attribute value - const isExpandedRegexPattern = /isExpanded="([^"]+)"/; - - // Extract the bpmndi:BPMNShape elements using the regular expression - const shapeMatches = xmlString.match(shapeRegexPattern); - - // Loop through the shape matches and extract the isExpanded attribute - for (let i = 0; i < shapeMatches.length; i++) { - const shapeMatch = shapeMatches[i]; - - // Extract the bpmnElement attribute value - const bpmnElementMatch = shapeMatch.match(/bpmnElement="([^"]+)"/); - if (bpmnElementMatch && bpmnElementMatch.length > 1) { - const bpmnElement = bpmnElementMatch[1]; - - // Extract the isExpanded attribute value - const isExpandedMatch = shapeMatch.match(isExpandedRegexPattern); - let positionCircuitCutting = xmlString.search('circuitCuttingSubprocess id="' + bpmnElement + '"'); - let positionSubProcess = xmlString.search('subProcess id="' + bpmnElement + '"'); - - if (positionCircuitCutting > -1 || positionSubProcess > -1) { - if (isExpandedMatch && isExpandedMatch.length > 1) { - const isExpanded = isExpandedMatch[1]; - - if (isExpanded !== undefined) { - expanded.push(isExpanded); - } - } else { - expanded.push('false'); - } - } - } - } - return expanded; -} \ No newline at end of file +}); \ No newline at end of file