describe('should edit ID', function() {

      it('accept if valid', inject(function(sheet) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        // when
        triggerInputEvent(id, 'bar');

        // then
        const root = sheet.getRoot();

        expect(root.businessObject.$parent.id).to.equal('bar');
      }));


      it('undo edit', inject(function(sheet, commandStack) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        triggerInputEvent(id, 'bar');

        // when
        commandStack.undo();

        // then
        expect(id.textContent).to.equal('decision');
      }));


      it('reject if invalid', inject(function(sheet) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        // when
        triggerInputEvent(id, '!foo');

        // then
        const root = sheet.getRoot();

        expect(root.businessObject.$parent.id).to.equal('decision');
        expect(domClasses(id.parentNode).has('invalid')).to.be.true;
      }));

    });
Exemplo n.º 2
0
describe('IdUnclaimBehavior', function() {

  beforeEach(bootstrapModeler(diagramXML, {
    modules: [
      CoreModule,
      ModelingModule
    ]
  }));


  it('should unclaim ID on row.remove', inject(
    function(elementRegistry, moddle, modeling) {

      // given
      const row = elementRegistry.get('rule1');

      const { ids } = moddle;

      // when
      modeling.removeRow(row);

      // then
      expect(ids.assigned('rule1')).to.be.false;
      expect(ids.assigned('inputEntry1')).to.be.false;
      expect(ids.assigned('inputEntry2')).to.be.false;
      expect(ids.assigned('outputEntry1')).to.be.false;
      expect(ids.assigned('outputEntry2')).to.be.false;
    }
  ));


  it('should unclaim ID on col.remove', inject(
    function(elementRegistry, moddle, modeling) {

      // given
      const col = elementRegistry.get('input1');

      const { ids } = moddle;

      // when
      modeling.removeCol(col);

      // then
      expect(ids.assigned('input1')).to.be.false;
      expect(ids.assigned('inputEntry1')).to.be.false;
      expect(ids.assigned('inputEntry3')).to.be.false;
      expect(ids.assigned('inputEntry5')).to.be.false;
      expect(ids.assigned('inputEntry7')).to.be.false;
    }
  ));

});
Exemplo n.º 3
0
  describe('OutputClause', function() {

    it('should render', function() {

      // when
      const simpleBooleanEdit = openSimpleBooleanEdit('outputEntry1');

      // then
      expect(simpleBooleanEdit).to.exist;
    });


    it('should edit change true to false', inject(function(elementRegistry) {

      // given
      const outputEntry1 = elementRegistry.get('outputEntry1');

      const simpleBooleanEdit = openSimpleBooleanEdit('outputEntry1');

      const select = domQuery('.dms-input-select', simpleBooleanEdit);

      // when
      triggerInputSelectChange(select, 'false', testContainer);

      // then
      expect(outputEntry1.businessObject.text).to.equal('false');
    }));


    it('should edit change unparsable to false', inject(function(elementRegistry) {

      // given
      const outputEntry5 = elementRegistry.get('outputEntry5');

      const simpleBooleanEdit = openSimpleBooleanEdit('outputEntry5');

      const select = domQuery('.dms-input-select', simpleBooleanEdit);

      // when
      triggerInputSelectChange(select, 'false', testContainer);

      // then
      expect(outputEntry5.businessObject.text).to.equal('false');
    }));

  });
Exemplo n.º 4
0
describe('features/create-inputs', function() {

  beforeEach(bootstrapModeler(simpleXML, {
    modules: [
      CoreModule,
      CreateInputsModule,
      DecisionRulesModule,
      DecisionTableHeadModule,
      ModelingModule
    ]
  }));

  let testContainer;

  beforeEach(function() {
    testContainer = TestContainer.get(this);
  });


  it('should render if no inputs', function() {

    // then
    expect(domQueryAll('.create-inputs', testContainer)).to.have.length(2);
  });


  it('should add first input', inject(function(sheet) {

    // given
    const { businessObject } = sheet.getRoot();

    const cell = domQuery('.create-inputs', testContainer);

    // when
    triggerClick(cell);

    // then
    expect(businessObject.input).to.have.length(1);
  }));

});
Exemplo n.º 5
0
  describe('OutputClause', function() {

    let simpleNumberEdit,
        outputEntry9;

    beforeEach(inject(function(elementRegistry) {
      const cell = domQuery('[data-element-id="outputEntry9"]', testContainer);

      triggerClick(cell);

      const button = domQuery('.simple-mode-button', testContainer);

      triggerClick(button);

      simpleNumberEdit = domQuery('.simple-number-edit', testContainer);

      outputEntry9 = elementRegistry.get('outputEntry9');
    }));


    it('should render', function() {

      // then
      expect(simpleNumberEdit).to.exist;
    });


    it('should edit value', function() {

      // given
      const input = domQuery('.dms-input', simpleNumberEdit);

      // when
      triggerInputEvent(input, '42');

      // then
      expect(outputEntry9.businessObject.text).to.equal('42');
    });

  });
