From f4d78017899d7534e07f394af5454657f39fb5ec Mon Sep 17 00:00:00 2001 From: "Marco A. Nina Mena" Date: Mon, 23 Nov 2026 14:51:42 -0400 Subject: [PATCH 1/2] Refactor linkEditing mixin to improve documentation number retrieval and add unit tests. Adjusted getNodeNumber method to return correct index based on documentation mapping. Introduced unit tests for documentation number functionality. --- src/mixins/linkEditing.js | 11 +++++-- .../linkEditing.documentationNumber.spec.js | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 tests/unit/linkEditing.documentationNumber.spec.js diff --git a/src/mixins/linkEditing.js b/src/mixins/linkEditing.js index b009de068..8a70f1644 100644 --- a/src/mixins/linkEditing.js +++ b/src/mixins/linkEditing.js @@ -455,10 +455,10 @@ export default { if (doc) { const nodeNumber = this.getNodeNumber(view.model.component.id); - if (nodeNumber >= 0) { + if (nodeNumber > 0) { window.ProcessMaker.EventBus.$emit( 'show-documentation', { - number: nodeNumber + 1, + number: nodeNumber, text: doc, position: pos, node: view.model.component.node, @@ -469,6 +469,11 @@ export default { }, getNodeNumber(nodeId) { + const documentationNumber = window.ProcessMaker?.modeler?.documentationNumbers?.[nodeId]; + if (documentationNumber) { + return documentationNumber; + } + const xmlString = window.ProcessMaker.$modeler.currentXML; const extractIds = (xml) => { @@ -483,7 +488,7 @@ export default { const ids = extractIds(xmlString); - return ids.indexOf(nodeId); + return ids.indexOf(nodeId) + 1; }, }, }; \ No newline at end of file diff --git a/tests/unit/linkEditing.documentationNumber.spec.js b/tests/unit/linkEditing.documentationNumber.spec.js new file mode 100644 index 000000000..9f8e2e54a --- /dev/null +++ b/tests/unit/linkEditing.documentationNumber.spec.js @@ -0,0 +1,29 @@ +import linkEditing from '@/mixins/linkEditing'; + +describe('linkEditing documentation numbering', () => { + afterEach(() => { + delete window.ProcessMaker; + }); + + it('uses the numbering map generated by the documentation API', () => { + window.ProcessMaker = { + modeler: { + documentationNumbers: { + task_1: 4, + }, + }, + }; + + expect(linkEditing.methods.getNodeNumber.call({}, 'task_1')).toBe(4); + }); + + it('falls back to the XML order when no numbering map exists', () => { + window.ProcessMaker = { + $modeler: { + currentXML: '', + }, + }; + + expect(linkEditing.methods.getNodeNumber.call({}, 'end_1')).toBe(2); + }); +}); From 0731db225bd6c75958dda082cf20691136381464 Mon Sep 17 00:00:00 2001 From: "Marco A. Nina Mena" Date: Mon, 23 Nov 2026 15:06:23 -0400 Subject: [PATCH 2/2] Refactor subProcess component to utilize getTaskShape function for shape initialization. Added unit tests for taskShape to verify documentation markers in different modes. --- src/components/nodes/subProcess/subProcess.vue | 4 ++-- .../components/nodes/task/taskShape.spec.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/unit/components/nodes/task/taskShape.spec.js diff --git a/src/components/nodes/subProcess/subProcess.vue b/src/components/nodes/subProcess/subProcess.vue index 5400ad549..ce34b821c 100644 --- a/src/components/nodes/subProcess/subProcess.vue +++ b/src/components/nodes/subProcess/subProcess.vue @@ -44,7 +44,7 @@ import debounce from 'lodash/debounce'; import { util } from 'jointjs'; import portsConfig from '@/mixins/portsConfig'; -import TaskShape from '@/components/nodes/task/shape'; +import { getTaskShape } from '@/components/nodes/task/shape'; import { taskHeight } from '@/components/nodes/task/taskConfig'; import store from '@/store'; import hasMarkers, { markerSize } from '@/mixins/hasMarkers'; @@ -196,7 +196,7 @@ export default { }, }, mounted() { - this.shape = new TaskShape(); + this.shape = getTaskShape(store.getters.isForDocumenting); this.$set(this.markers.bottomCenter, 'subprocess', subprocessIcon); let bounds = this.node.diagram.bounds; this.shape.position(bounds.x, bounds.y); diff --git a/tests/unit/components/nodes/task/taskShape.spec.js b/tests/unit/components/nodes/task/taskShape.spec.js new file mode 100644 index 000000000..d964dd60f --- /dev/null +++ b/tests/unit/components/nodes/task/taskShape.spec.js @@ -0,0 +1,17 @@ +import { getTaskShape } from '@/components/nodes/task/shape'; + +describe('task documentation shape', () => { + it('includes documentation markers in documenting mode', () => { + const shape = getTaskShape(true); + const selectors = shape.markup.map(item => item.selector); + + expect(selectors).toEqual(expect.arrayContaining(['doccircle', 'doclabel'])); + }); + + it('excludes documentation markers in designer mode', () => { + const shape = getTaskShape(false); + const selectors = shape.markup.map(item => item.selector); + + expect(selectors).not.toEqual(expect.arrayContaining(['doccircle', 'doclabel'])); + }); +});