chore(test): refactor replace action trigger
This commit is contained in:
parent
0feebe0b0c
commit
0c6c26ef4d
|
@ -41,6 +41,16 @@ function getEntries(popupMenu) {
|
||||||
return popupMenu._current.provider.getEntries(element);
|
return popupMenu._current.provider.getEntries(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function triggerAction(entries, id) {
|
||||||
|
var entry = find(entries, { id: id });
|
||||||
|
|
||||||
|
if (!entry) {
|
||||||
|
throw new Error('entry "'+ id +'" not found in replace menu');
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.action();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
describe('features/replace-menu', function() {
|
describe('features/replace-menu', function() {
|
||||||
|
|
||||||
|
@ -922,7 +932,8 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(conditionalFlowEntry).to.exist;
|
expect(conditionalFlowEntry).to.exist;
|
||||||
expect(entriesContainer.childNodes.length).to.equal(1);
|
|
||||||
|
expect(entriesContainer.childNodes).to.have.length(2);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
@ -963,8 +974,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
||||||
|
|
||||||
|
@ -982,10 +992,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
var replaceDefaultFlow = find(entries, { id: 'replace-with-default-flow' });
|
|
||||||
|
|
||||||
replaceDefaultFlow.action();
|
|
||||||
|
|
||||||
var task = elementRegistry.get('Task_1ei94kl');
|
var task = elementRegistry.get('Task_1ei94kl');
|
||||||
|
|
||||||
|
@ -1004,8 +1011,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
|
@ -1026,10 +1032,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
var replaceDefaultFlow = find(entries, { id: 'replace-with-default-flow' });
|
|
||||||
|
|
||||||
replaceDefaultFlow.action();
|
|
||||||
|
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
|
@ -1053,14 +1056,14 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
entries = getEntries(popupMenu);
|
entries = getEntries(popupMenu);
|
||||||
|
|
||||||
entries[0].action();
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
|
|
||||||
// trigger morphing sequenceFlow to default flow
|
// trigger morphing sequenceFlow to default flow
|
||||||
openPopup(sequenceFlow);
|
openPopup(sequenceFlow);
|
||||||
|
|
||||||
entries = getEntries(popupMenu);
|
entries = getEntries(popupMenu);
|
||||||
|
|
||||||
entries[0].action();
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
|
|
||||||
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
var gateway = elementRegistry.get('ExclusiveGateway_1');
|
||||||
|
|
||||||
|
@ -1077,10 +1080,9 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
openPopup(sequenceFlow);
|
openPopup(sequenceFlow);
|
||||||
|
|
||||||
var sequenceFlowEntries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
sequenceFlowEntries[0].action();
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.reconnectStart(sequenceFlow, task, [
|
modeling.reconnectStart(sequenceFlow, task, [
|
||||||
|
@ -1103,10 +1105,9 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
openPopup(sequenceFlow);
|
openPopup(sequenceFlow);
|
||||||
|
|
||||||
var sequenceFlowEntries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
sequenceFlowEntries[0].action();
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.reconnectStart(sequenceFlow, task, [
|
modeling.reconnectStart(sequenceFlow, task, [
|
||||||
|
@ -1135,10 +1136,9 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
openPopup(sequenceFlow);
|
openPopup(sequenceFlow);
|
||||||
|
|
||||||
var sequenceFlowEntries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
sequenceFlowEntries[0].action();
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
||||||
|
@ -1165,10 +1165,9 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
openPopup(sequenceFlow);
|
openPopup(sequenceFlow);
|
||||||
|
|
||||||
var sequenceFlowEntries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
sequenceFlowEntries[0].action();
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
||||||
|
@ -1195,8 +1194,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
var inclusiveGateway = bpmnReplace.replaceElement(exclusiveGateway, { type: 'bpmn:InclusiveGateway'});
|
var inclusiveGateway = bpmnReplace.replaceElement(exclusiveGateway, { type: 'bpmn:InclusiveGateway'});
|
||||||
|
|
||||||
|
@ -1238,8 +1236,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger DefaultFlow replacement
|
triggerAction(entries, 'replace-with-default-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
bpmnReplace.replaceElement(exclusiveGateway, { type: 'bpmn:InclusiveGateway'});
|
bpmnReplace.replaceElement(exclusiveGateway, { type: 'bpmn:InclusiveGateway'});
|
||||||
|
|
||||||
|
@ -1293,8 +1290,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger ConditionalFlow replacement
|
triggerAction(entries, 'replace-with-conditional-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(sequenceFlow.businessObject.conditionExpression.$type).to.equal('bpmn:FormalExpression');
|
expect(sequenceFlow.businessObject.conditionExpression.$type).to.equal('bpmn:FormalExpression');
|
||||||
|
@ -1310,8 +1306,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger ConditionalFlow replacement
|
triggerAction(entries, 'replace-with-conditional-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
commandStack.undo();
|
commandStack.undo();
|
||||||
|
|
||||||
|
@ -1330,12 +1325,14 @@ describe('features/replace-menu', function() {
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger ConditionalFlow replacement
|
// trigger ConditionalFlow replacement
|
||||||
entries[0].action();
|
triggerAction(entries, 'replace-with-conditional-flow');
|
||||||
|
|
||||||
var conditionalEntries = getEntries(popupMenu, sequenceFlow);
|
openPopup(sequenceFlow);
|
||||||
|
|
||||||
|
entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// replace with SequenceFlow
|
// replace with SequenceFlow
|
||||||
conditionalEntries[0].action();
|
triggerAction(entries, 'replace-with-sequence-flow');
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(sequenceFlow.businessObject.conditionExpression).to.not.exist;
|
expect(sequenceFlow.businessObject.conditionExpression).to.not.exist;
|
||||||
|
@ -1353,8 +1350,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger ConditionalFlow replacement
|
triggerAction(entries, 'replace-with-conditional-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.reconnectStart(sequenceFlow, startEvent, [
|
modeling.reconnectStart(sequenceFlow, startEvent, [
|
||||||
|
@ -1378,8 +1374,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger ConditionalFlow replacement
|
triggerAction(entries, 'replace-with-conditional-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.reconnectStart(sequenceFlow, startEvent, [
|
modeling.reconnectStart(sequenceFlow, startEvent, [
|
||||||
|
@ -1407,8 +1402,7 @@ describe('features/replace-menu', function() {
|
||||||
|
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger ConditionalFlow replacement
|
triggerAction(entries, 'replace-with-conditional-flow');
|
||||||
entries[0].action();
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
||||||
|
@ -1435,7 +1429,7 @@ describe('features/replace-menu', function() {
|
||||||
var entries = getEntries(popupMenu);
|
var entries = getEntries(popupMenu);
|
||||||
|
|
||||||
// trigger ConditionalFlow replacement
|
// trigger ConditionalFlow replacement
|
||||||
entries[0].action();
|
triggerAction(entries, 'replace-with-conditional-flow');
|
||||||
|
|
||||||
// when
|
// when
|
||||||
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
modeling.reconnectEnd(sequenceFlow, intermediateEvent, [
|
||||||
|
|
Loading…
Reference in New Issue