Exemplo n.º 6
0
    describe('comparison', function() {

      let simpleNumberEdit,
          inputEntry4;

      beforeEach(inject(function(elementRegistry) {
        const cell = domQuery('[data-element-id="inputEntry4"]', testContainer);

        triggerClick(cell);

        const button = domQuery('.simple-mode-button', testContainer);

        triggerClick(button);

        simpleNumberEdit = domQuery('.simple-number-edit', testContainer);

        inputEntry4 = elementRegistry.get('inputEntry4');
      }));


      it('should render', function() {

        // then
        expect(simpleNumberEdit).to.exist;
      });


      it('should set to range', function() {

        // given
        const select = domQuery('.dms-input-select', simpleNumberEdit);

        // when
        triggerInputSelectChange(select, 'range', testContainer);

        // then
        expect(inputEntry4.businessObject.text).to.equal('[0..0]');
      });


      it('should set to comparison restoring previously set comparison', function() {

        // given
        const select = domQuery('.dms-input-select', simpleNumberEdit);

        triggerInputSelectChange(select, 'range', testContainer);

        // when
        triggerInputSelectChange(select, 'comparison', testContainer);

        // then
        expect(inputEntry4.businessObject.text).to.equal('< 1000');
      });


      it('should edit operator', function() {

        // given
        const select = domQueryAll('.dms-input-select', simpleNumberEdit)[1];

        // when
        triggerInputSelectChange(select, 'greater', testContainer);

        // then
        expect(inputEntry4.businessObject.text).to.equal('> 1000');
      });


      it('should edit value', function() {

        // given
        const input = domQuery('.comparison-number-input', simpleNumberEdit);

        // when
        triggerInputEvent(input, '42');

        // then
        expect(inputEntry4.businessObject.text).to.equal('< 42');
      });

    });
Exemplo n.º 7
0
    describe('range', function() {

      let simpleNumberEdit,
          inputEntry2;

      beforeEach(inject(function(elementRegistry) {
        const cell = domQuery('[data-element-id="inputEntry2"]', testContainer);

        triggerClick(cell);

        const button = domQuery('.simple-mode-button', testContainer);

        triggerClick(button);

        simpleNumberEdit = domQuery('.simple-number-edit', testContainer);

        inputEntry2 = elementRegistry.get('inputEntry2');
      }));


      it('should render', function() {

        // then
        expect(simpleNumberEdit).to.exist;
      });


      it('should set to comparison', function() {

        // given
        const select = domQuery('.dms-input-select', simpleNumberEdit);

        // when
        triggerInputSelectChange(select, 'comparison', testContainer);

        // then
        expect(inputEntry2.businessObject.text).to.equal('0');
      });


      it('should set to range restoring previously set range', function() {

        // given
        const select = domQuery('.dms-input-select', simpleNumberEdit);

        triggerInputSelectChange(select, 'comparison');

        // when
        triggerInputSelectChange(select, 'range', testContainer);

        // then
        expect(inputEntry2.businessObject.text).to.equal('[10..20[');
      });


      it('should edit range start type', function() {

        // given
        const select = domQueryAll('.dms-input-select', simpleNumberEdit)[1];

        // when
        triggerInputSelectChange(select, 'exclude', testContainer);

        // then
        expect(inputEntry2.businessObject.text).to.equal(']10..20[');
      });


      it('should edit range start value', function() {

        // given
        const input = domQuery('.range-start-number-input', simpleNumberEdit);

        // when
        triggerInputEvent(input, '42');

        // then
        expect(inputEntry2.businessObject.text).to.equal('[42..20[');
      });


      it('should edit range end type', function() {

        // given
        const select = domQueryAll('.dms-input-select', simpleNumberEdit)[2];

        // when
        triggerInputSelectChange(select, 'include', testContainer);

        // then
        expect(inputEntry2.businessObject.text).to.equal('[10..20]');
      });


      it('should edit range end value', function() {

        // given
        const input = domQuery('.range-end-number-input', simpleNumberEdit);

        // when
        triggerInputEvent(input, '42');

        // then
        expect(inputEntry2.businessObject.text).to.equal('[10..42[');
      });

    });
