Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port #917 to main #918

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,119 @@ import CoreModule from 'src/core';
import Modeling from 'src/features/modeling';


describe('NameChangeBehavior', function() {
describe('features/modeling - NameChangeBehavior', function() {

describe('with label change', function() {
beforeEach(bootstrapModeler(simpleStringEditXML, {
modules: [
CoreModule,
Modeling
],
}));

beforeEach(bootstrapModeler(simpleStringEditXML, {
modules: [
CoreModule,
Modeling
],
}));

describe('should update variable name when label is changed', function() {


it('<do>', inject(
function(modeling, elementRegistry) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;

// when
modeling.updateLabel(decision,'foo');
describe('should update variable name when label is changed', function() {

// then
expect(variable.get('name')).to.equal('foo');
}
));


it('<undo>', inject(function(modeling, elementRegistry, commandStack) {
it('<do>', inject(
function(modeling, elementRegistry) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;
modeling.updateLabel(decision,'foo');

// when
commandStack.undo();
modeling.updateLabel(decision,'foo');

// then
expect(variable.get('name')).to.equal('season');
}));
expect(variable.get('name')).to.equal('foo');
}
));


it('<undo>', inject(function(modeling, elementRegistry, commandStack) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;
modeling.updateLabel(decision,'foo');

// when
commandStack.undo();

// then
expect(variable.get('name')).to.equal('season');
}));


it('<redo>', inject(function(modeling, elementRegistry, commandStack) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;
modeling.updateLabel(decision,'foo');

// when
commandStack.undo();
commandStack.redo();

// then
expect(variable.get('name')).to.equal('foo');
}));
});


describe('should update variable name when element name is changed', function() {

it('<redo>', inject(function(modeling, elementRegistry, commandStack) {

it('<do>', inject(
function(modeling, elementRegistry) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;
modeling.updateLabel(decision,'foo');

// when
commandStack.undo();
commandStack.redo();
modeling.updateProperties(decision, { name: 'foo' });

// then
expect(variable.get('name')).to.equal('foo');
}));
});
}
));


it('<undo>', inject(function(modeling, elementRegistry, commandStack) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;
modeling.updateProperties(decision, { name: 'foo' });

// when
commandStack.undo();

// then
expect(variable.get('name')).to.equal('season');
}));


it('<redo>', inject(function(modeling, elementRegistry, commandStack) {

// given
const decision = elementRegistry.get('season'),
bo = decision.businessObject,
variable = bo.variable;
modeling.updateProperties(decision, { name: 'foo' });

// when
commandStack.undo();
commandStack.redo();

// then
expect(variable.get('name')).to.equal('foo');
}));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class NameChangeBehavior extends CommandInterceptor {
return;
}

else if (!this.isElementVariable(element)) {
else if (!this.shouldSyncVariable(element)) {
this.syncElementVariableChange(bo);
}
};
Expand All @@ -68,9 +68,10 @@ export default class NameChangeBehavior extends CommandInterceptor {
);
}

isElementVariable(element) {
const variable = element.get('variable');
return variable && (element.name === variable.name);
shouldSyncVariable(element) {
const bo = getBusinessObject(element),
variable = bo.get('variable');
return variable && (bo.name === variable.name);
}

syncElementVariableChange(businessObject) {
Expand Down
4 changes: 4 additions & 0 deletions packages/dmn-js/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ ___Note:__ Yet to be released changes appear here._

* Keyboard (DRD) is now implicit, and canvas is focusable, cf. [bpmn-io/diagram-js#662](https://github.com/bpmn-io/diagram-js/pull/662))

## 16.8.2

* `FIX`: make name change behavior not break on name change ([#917](https://github.com/bpmn-io/dmn-js/pull/917))

## 16.8.1

* `FIX`: make literal expression editor hitbox bigger in BKM ([camunda/camunda-modeler#4545](https://github.com/camunda/camunda-modeler/issues/4545))
Expand Down