Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Jun 27, 2022
1 parent 7e4c7ee commit d2a03bf
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/features/align-elements/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import AlignElementsModule from 'diagram-js/lib/features/align-elements';
import ContextPadModule from 'diagram-js/lib/features/context-pad';
import PopupMenuModule from 'diagram-js/lib/features/popup-menu';

import AlignElementsContextPadProvider from './AlignElementsContextPadProvider';
import AlignElementsMenuProvider from './AlignElementsMenuProvider';

export default {
__depends__: [
AlignElementsModule,
ContextPadModule
ContextPadModule,
PopupMenuModule
],
__init__: [
'alignElementsContextPadProvider',
'alignElementsMenuProvider'
],
alignElementsContextPadProvider: [ 'type', AlignElementsContextPadProvider ],
alignElementsMenuProvider: [ 'type', AlignElementsMenuProvider ]
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import {
bootstrapModeler,
getBpmnJS,
inject
} from 'test/TestHelper';

import {
query as domQuery
} from 'min-dom';

import alignElementsModule from 'lib/features/align-elements';
import modelingModule from 'lib/features/modeling';
import coreModule from 'lib/core';



describe('features/align-elements - context pad', function() {

var testModules = [ alignElementsModule, modelingModule, coreModule ];

var basicXML = require('../../../fixtures/bpmn/align-elements.bpmn');

beforeEach(bootstrapModeler(basicXML, { modules: testModules }));


it('should provide button to open menu', inject(function(elementRegistry, contextPad) {

// given
var elements = [
elementRegistry.get('EndEvent_lane'),
elementRegistry.get('Task_lane'),
elementRegistry.get('SubProcess_lane')
];

// when
contextPad.open(elements);

// then
expect(getEntry(elements, 'align-elements')).to.exist;
}));


it('should NOT provide button if no actions are available', inject(
function(elementRegistry, contextPad, popupMenu) {

// given
var elements = [
elementRegistry.get('EndEvent_lane'),
elementRegistry.get('Task_lane'),
elementRegistry.get('SubProcess_lane')
];
popupMenu.registerProvider('align-elements', 0, {
getPopupMenuEntries: function() {
return function() {
return {};
};
}
});

// when
contextPad.open(elements);

// then
expect(getEntry(elements, 'align-elements')).not.to.exist;
})
);
});


// helper //////////////////////////////////////////////////////////////////////
function getEntry(target, actionName) {
return padEntry(getBpmnJS().invoke(function(contextPad) {
return contextPad.getPad(target).html;
}), actionName);
}

function padEntry(element, name) {
return domQuery('[data-action="' + name + '"]', element);
}

0 comments on commit d2a03bf

Please sign in to comment.