Skip to content

Commit 58d7d7a

Browse files
philippfrommenikku
authored andcommittedSep 16, 2024·
fix(search): handle elements without label
Closes #2232
1 parent 14d14f7 commit 58d7d7a

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed
 

‎lib/features/search/BpmnSearchProvider.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ function compareTokens(tokensA, tokensB) {
146146
/**
147147
* Compares two strings.
148148
*
149-
* @param {string} a
150-
* @param {string} b
149+
* @param {string} [a]
150+
* @param {string} [b]
151151
*
152152
* @returns {number}
153153
*/
154-
function compareStrings(a, b) {
154+
function compareStrings(a = '', b = '') {
155155
return a.localeCompare(b);
156156
}
157157

‎test/spec/features/search/BpmnSearchProviderSpec.js

+15
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,21 @@ describe('features - BPMN search provider', function() {
206206
expect(elements[5].element.id).to.eql('foo_1');
207207
}));
208208

209+
210+
it('should handle elements without label', inject(function(bpmnSearch) {
211+
212+
// given
213+
var pattern = 'ass';
214+
215+
// when
216+
var elements = bpmnSearch.find(pattern);
217+
218+
// then
219+
expect(elements).length(2);
220+
expect(elements[0].element.id).to.eql('Association_1');
221+
expect(elements[1].element.id).to.eql('Association_2');
222+
}));
223+
209224
});
210225

211226
});
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0ikirpg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.23.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0">
2+
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0ikirpg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.27.0-rc.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0">
33
<bpmn:process id="Process_1" isExecutable="true">
44
<bpmn:task id="foo_3" name="foo bar" />
55
<bpmn:task id="baz" name="bar foo" />
66
<bpmn:task id="bar" name="foo bar" />
77
<bpmn:task id="foo_2" name="foo bar" />
88
<bpmn:task id="foo_1" name="baz" />
99
<bpmn:task id="foo_0" name="bar" />
10+
<bpmn:textAnnotation id="TextAnnotation_1" />
11+
<bpmn:association id="Association_1" associationDirection="None" sourceRef="foo_3" targetRef="TextAnnotation_1" />
12+
<bpmn:textAnnotation id="TextAnnotation_2" />
13+
<bpmn:association id="Association_2" associationDirection="None" sourceRef="baz" targetRef="TextAnnotation_2" />
1014
</bpmn:process>
1115
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
1216
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
1317
<bpmndi:BPMNShape id="Activity_1sd3etr_di" bpmnElement="foo_3">
14-
<dc:Bounds x="160" y="80" width="100" height="80" />
18+
<dc:Bounds x="160" y="160" width="100" height="80" />
1519
<bpmndi:BPMNLabel />
1620
</bpmndi:BPMNShape>
1721
<bpmndi:BPMNShape id="Activity_0tpx833_di" bpmnElement="baz">
18-
<dc:Bounds x="290" y="80" width="100" height="80" />
22+
<dc:Bounds x="290" y="160" width="100" height="80" />
1923
<bpmndi:BPMNLabel />
2024
</bpmndi:BPMNShape>
2125
<bpmndi:BPMNShape id="Activity_03mqj66_di" bpmnElement="bar">
22-
<dc:Bounds x="420" y="80" width="100" height="80" />
26+
<dc:Bounds x="420" y="160" width="100" height="80" />
2327
<bpmndi:BPMNLabel />
2428
</bpmndi:BPMNShape>
2529
<bpmndi:BPMNShape id="Activity_1pc6qua_di" bpmnElement="foo_2">
26-
<dc:Bounds x="550" y="80" width="100" height="80" />
30+
<dc:Bounds x="550" y="160" width="100" height="80" />
2731
<bpmndi:BPMNLabel />
2832
</bpmndi:BPMNShape>
2933
<bpmndi:BPMNShape id="Activity_0g0alrr_di" bpmnElement="foo_1">
30-
<dc:Bounds x="680" y="80" width="100" height="80" />
34+
<dc:Bounds x="680" y="160" width="100" height="80" />
3135
<bpmndi:BPMNLabel />
3236
</bpmndi:BPMNShape>
3337
<bpmndi:BPMNShape id="Activity_0mbe5y4_di" bpmnElement="foo_0">
34-
<dc:Bounds x="810" y="80" width="100" height="80" />
38+
<dc:Bounds x="810" y="160" width="100" height="80" />
3539
<bpmndi:BPMNLabel />
3640
</bpmndi:BPMNShape>
41+
<bpmndi:BPMNEdge id="Association_0sxp2i6_di" bpmnElement="Association_1">
42+
<di:waypoint x="248" y="160" />
43+
<di:waypoint x="296" y="110" />
44+
</bpmndi:BPMNEdge>
45+
<bpmndi:BPMNEdge id="Association_1gmudwp_di" bpmnElement="Association_2">
46+
<di:waypoint x="378" y="160" />
47+
<di:waypoint x="426" y="110" />
48+
</bpmndi:BPMNEdge>
49+
<bpmndi:BPMNShape id="TextAnnotation_0g5dnhq_di" bpmnElement="TextAnnotation_1">
50+
<dc:Bounds x="260" y="80" width="100" height="30" />
51+
</bpmndi:BPMNShape>
52+
<bpmndi:BPMNShape id="TextAnnotation_17bv75f_di" bpmnElement="TextAnnotation_2">
53+
<dc:Bounds x="390" y="80" width="100" height="30" />
54+
</bpmndi:BPMNShape>
3755
</bpmndi:BPMNPlane>
3856
</bpmndi:BPMNDiagram>
3957
</bpmn:definitions>

0 commit comments

Comments
 (0)
Please sign in to comment.