Skip to content

Commit

Permalink
fix(search): handle elements without label
Browse files Browse the repository at this point in the history
Closes #2232
  • Loading branch information
philippfromme authored and nikku committed Sep 16, 2024
1 parent 14d14f7 commit 58d7d7a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/features/search/BpmnSearchProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ function compareTokens(tokensA, tokensB) {
/**
* Compares two strings.
*
* @param {string} a
* @param {string} b
* @param {string} [a]
* @param {string} [b]
*
* @returns {number}
*/
function compareStrings(a, b) {
function compareStrings(a = '', b = '') {
return a.localeCompare(b);
}

Expand Down
15 changes: 15 additions & 0 deletions test/spec/features/search/BpmnSearchProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ describe('features - BPMN search provider', function() {
expect(elements[5].element.id).to.eql('foo_1');
}));


it('should handle elements without label', inject(function(bpmnSearch) {

// given
var pattern = 'ass';

// when
var elements = bpmnSearch.find(pattern);

// then
expect(elements).length(2);
expect(elements[0].element.id).to.eql('Association_1');
expect(elements[1].element.id).to.eql('Association_2');
}));

});

});
32 changes: 25 additions & 7 deletions test/spec/features/search/bpmn-search-sorting.bpmn
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:task id="foo_3" name="foo bar" />
<bpmn:task id="baz" name="bar foo" />
<bpmn:task id="bar" name="foo bar" />
<bpmn:task id="foo_2" name="foo bar" />
<bpmn:task id="foo_1" name="baz" />
<bpmn:task id="foo_0" name="bar" />
<bpmn:textAnnotation id="TextAnnotation_1" />
<bpmn:association id="Association_1" associationDirection="None" sourceRef="foo_3" targetRef="TextAnnotation_1" />
<bpmn:textAnnotation id="TextAnnotation_2" />
<bpmn:association id="Association_2" associationDirection="None" sourceRef="baz" targetRef="TextAnnotation_2" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="Activity_1sd3etr_di" bpmnElement="foo_3">
<dc:Bounds x="160" y="80" width="100" height="80" />
<dc:Bounds x="160" y="160" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0tpx833_di" bpmnElement="baz">
<dc:Bounds x="290" y="80" width="100" height="80" />
<dc:Bounds x="290" y="160" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_03mqj66_di" bpmnElement="bar">
<dc:Bounds x="420" y="80" width="100" height="80" />
<dc:Bounds x="420" y="160" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1pc6qua_di" bpmnElement="foo_2">
<dc:Bounds x="550" y="80" width="100" height="80" />
<dc:Bounds x="550" y="160" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0g0alrr_di" bpmnElement="foo_1">
<dc:Bounds x="680" y="80" width="100" height="80" />
<dc:Bounds x="680" y="160" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0mbe5y4_di" bpmnElement="foo_0">
<dc:Bounds x="810" y="80" width="100" height="80" />
<dc:Bounds x="810" y="160" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_0sxp2i6_di" bpmnElement="Association_1">
<di:waypoint x="248" y="160" />
<di:waypoint x="296" y="110" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_1gmudwp_di" bpmnElement="Association_2">
<di:waypoint x="378" y="160" />
<di:waypoint x="426" y="110" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="TextAnnotation_0g5dnhq_di" bpmnElement="TextAnnotation_1">
<dc:Bounds x="260" y="80" width="100" height="30" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_17bv75f_di" bpmnElement="TextAnnotation_2">
<dc:Bounds x="390" y="80" width="100" height="30" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit 58d7d7a

Please sign in to comment.