diff --git a/docs/translations.json b/docs/translations.json index a5819d5daf..7759b6d841 100644 --- a/docs/translations.json +++ b/docs/translations.json @@ -4,12 +4,22 @@ "Activate the hand tool", "Activate the lasso tool", "Ad-hoc", + "Add Lane above", + "Add Lane below", + "Append ConditionIntermediateCatchEvent", + "Append EndEvent", + "Append Gateway", + "Append Intermediate/Boundary Event", + "Append MessageIntermediateCatchEvent", + "Append ReceiveTask", + "Append SignalIntermediateCatchEvent", + "Append Task", + "Append TimerIntermediateCatchEvent", "Append compensation activity", "Append {type}", "Business Rule Task", "Call Activity", "Cancel Boundary Event", - "Cancel End Event", "Change type", "Compensation Boundary Event", "Compensation End Event", @@ -25,11 +35,19 @@ "Connect using Association", "Connect using DataInputAssociation", "Connect using Sequence/MessageFlow or Association", - "Create IntermediateThrowEvent/BoundaryEvent", + "Create DataObjectReference", + "Create DataStoreReference", + "Create EndEvent", + "Create Gateway", + "Create Group", + "Create Intermediate/Boundary Event", "Create Pool/Participant", + "Create StartEvent", + "Create Task", "Create expanded SubProcess", - "Create {type}", "Default Flow", + "Divide into three Lanes", + "Divide into two Lanes", "End Event", "Error Boundary Event", "Error End Event", @@ -41,8 +59,8 @@ "Escalation Start Event", "Escalation Start Event (non-interrupting)", "Event Sub Process", + "Event based Gateway", "Exclusive Gateway", - "HELLO {you}!", "Inclusive Gateway", "Intermediate Throw Event", "Link Intermediate Catch Event", @@ -93,6 +111,5 @@ "multiple DI elements defined for {element}", "no bpmnElement referenced in {element}", "no diagram to display", - "no process or collaboration to display", - "participants cannot be pasted onto a non-empty process diagram" + "no process or collaboration to display" ] \ No newline at end of file diff --git a/lib/features/modeling/behavior/ModelingFeedback.js b/lib/features/modeling/behavior/ModelingFeedback.js index 18e98c1824..083af51ecb 100644 --- a/lib/features/modeling/behavior/ModelingFeedback.js +++ b/lib/features/modeling/behavior/ModelingFeedback.js @@ -1,8 +1,6 @@ import { is } from '../../../util/ModelUtil'; -var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants', - PROCESS_ERR_MSG = 'participants cannot be pasted onto a non-empty process diagram'; - +var COLLAB_ERR_MSG = 'flow elements must be children of pools/participants'; export default function ModelingFeedback(eventBus, tooltips, translate) { @@ -28,19 +26,6 @@ export default function ModelingFeedback(eventBus, tooltips, translate) { } }); - eventBus.on([ 'elements.paste.rejected' ], function(event) { - var context = event.context, - position = context.position, - target = context.target; - - if (is(target, 'bpmn:Collaboration')) { - showError(position, translate(COLLAB_ERR_MSG)); - } - - if (is(target, 'bpmn:Process')) { - showError(position, translate(PROCESS_ERR_MSG), 3000); - } - }); } ModelingFeedback.$inject = [ diff --git a/package.json b/package.json index f0fdda83bf..594b563537 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dev": "npm test -- --auto-watch --no-single-run", "test": "karma start test/config/karma.unit.js", "distro": "node tasks/build-distro.js", + "collect-translations": "COLLECT_TRANSLATIONS=1 npm test", "test:distro": "node tasks/test-distro.js", "preversion": "run-s distro test:distro" }, diff --git a/test/config/karma.unit.js b/test/config/karma.unit.js index ddd9a13c40..9b82b1781d 100644 --- a/test/config/karma.unit.js +++ b/test/config/karma.unit.js @@ -2,6 +2,8 @@ var path = require('path'); +var collectTranslations = process.env.COLLECT_TRANSLATIONS; + var coverage = process.env.COVERAGE; // configures browsers to run test against @@ -19,7 +21,8 @@ var suite = coverage ? 'test/coverageBundle.js' : 'test/testBundle.js'; module.exports = function(karma) { - karma.set({ + + var config = { basePath, @@ -86,5 +89,16 @@ module.exports = function(karma) { }, devtool: 'eval-source-map' } - }); + }; + + if (collectTranslations) { + config.plugins = [].concat(config.plugins || [], 'karma-*', require('./translation-reporter')); + config.reporters = [].concat(config.reporters || [], 'translation-reporter'); + + config.envPreprocessor = [ + 'TRANSLATIONS' + ]; + } + + karma.set(config); }; diff --git a/test/config/translation-reporter.js b/test/config/translation-reporter.js index 4bd57e1675..b407bd8108 100644 --- a/test/config/translation-reporter.js +++ b/test/config/translation-reporter.js @@ -10,7 +10,7 @@ var { function TranslationReporter() { process.env.TRANSLATIONS = 'enabled'; - var outputFile = path.join(__dirname, '../../docs/translations.json'); + var translationsFile = path.join(__dirname, '../../docs/translations.json'); var translations = []; @@ -38,10 +38,10 @@ function TranslationReporter() { this.onRunComplete = function() { - translations = uniqueBy(function(e) {return e;}, translations); - translations = sortBy(translations, function(e) {return e;}); + translations = uniqueBy(function(e) { return e; }, translations); + translations = sortBy(translations, function(e) { return e; }); - fs.writeFileSync(outputFile, JSON.stringify(translations, null, 2)); + fs.writeFileSync(translationsFile, JSON.stringify(translations, null, 2)); }; } diff --git a/test/fixtures/bpmn/error/no-process-collaboration.bpmn b/test/fixtures/bpmn/error/no-process-collaboration.bpmn new file mode 100644 index 0000000000..0bc703f98c --- /dev/null +++ b/test/fixtures/bpmn/error/no-process-collaboration.bpmn @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/test/helper/index.js b/test/helper/index.js index 46c28b84e3..a9f97a861f 100644 --- a/test/helper/index.js +++ b/test/helper/index.js @@ -39,12 +39,22 @@ import { import TestContainer from 'mocha-test-container-support'; import Modeler from '../../lib/Modeler'; +import NavigatedViewer from '../../lib/NavigatedViewer'; import Viewer from '../../lib/Viewer'; var OPTIONS, BPMN_JS; import translationModule from './TranslationCollector'; +export var collectTranslations = window.__env__ && window.__env__.TRANSLATIONS === 'enabled'; + +// inject logging translation module into default modules +if (collectTranslations) { + + [ Modeler, Viewer, NavigatedViewer ].forEach(function(constructor) { + constructor.prototype._modules.push(translationModule); + }); +} export function bootstrapBpmnJS(BpmnJS, diagram, options, locals) { @@ -105,7 +115,7 @@ export function bootstrapBpmnJS(BpmnJS, diagram, options, locals) { } // used to extract translations used during tests - if (window.__env__ && window.__env__.TRANSLATIONS === 'enabled') { + if (collectTranslations) { _options.additionalModules = [].concat( _options.additionalModules || [], [ translationModule ] @@ -278,4 +288,4 @@ export function insertCSS(name, css) { } head.appendChild(style); -} +} \ No newline at end of file diff --git a/test/spec/ModelerSpec.js b/test/spec/ModelerSpec.js index 0730b4cc96..0afd5eb01a 100644 --- a/test/spec/ModelerSpec.js +++ b/test/spec/ModelerSpec.js @@ -10,7 +10,8 @@ import { import { setBpmnJS, - clearBpmnJS + clearBpmnJS, + collectTranslations } from 'test/TestHelper'; @@ -156,7 +157,7 @@ describe('Modeler', function() { }); - describe('translate support', function() { + !collectTranslations && describe('translate support', function() { var xml = require('../fixtures/bpmn/simple.bpmn'); diff --git a/test/spec/ViewerSpec.js b/test/spec/ViewerSpec.js index c9b337d7ab..3840fc5c46 100644 --- a/test/spec/ViewerSpec.js +++ b/test/spec/ViewerSpec.js @@ -268,6 +268,21 @@ describe('Viewer', function() { }); }); + + it('should handle missing process/collaboration', function() { + + var xml = require('../fixtures/bpmn/error/no-process-collaboration.bpmn'); + + // when + return createViewer(container, Viewer, xml).then(function(result) { + + var err = result.error; + + // then + expect(err.message).to.eql('no process or collaboration to display'); + }); + }); + }); diff --git a/test/spec/features/modeling/behavior/ModelingFeedback.bpmn b/test/spec/features/modeling/behavior/ModelingFeedback.bpmn new file mode 100644 index 0000000000..b2b1a4d42f --- /dev/null +++ b/test/spec/features/modeling/behavior/ModelingFeedback.bpmn @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/test/spec/features/modeling/behavior/ModelingFeedbackSpec.js b/test/spec/features/modeling/behavior/ModelingFeedbackSpec.js new file mode 100644 index 0000000000..4faddf1683 --- /dev/null +++ b/test/spec/features/modeling/behavior/ModelingFeedbackSpec.js @@ -0,0 +1,57 @@ +import { + bootstrapModeler, + getBpmnJS, + inject +} from 'test/TestHelper'; + +import { + createCanvasEvent as canvasEvent +} from 'test/util/MockEvents'; + +import coreModule from 'lib/core'; +import modelingModule from 'lib/features/modeling'; + + +describe('features/modeling - ModelingFeedback', function() { + + var collaborationDiagramXML = require('./ModelingFeedback.bpmn'); + + beforeEach(bootstrapModeler(collaborationDiagramXML, { + modules: [ + coreModule, + modelingModule + ] + })); + + + it('should indicate', inject(function(create, canvas, elementFactory, dragging) { + + // given + var task = elementFactory.createShape({ type: 'bpmn:Task' }); + + var collaboration = canvas.getRootElement(); + var collaborationGfx = canvas.getGraphics(collaboration); + + create.start(canvasEvent({ x: 100, y: 100 }), task); + dragging.hover({ element: collaboration, gfx: collaborationGfx }); + + // when + dragging.end(); + + // then + expectTooltip('error', 'flow elements must be children of pools/participants'); + })); + +}); + + +function expectTooltip(cls, message) { + + return getBpmnJS().invoke(function(canvas) { + + var tooltipEl = document.querySelector('[data-tooltip-id]', canvas.getContainer()); + + expect(tooltipEl.textContent).to.eql(message); + expect(tooltipEl.classList.contains(cls)); + }); +} \ No newline at end of file