Exemplo n.º 8
0
describe('annotations editor', function() {

  beforeEach(bootstrapModeler(simpleXML, {
    modules: [
      AnnotationsEditorModule,
      CoreModule,
      DecisionTableHeadModule,
      ModelingModule,
      DecisionRulesModule
    ],
    debounceInput: false
  }));

  let testContainer;

  beforeEach(function() {
    testContainer = TestContainer.get(this);
  });


  it('should render annotation head cell', function() {

    // then
    expect(domQuery('th.annotation', testContainer)).to.exist;
  });


  it('should render annotation cells', function() {

    // then
    const cells = domQueryAll('td.annotation', testContainer);

    expect(cells).to.have.lengthOf(4);
    expect(cells[0].textContent).to.equal('Bronze is really not that good');
    expect(cells[1].textContent).to.equal('Silver is actually quite okay');
    expect(cells[2].textContent).to.equal('Same here');
    expect(cells[3].textContent).to.equal(
      'Gold is really good, try even harder next time though'
    );
  });


  it('should edit annotation', inject(function(sheet) {

    // given
    const cell = queryEditor('td.annotation', testContainer);

    // when
    cell.focus();

    triggerInputEvent(cell, 'foo');

    // then
    const root = sheet.getRoot();

    const rule = root.businessObject.rule[0];

    expect(rule.description).to.equal('foo');
  }));


  it('should edit annotation - line break', inject(function(sheet) {

    // given
    const cell = queryEditor('td.annotation', testContainer);

    // when
    cell.focus();

    triggerInputEvent(cell, 'foo<br>bar<br>');

    cell.blur();

    // then
    const root = sheet.getRoot();

    const rule = root.businessObject.rule[0];

    expect(rule.description).to.equal('foo\nbar');

    expect(cell.innerHTML).to.equal('foo<br>bar<br>');
  }));

});
Exemplo n.º 9
0
describe('decision table head', function() {

  beforeEach(bootstrapViewer(simpleXML, {
    modules: [
      CoreModule,
      DecisionTableHeadModule
    ]
  }));

  let testContainer;

  beforeEach(function() {
    testContainer = TestContainer.get(this);
  });


  it('should render head', function() {

    // then
    expect(domQuery('thead', testContainer)).to.exist;
  });


  it('should render header input cells with a [data-col-id] attribute', function() {

    // then
    expect(domQuery('[data-col-id]', testContainer)).to.exist;
  });


  it('should render input label', function() {

    // then
    expect(domQuery('.inputs-label', testContainer)).to.exist;
  });


  it('should render output label', function() {

    // then
    expect(domQuery('.outputs-label', testContainer)).to.exist;
  });


  it('should allow rendering before labels', inject(
    function(components, eventBus, sheet) {

      // given
      components.onGetComponent('cell', ({ cellType }) => {
        if (cellType === 'before-label-cells') {
          return () => <td className="foo">FOO</td>;
        }
      });

      const root = sheet.getRoot();

      // when
      eventBus.fire('elements.changed', { elements: [ root ] });

      // then
      expect(domQuery('.foo', testContainer)).to.exist;
    }
  ));


  it('should allow rendering after labels', inject(function(components, eventBus, sheet) {

    // given
    components.onGetComponent('cell', ({ cellType }) => {
      if (cellType === 'after-label-cells') {
        return () => <td className="foo">FOO</td>;
      }
    });

    const root = sheet.getRoot();

    // when
    eventBus.fire('elements.changed', { elements: [ root ] });

    // then
    expect(domQuery('.foo', testContainer)).to.exist;
  }));

});
Exemplo n.º 10
0
describe('context menu close behavior', function() {

  beforeEach(bootstrapModeler(simpleXML, {
    modules: [
      ContextMenuModule,
      CoreModule,
      InteractionEventsModule,
      ModelingModule,
      DecisionRulesModule
    ]
  }));

  let testContainer;

  beforeEach(function() {
    testContainer = TestContainer.get(this);
  });


  it('should close on commandstack.executed', inject(function(eventBus) {

    // given
    const cell = domQuery('[data-element-id="inputEntry1"]', testContainer);

    triggerMouseEvent(cell, 'contextmenu');

    // when
    eventBus.fire('commandStack.executed', {
      command: 'row.add'
    });

    // then
    expect(domQuery('.context-menu', testContainer)).to.not.exist;
  }));


  it('should NOT close on commandstack.executed', inject(function(eventBus) {

    // given
    const cell = domQuery('[data-element-id="inputEntry1"]', testContainer);

    triggerMouseEvent(cell, 'contextmenu');

    // when
    eventBus.fire('commandStack.executed', {
      command: 'foo'
    });

    // then
    expect(domQuery('.context-menu', testContainer)).to.exist;
  }));


  it('should close on commandstack.reverted', inject(function(eventBus) {

    // given
    const cell = domQuery('[data-element-id="inputEntry1"]', testContainer);

    triggerMouseEvent(cell, 'contextmenu');

    // when
    eventBus.fire('commandStack.reverted');

    // then
    expect(domQuery('.context-menu', testContainer)).to.not.exist;
  }));

});
Exemplo n.º 11
0
describe('decision properties editor', function() {

  beforeEach(bootstrapModeler(literalExpressionXML, {
    modules: [
      CoreModule,
      DecisionPropertiesEditorModule,
      ModelingModule
    ],
    debounceInput: false
  }));

  let testContainer;

  beforeEach(function() {
    testContainer = TestContainer.get(this);
  });


  it('should render', function() {

    // then
    expect(domQuery('.decision-properties', testContainer)).to.exist;
  });


  it('should edit decision name', inject(function(viewer) {

    // given
    const editor = queryEditor('.decision-name', testContainer);

    editor.focus();

    // when
    triggerInputEvent(editor, 'foo');

    // then
    expect(viewer.getDecision().name).to.equal('foo');
  }));


  it('should edit decision id', inject(function(viewer) {

    // given
    const editor = queryEditor('.decision-id', testContainer);

    editor.focus();

    // when
    triggerInputEvent(editor, 'foo');

    // then
    expect(viewer.getDecision().id).to.equal('foo');
  }));


  it('should validate decision id', inject(function(viewer) {

    // given
    const decisionId = domQuery('.decision-id', testContainer);
    const editor = queryEditor('.decision-id', testContainer);

    editor.focus();

    // when
    triggerInputEvent(editor, 'foo bar');

    // then
    expect(viewer.getDecision().id).to.equal('season');

    expect(domClasses(decisionId).has('invalid')).to.be.true;
  }));

});
Exemplo n.º 12
0
describe('expression language', function() {

  beforeEach(bootstrapModeler(simpleXML, {
    modules: [
      ContextMenuModule,
      CoreModule,
      ExpressionLanguageModule,
      InteractionEventsModule,
      ModelingModule,
      DecisionRulesEditorModule,
      KeyboardModule
    ],
    debounceInput: false
  }));

  let testContainer;

  beforeEach(function() {
    testContainer = TestContainer.get(this);
  });

  function openContextMenu(elementId, elementRegistry) {
    const cell = domQuery(`[data-element-id="${ elementId }"]`, testContainer);

    triggerMouseEvent(cell, 'contextmenu');

    return domQuery('.expression-language', testContainer);
  }


  it('should edit expression language - input', inject(function(elementRegistry) {

    // given
    const inputSelect = openContextMenu('inputEntry1');

    const input = domQuery('.dms-input', inputSelect);

    // when
    triggerInputEvent(input, 'foo');

    // then
    const expressionLanguage =
      elementRegistry.get('inputEntry1').businessObject.expressionLanguage;

    expect(expressionLanguage).to.equal('foo');
  }));


  it('should edit expression language - select', inject(function(elementRegistry) {

    // given
    const inputSelect = openContextMenu('inputEntry1');

    // when
    triggerInputSelectChange(inputSelect, 'javascript', testContainer);

    // then
    const expressionLanguage =
      elementRegistry.get('inputEntry1').businessObject.expressionLanguage;

    expect(expressionLanguage).to.equal('javascript');
  }));

});
  describe('decision table property editing', function() {

    it('should edit name', inject(function(sheet) {

      // given
      const name = queryEditor('.decision-table-name', testContainer);

      name.focus();

      // when
      triggerInputEvent(name, 'foo');

      // then
      const root = sheet.getRoot();

      expect(root.businessObject.$parent.name).to.equal('foo');
    }));


    it('should edit name - line breaks', inject(function(sheet) {

      // given
      const name = queryEditor('.decision-table-name', testContainer);

      name.focus();

      // when
      triggerInputEvent(name, 'foo<br>bar<br>');

      name.blur();

      // then
      const root = sheet.getRoot();

      expect(root.businessObject.$parent.name).to.equal('foo\nbar');

      expect(name.innerHTML).to.equal('foo<br>bar<br>');
    }));


    describe('should edit ID', function() {

      it('accept if valid', inject(function(sheet) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        // when
        triggerInputEvent(id, 'bar');

        // then
        const root = sheet.getRoot();

        expect(root.businessObject.$parent.id).to.equal('bar');
      }));


      it('undo edit', inject(function(sheet, commandStack) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        triggerInputEvent(id, 'bar');

        // when
        commandStack.undo();

        // then
        expect(id.textContent).to.equal('decision');
      }));


      it('reject if invalid', inject(function(sheet) {

        // given
        const id = queryEditor('.decision-table-id', testContainer);

        id.focus();

        // when
        triggerInputEvent(id, '!foo');

        // then
        const root = sheet.getRoot();

        expect(root.businessObject.$parent.id).to.equal('decision');
        expect(domClasses(id.parentNode).has('invalid')).to.be.true;
      }));

    });

  });
