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

fix(Input/Output): keep undo/redo stack #983

Merged
merged 1 commit into from
Oct 10, 2023
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
1 change: 0 additions & 1 deletion src/provider/zeebe/properties/InputProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ function addFactory({ element, bpmnFactory, commandStack }) {

// (3) create parameter
const newParameter = createElement('zeebe:Input', {
source: '',
target: nextId('InputVariable_')
}, ioMapping, bpmnFactory);

Expand Down
1 change: 0 additions & 1 deletion src/provider/zeebe/properties/OutputProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ function addFactory({ element, bpmnFactory, commandStack }) {

// (3) create parameter
const newParameter = createElement('zeebe:Output', {
source: '',
target: nextId('OutputVariable_')
}, ioMapping, bpmnFactory);

Expand Down
156 changes: 156 additions & 0 deletions test/spec/provider/zeebe/InputOutputParameter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
})
);


it('should display', inject(async function(elementRegistry, selection) {

// given
Expand Down Expand Up @@ -163,6 +164,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
})
);


it('should display', inject(async function(elementRegistry, selection) {

// given
Expand Down Expand Up @@ -223,6 +225,81 @@ describe('provider/zeebe - InputOutputParameter', function() {
})
);


describe('integration', function() {

// Test for undo/redo integration with newly created input/output parameters
// cf. https://github.com/bpmn-io/bpmn-js-properties-panel/issues/981
it('should undo',
inject(async function(elementRegistry, selection, commandStack) {

// given
const serviceTask = elementRegistry.get('ServiceTask_empty');

await act(() => {
selection.select(serviceTask);
});

const inputGroup = getGroup(container, 'inputs');
const addEntry = domQuery('.bio-properties-panel-add-entry', inputGroup);

await act(() => {
addEntry.click();
});

const sourceInput = domQuery('[name=ServiceTask_empty-input-0-source] [role="textbox"]', inputGroup);
await setEditorValue(sourceInput, 'newValue');

// assume
expect(getInput(serviceTask, 0).get('source')).to.eql('=newValue');

// when
commandStack.undo();
await nextTick(); // propagate value to editor and await change handler

// then
expect(getInput(serviceTask, 0).get('source')).to.be.undefined;
})
);


it('should redo',
inject(async function(elementRegistry, selection, commandStack) {

// given
const serviceTask = elementRegistry.get('ServiceTask_empty');

await act(() => {
selection.select(serviceTask);
});

const inputGroup = getGroup(container, 'inputs');
const addEntry = domQuery('.bio-properties-panel-add-entry', inputGroup);

await act(() => {
addEntry.click();
});

const sourceInput = domQuery('[name=ServiceTask_empty-input-0-source] [role="textbox"]', inputGroup);

await setEditorValue(sourceInput, 'newValue');

// assume
expect(getInput(serviceTask, 0).get('source')).to.eql('=newValue');

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

// then
expect(getInput(serviceTask, 0).get('source')).to.eql('=newValue');

})
);
});

});


Expand All @@ -247,6 +324,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
})
);


it('should display', inject(async function(elementRegistry, selection) {

// given
Expand Down Expand Up @@ -331,6 +409,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
})
);


it('should display', inject(async function(elementRegistry, selection) {

// given
Expand Down Expand Up @@ -391,6 +470,80 @@ describe('provider/zeebe - InputOutputParameter', function() {
})
);


describe('integration', function() {

// Test for undo/redo integration with newly created input/output parameters
// Cf. https://github.com/bpmn-io/bpmn-js-properties-panel/issues/981
it('should undo',
inject(async function(elementRegistry, selection, commandStack) {

// given
const serviceTask = elementRegistry.get('ServiceTask_empty');

await act(() => {
selection.select(serviceTask);
});

const outputGroup = getGroup(container, 'outputs');
const addEntry = domQuery('.bio-properties-panel-add-entry', outputGroup);

await act(() => {
addEntry.click();
});

const sourceInput = domQuery('[name=ServiceTask_empty-output-0-source] [role="textbox"]', outputGroup);
await setEditorValue(sourceInput, 'newValue');

// assume
expect(getOutput(serviceTask, 0).get('source')).to.eql('=newValue');

// when
commandStack.undo();
await nextTick(); // propagate value to editor and await change handler

// then
expect(getOutput(serviceTask, 0).get('source')).to.be.undefined;
})
);


it('should redo',
inject(async function(elementRegistry, selection, commandStack) {

// given
const serviceTask = elementRegistry.get('ServiceTask_empty');

await act(() => {
selection.select(serviceTask);
});

const outputGroup = getGroup(container, 'outputs');
const addEntry = domQuery('.bio-properties-panel-add-entry', outputGroup);

await act(() => {
addEntry.click();
});

const sourceInput = domQuery('[name=ServiceTask_empty-output-0-source] [role="textbox"]', outputGroup);
await setEditorValue(sourceInput, 'newValue');

// assume
expect(getOutput(serviceTask, 0).get('source')).to.eql('=newValue');

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

// then
expect(getOutput(serviceTask, 0).get('source')).to.eql('=newValue');

})
);
});

});

});
Expand All @@ -410,3 +563,6 @@ function getOutput(element, idx) {
return (getOutputParameters(element) || [])[idx];
}

function nextTick() {
return new Promise(resolve => setTimeout(resolve, 0));
}