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

Use Timeout to Account for Async Rendering of Properties Panel #19

Merged
merged 3 commits into from
Sep 23, 2022
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
7 changes: 5 additions & 2 deletions lib/modeler/Linting.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ export default class Linting {

const { entryId } = propertiesPanel;

this._eventBus.fire('propertiesPanel.showEntry', {
id: entryId
// TODO(philippfromme): remove timeout once properties panel is fixed
setTimeout(() => {
this._eventBus.fire('propertiesPanel.showEntry', {
id: entryId
});
});
}

Expand Down
128 changes: 74 additions & 54 deletions test/spec/modeler/Linting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,88 +363,108 @@ describe('Linting', function() {
));


it('should show error', inject(
async function(bpmnjs, elementRegistry, eventBus, linting, selection) {
describe('show error', function() {

// given
const serviceTask = elementRegistry.get('ServiceTask_1');
let clock;

const reports = await linter.lint(bpmnjs.getDefinitions());
beforeEach(function() {
clock = sinon.useFakeTimers();
});

// assume
expect(reports).to.have.length(1);
afterEach(function() {
clock.restore();
});

linting.setErrors(reports);

linting.activate();
it('should show error', inject(
async function(bpmnjs, elementRegistry, eventBus, linting, selection) {

const propertiesPanelSetErrorSpy = sinon.spy();
// given
const serviceTask = elementRegistry.get('ServiceTask_1');

eventBus.on('propertiesPanel.setErrors', propertiesPanelSetErrorSpy);
const reports = await linter.lint(bpmnjs.getDefinitions());

const propertiesPanelShowEntrySpy = sinon.spy();
// assume
expect(reports).to.have.length(1);

eventBus.on('propertiesPanel.showEntry', propertiesPanelShowEntrySpy);
linting.setErrors(reports);

// when
linting.showError(reports[ 0 ]);
linting.activate();

// then
expect(selection.get()).to.eql([ serviceTask ]);
const propertiesPanelSetErrorSpy = sinon.spy();

expect(propertiesPanelSetErrorSpy).to.have.been.calledOnce;
expect(propertiesPanelSetErrorSpy).to.have.been.calledWithMatch({
errors: getErrors(reports, serviceTask)
});
eventBus.on('propertiesPanel.setErrors', propertiesPanelSetErrorSpy);

expect(propertiesPanelShowEntrySpy).to.have.been.calledOnce;
expect(propertiesPanelShowEntrySpy).to.have.been.calledWithMatch({
id: 'taskDefinitionType'
});
}
));
const propertiesPanelShowEntrySpy = sinon.spy();

eventBus.on('propertiesPanel.showEntry', propertiesPanelShowEntrySpy);

it('should show error on lintingAnnotations.click', inject(
async function(bpmnjs, elementRegistry, eventBus, linting, selection) {
// when
linting.showError(reports[ 0 ]);

// given
const serviceTask = elementRegistry.get('ServiceTask_1');
clock.tick();

const reports = await linter.lint(bpmnjs.getDefinitions());
// then
expect(selection.get()).to.eql([ serviceTask ]);

// assume
expect(reports).to.have.length(1);
expect(propertiesPanelSetErrorSpy).to.have.been.calledOnce;
expect(propertiesPanelSetErrorSpy).to.have.been.calledWithMatch({
errors: getErrors(reports, serviceTask)
});

linting.setErrors(reports);
expect(propertiesPanelShowEntrySpy).to.have.been.calledOnce;
expect(propertiesPanelShowEntrySpy).to.have.been.calledWithMatch({
id: 'taskDefinitionType'
});
}
));

linting.activate();

const propertiesPanelSetErrorSpy = sinon.spy();
it('should show error on lintingAnnotations.click', inject(
async function(bpmnjs, elementRegistry, eventBus, linting, selection) {

eventBus.on('propertiesPanel.setErrors', propertiesPanelSetErrorSpy);
// given
const serviceTask = elementRegistry.get('ServiceTask_1');

const propertiesPanelShowEntrySpy = sinon.spy();
const reports = await linter.lint(bpmnjs.getDefinitions());

eventBus.on('propertiesPanel.showEntry', propertiesPanelShowEntrySpy);
// assume
expect(reports).to.have.length(1);

// when
eventBus.fire('lintingAnnotations.click', { report: reports[ 0 ] });
linting.setErrors(reports);

// then
expect(selection.get()).to.eql([ serviceTask ]);
linting.activate();

expect(propertiesPanelSetErrorSpy).to.have.been.calledOnce;
expect(propertiesPanelSetErrorSpy).to.have.been.calledWithMatch({
errors: getErrors(reports, serviceTask)
});
const propertiesPanelSetErrorSpy = sinon.spy();

expect(propertiesPanelShowEntrySpy).to.have.been.calledOnce;
expect(propertiesPanelShowEntrySpy).to.have.been.calledWithMatch({
id: 'taskDefinitionType'
});
}
));
eventBus.on('propertiesPanel.setErrors', propertiesPanelSetErrorSpy);

const propertiesPanelShowEntrySpy = sinon.spy();

eventBus.on('propertiesPanel.showEntry', propertiesPanelShowEntrySpy);

// when
eventBus.fire('lintingAnnotations.click', { report: reports[ 0 ] });

// TODO(philippfromme): remove timeout once properties panel is fixed
clock.tick();
barmac marked this conversation as resolved.
Show resolved Hide resolved

// then
expect(selection.get()).to.eql([ serviceTask ]);

expect(propertiesPanelSetErrorSpy).to.have.been.calledOnce;
expect(propertiesPanelSetErrorSpy).to.have.been.calledWithMatch({
errors: getErrors(reports, serviceTask)
});

expect(propertiesPanelShowEntrySpy).to.have.been.calledOnce;
expect(propertiesPanelShowEntrySpy).to.have.been.calledWithMatch({
id: 'taskDefinitionType'
});
}
));

});


describe('canvas scrolling', function() {
Expand Down