Exemplo n.º 14
0
describe('description', function() {

  beforeEach(bootstrapModeler(simpleBooleanEditXML, {
    modules: [
      CoreModule,
      CellSelectionModule,
      ModelingModule,
      DecisionRulesEditorModule,
      DescriptionModule,
      ContextMenuModule
    ],
    debounceInput: false
  }));

  let testContainer;

  beforeEach(function() {
    testContainer = TestContainer.get(this);
  });

  function openDescriptionEditor(elementId) {
    const cellEl = domQuery(`[data-element-id="${ elementId }"]`, testContainer);

    expect(cellEl).to.exist;

    triggerClick(cellEl);

    const editorEl = queryEditor('.description-editor', testContainer);

    expect(editorEl).to.exist;

    return editorEl;
  }

  function clickContextMenuEntry(elementId, className) {
    const cell = domQuery(`[data-element-id="${ elementId }"]`, testContainer);

    triggerMouseEvent(cell, 'contextmenu');

    const contextmenu = domQuery('.context-menu', testContainer);

    const contextMenuEntry = domQuery(className, contextmenu);

    triggerClick(contextMenuEntry);
  }

  function hasDescriptionIndicator(elementId) {
    const cell = domQuery(`[data-element-id="${ elementId }"]`, testContainer);

    return !!domQuery('.description-indicator', cell);
  }


  it('should add description', inject(function(elementRegistry) {

    // given
    const inputEntry1 = elementRegistry.get('inputEntry1');

    // when
    clickContextMenuEntry('inputEntry1', '.add-description');

    // then
    expect(inputEntry1.businessObject.description).to.equal('');

    expect(hasDescriptionIndicator('inputEntry1')).to.be.true;
  }));


  it('should edit description', inject(function(elementRegistry) {

    // given
    const inputEntry2 = elementRegistry.get('inputEntry2');

    // when
    const editor = openDescriptionEditor('inputEntry2');

    triggerInputEvent(editor, 'bar');

    // then
    expect(inputEntry2.businessObject.description).to.equal('bar');
  }));


  it('should remove description if empty', inject(function(elementRegistry) {

    // given
    const inputEntry2 = elementRegistry.get('inputEntry2');

    const cell = domQuery('[data-element-id="inputEntry1"]', testContainer);

    // when
    const editor = openDescriptionEditor('inputEntry2');

    triggerInputEvent(editor, '');

    triggerClick(cell);

    // then
    expect(inputEntry2.businessObject.description).to.not.exist;

    expect(hasDescriptionIndicator('inputEntry2')).to.be.false;
  }));


  it('should remove description', inject(function(elementRegistry) {

    // given
    const inputEntry2 = elementRegistry.get('inputEntry2');

    // when
    clickContextMenuEntry('inputEntry2', '.remove-description');

    // then
    expect(inputEntry2.businessObject.description).to.not.exist;

    expect(hasDescriptionIndicator('inputEntry2')).to.be.false;
  }));

});