-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: variable name changes when element name/label changes
Closes #863
- Loading branch information
1 parent
959725f
commit 760ba19
Showing
12 changed files
with
293 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ages/dmn-js-decision-table/test/spec/features/modeling/behavior/NameChangeBehaviorSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { bootstrapModeler, inject } from 'test/helper'; | ||
|
||
import decisionTableXML from './name-change-behavior.dmn'; | ||
|
||
import CoreModule from 'src/core'; | ||
import Modeling from 'src/features/modeling'; | ||
|
||
|
||
describe('NameChangeBehavior', function() { | ||
|
||
describe('with existing variable', function() { | ||
|
||
beforeEach(bootstrapModeler(decisionTableXML, { | ||
modules: [ | ||
CoreModule, | ||
Modeling | ||
], | ||
})); | ||
|
||
|
||
it('should update variable name when element name is changed', inject( | ||
function(modeling, sheet) { | ||
|
||
// given | ||
const root = sheet.getRoot(), | ||
decisionTable = root.businessObject; | ||
|
||
const decision = decisionTable.$parent; | ||
|
||
// when | ||
modeling.editDecisionTableName('foo'); | ||
|
||
// then | ||
const variable = decision.get('variable'); | ||
|
||
expect(variable.get('name')).to.equal('foo'); | ||
} | ||
)); | ||
}); | ||
}); |
31 changes: 31 additions & 0 deletions
31
packages/dmn-js-decision-table/test/spec/features/modeling/behavior/name-change-behavior.dmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" id="dish" name="Desired Dish" namespace="party" exporter="Camunda Modeler" exporterVersion="5.25.0"> | ||
<inputData id="InputData_0wikdil" name="Variable" /> | ||
<decision id="season" name="Season"> | ||
<variable id="InformationItem_var" name="Season" /> | ||
<informationRequirement id="InformationRequirement_13flr3u"> | ||
<requiredInput href="#InputData_0wikdil" /> | ||
</informationRequirement> | ||
<decisionTable id="DecisionTable_0hzuy0u"> | ||
<input id="InputClause_1c1qe3j"> | ||
<inputExpression id="LiteralExpression_0qgvyx9" typeRef="string" /> | ||
</input> | ||
<output id="OutputClause_1xvwwox" typeRef="string" /> | ||
</decisionTable> | ||
</decision> | ||
<dmndi:DMNDI> | ||
<dmndi:DMNDiagram> | ||
<dmndi:DMNShape id="DMNShape_1ds1jom" dmnElementRef="InputData_0wikdil"> | ||
<dc:Bounds height="45" width="125" x="138" y="198" /> | ||
</dmndi:DMNShape> | ||
<dmndi:DMNEdge id="DMNEdge_0qwszuo" dmnElementRef="InformationRequirement_13flr3u"> | ||
<di:waypoint x="201" y="198" /> | ||
<di:waypoint x="200" y="155" /> | ||
<di:waypoint x="200" y="135" /> | ||
</dmndi:DMNEdge> | ||
<dmndi:DMNShape id="DMNShape_0d8mpxr" dmnElementRef="season"> | ||
<dc:Bounds height="55" width="100" x="150" y="80" /> | ||
</dmndi:DMNShape> | ||
</dmndi:DMNDiagram> | ||
</dmndi:DMNDI> | ||
</definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/dmn-js-drd/test/spec/features/modeling/behavior/NameChangeBehaviorSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { bootstrapModeler, inject } from 'test/helper'; | ||
|
||
import simpleStringEditXML from './name-change-behavior.dmn'; | ||
|
||
import CoreModule from 'src/core'; | ||
import Modeling from 'src/features/modeling'; | ||
|
||
|
||
describe('NameChangeBehavior', function() { | ||
|
||
describe('with label change', function() { | ||
|
||
beforeEach(bootstrapModeler(simpleStringEditXML, { | ||
modules: [ | ||
CoreModule, | ||
Modeling | ||
], | ||
})); | ||
|
||
|
||
it('should update variable name when label is changed', inject( | ||
function(modeling, elementRegistry) { | ||
|
||
// given | ||
const decision = elementRegistry.get('season'), | ||
bo = decision.businessObject, | ||
variable = bo.variable; | ||
|
||
// when | ||
modeling.updateLabel(decision,'foo'); | ||
|
||
// then | ||
expect(variable.get('name')).to.equal('foo'); | ||
} | ||
)); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
packages/dmn-js-drd/test/spec/features/modeling/behavior/name-change-behavior.dmn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" xmlns:di="http://www.omg.org/spec/DMN/20180521/DI/" id="dish" name="Desired Dish" namespace="party" exporter="Camunda Modeler" exporterVersion="5.11.0"> | ||
<decision id="season" name="Season"> | ||
<variable id="InformationItem_16229yj" name="season" typeRef="string" /> | ||
<informationRequirement id="InformationRequirement_13flr3u"> | ||
<requiredInput href="#InputData_0wikdil" /> | ||
</informationRequirement> | ||
<literalExpression id="LiteralExpression_0hs8xyn"> | ||
<text>calendar.getSeason(date)</text> | ||
</literalExpression> | ||
</decision> | ||
<inputData id="InputData_0wikdil" name="Variable" /> | ||
<dmndi:DMNDI> | ||
<dmndi:DMNDiagram> | ||
<dmndi:DMNShape dmnElementRef="season"> | ||
<dc:Bounds height="55" width="100" x="150" y="80" /> | ||
</dmndi:DMNShape> | ||
<dmndi:DMNShape id="DMNShape_1ds1jom" dmnElementRef="InputData_0wikdil"> | ||
<dc:Bounds height="45" width="125" x="138" y="198" /> | ||
</dmndi:DMNShape> | ||
<dmndi:DMNEdge id="DMNEdge_0qwszuo" dmnElementRef="InformationRequirement_13flr3u"> | ||
<di:waypoint x="201" y="198" /> | ||
<di:waypoint x="200" y="155" /> | ||
<di:waypoint x="200" y="135" /> | ||
</dmndi:DMNEdge> | ||
</dmndi:DMNDiagram> | ||
</dmndi:DMNDI> | ||
</definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
packages/dmn-js-literal-expression/src/features/modeling/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import CommandStack from 'diagram-js/lib/command/CommandStack'; | ||
import IdChangeBehavior from | ||
'dmn-js-shared/lib/features/modeling/behavior/IdChangeBehavior'; | ||
|
||
import NameChangeBehavior from | ||
'dmn-js-shared/lib/features/modeling/behavior/NameChangeBehavior'; | ||
import Modeling from './Modeling'; | ||
|
||
export default { | ||
__init__: [ 'idChangeBehavior', 'modeling' ], | ||
__init__: [ 'idChangeBehavior', 'nameChangeBehavior', 'modeling' ], | ||
commandStack: [ 'type', CommandStack ], | ||
idChangeBehavior: [ 'type', IdChangeBehavior ], | ||
nameChangeBehavior: [ 'type', NameChangeBehavior ], | ||
modeling: [ 'type', Modeling ] | ||
}; |
37 changes: 37 additions & 0 deletions
37
.../dmn-js-literal-expression/test/spec/features/modeling/behavior/NameChangeBehaviorSpec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { bootstrapModeler, inject } from 'test/helper'; | ||
|
||
import simpleStringEditXML from '../../../literal-expression.dmn'; | ||
|
||
import CoreModule from 'src/core'; | ||
import Modeling from 'src/features/modeling'; | ||
|
||
|
||
describe('NameChangeBehavior', function() { | ||
|
||
describe('with existing variable', function() { | ||
|
||
beforeEach(bootstrapModeler(simpleStringEditXML, { | ||
modules: [ | ||
CoreModule, | ||
Modeling | ||
], | ||
})); | ||
|
||
|
||
it('should update variable name when element name is changed', inject( | ||
function(modeling, viewer) { | ||
|
||
// given | ||
const decision = viewer.getDecision(); | ||
|
||
// when | ||
modeling.editDecisionName('foo'); | ||
|
||
// then | ||
const variable = decision.get('variable'); | ||
|
||
expect(variable.get('name')).to.equal('foo'); | ||
} | ||
)); | ||
}); | ||
}); |
Oops, something went wrong.