2018-04-02 19:01:53 +00:00
|
|
|
/* global sinon */
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapViewer,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import TestContainer from 'mocha-test-container-support';
|
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
import { forEach } from 'min-dash';
|
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import coreModule from 'lib/core';
|
|
|
|
import editorActionsModule from 'lib/features/editor-actions';
|
|
|
|
import keyboardModule from 'lib/features/keyboard';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
var createKeyEvent = require('../../../util/KeyEvents').createKeyEvent;
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2016-06-21 13:18:29 +00:00
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
describe('features - keyboard', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
var testModules = [
|
|
|
|
coreModule,
|
2016-06-21 13:18:29 +00:00
|
|
|
editorActionsModule,
|
2015-08-03 09:49:06 +00:00
|
|
|
keyboardModule,
|
2016-06-21 13:18:29 +00:00
|
|
|
modelingModule
|
2015-07-22 16:08:53 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
beforeEach(bootstrapViewer(diagramXML, { modules: testModules }));
|
|
|
|
|
2016-06-21 13:18:29 +00:00
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
describe('bpmn key bindings', function() {
|
|
|
|
|
|
|
|
var container;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
container = TestContainer.get(this);
|
|
|
|
});
|
|
|
|
|
2015-10-19 06:09:58 +00:00
|
|
|
it('should include triggers inside editorActions', inject(function(editorActions) {
|
|
|
|
// then
|
2016-12-13 10:21:57 +00:00
|
|
|
expect(editorActions.length()).to.equal(19);
|
2016-04-13 10:36:19 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
forEach(['c', 'C'], function(key) {
|
2016-04-13 10:36:19 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
it('should global connect tool for key ' + key, inject(function(keyboard, globalConnect) {
|
2016-04-13 10:36:19 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
sinon.spy(globalConnect, 'toggle');
|
2016-04-13 10:36:19 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, key, false);
|
2016-04-13 10:36:19 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
2015-10-19 06:09:58 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// then
|
|
|
|
expect(globalConnect.toggle.calledOnce).to.be.true;
|
|
|
|
}));
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
});
|
2015-07-22 16:08:53 +00:00
|
|
|
|
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
forEach(['l', 'L'], function(key) {
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
it('should trigger lasso tool for key ' + key, inject(function(keyboard, lassoTool) {
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
sinon.spy(lassoTool, 'activateSelection');
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, key, false);
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// then
|
|
|
|
expect(lassoTool.activateSelection.calledOnce).to.be.true;
|
|
|
|
}));
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
});
|
2015-07-22 16:08:53 +00:00
|
|
|
|
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
forEach(['s', 'S'], function(key) {
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
it('should trigger space tool', inject(function(keyboard, spaceTool) {
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
sinon.spy(spaceTool, 'activateSelection');
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, key, false);
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// then
|
|
|
|
expect(spaceTool.activateSelection.calledOnce).to.be.true;
|
|
|
|
}));
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
});
|
2015-07-22 16:08:53 +00:00
|
|
|
|
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
forEach(['e', 'E'], function(key) {
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
it('should trigger direct editing', inject(function(keyboard, selection, elementRegistry, directEditing) {
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
sinon.spy(directEditing, 'activate');
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// given
|
|
|
|
var task = elementRegistry.get('Task_1');
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
selection.select(task);
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
var e = createKeyEvent(container, key, false);
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// then
|
|
|
|
expect(directEditing.activate.calledOnce).to.be.true;
|
|
|
|
}));
|
2015-07-22 16:08:53 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
});
|
2016-03-27 14:04:07 +00:00
|
|
|
|
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
forEach(['a', 'A'], function(key) {
|
2016-03-27 14:04:07 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
it('should select all elements',
|
|
|
|
inject(function(canvas, keyboard, selection, elementRegistry) {
|
2016-03-27 14:04:07 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, key, true);
|
2016-03-27 14:04:07 +00:00
|
|
|
|
2018-10-24 11:56:21 +00:00
|
|
|
var allElements = elementRegistry.getAll(),
|
|
|
|
rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
|
|
|
|
|
|
|
// then
|
|
|
|
var selectedElements = selection.get();
|
|
|
|
|
|
|
|
expect(selectedElements).to.have.length(allElements.length - 1);
|
|
|
|
expect(selectedElements).not.to.contain(rootElement);
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
forEach(['f', 'F'], function(key) {
|
|
|
|
|
|
|
|
it('should trigger search for labels', inject(function(keyboard, searchPad) {
|
|
|
|
|
|
|
|
sinon.spy(searchPad, 'toggle');
|
|
|
|
|
|
|
|
// given
|
|
|
|
var e = createKeyEvent(container, key, true);
|
|
|
|
|
|
|
|
// when
|
|
|
|
keyboard._keyHandler(e);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(searchPad.toggle).calledOnce;
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
2016-03-27 14:04:07 +00:00
|
|
|
|
2015-07-22 16:08:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|