bpmn-js 0.20.6 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +33 -33
- package/.npmignore +8 -8
- package/.travis.yml +19 -17
- package/.wiredeps +88 -88
- package/CONTRIBUTING.md +55 -55
- package/Gruntfile.js +129 -129
- package/LICENSE +22 -22
- package/README.md +113 -113
- package/assets/bpmn-font/css/bpmn-embedded.css +159 -159
- package/assets/bpmn-font/css/bpmn.css +161 -161
- package/assets/bpmn-font/font/bpmn.svg +116 -116
- package/docs/architecture/overview.svg +48 -48
- package/docs/project/COMMIT_MESSAGES.md +82 -82
- package/docs/project/SETUP.md +66 -66
- package/docs/project/setup-alternative.sh +41 -41
- package/docs/project/setup.bat +45 -45
- package/docs/project/setup.sh +40 -40
- package/docs/translations.json +97 -97
- package/lib/Modeler.js +208 -208
- package/lib/NavigatedViewer.js +27 -27
- package/lib/Viewer.js +503 -503
- package/lib/core/index.js +5 -5
- package/lib/draw/BpmnRenderer.js +1934 -1934
- package/lib/draw/PathMap.js +478 -478
- package/lib/draw/index.js +5 -5
- package/lib/features/auto-resize/BpmnAutoResize.js +34 -34
- package/lib/features/auto-resize/BpmnAutoResizeProvider.js +51 -51
- package/lib/features/auto-resize/index.js +5 -5
- package/lib/features/context-pad/ContextPadProvider.js +374 -374
- package/lib/features/context-pad/index.js +11 -11
- package/lib/features/copy-paste/BpmnCopyPaste.js +157 -154
- package/lib/features/copy-paste/index.js +7 -7
- package/lib/features/distribute-elements/BpmnDistributeElements.js +34 -34
- package/lib/features/distribute-elements/index.js +7 -7
- package/lib/features/editor-actions/BpmnEditorActions.js +130 -130
- package/lib/features/editor-actions/index.js +15 -15
- package/lib/features/global-connect/BpmnGlobalConnect.js +49 -49
- package/lib/features/global-connect/index.js +7 -7
- package/lib/features/keyboard/BpmnKeyBindings.js +72 -72
- package/lib/features/keyboard/index.js +7 -7
- package/lib/features/label-editing/LabelEditingPreview.js +122 -0
- package/lib/features/label-editing/LabelEditingProvider.js +292 -193
- package/lib/features/label-editing/LabelUtil.js +43 -43
- package/lib/features/label-editing/cmd/UpdateLabelHandler.js +116 -112
- package/lib/features/label-editing/index.js +14 -9
- package/lib/features/modeling/BpmnFactory.js +97 -97
- package/lib/features/modeling/BpmnLayouter.js +191 -191
- package/lib/features/modeling/BpmnUpdater.js +692 -688
- package/lib/features/modeling/ElementFactory.js +218 -218
- package/lib/features/modeling/Modeling.js +183 -183
- package/lib/features/modeling/behavior/AppendBehavior.js +42 -42
- package/lib/features/modeling/behavior/CopyPasteBehavior.js +69 -69
- package/lib/features/modeling/behavior/CreateBoundaryEventBehavior.js +51 -51
- package/lib/features/modeling/behavior/CreateDataObjectBehavior.js +37 -37
- package/lib/features/modeling/behavior/CreateParticipantBehavior.js +91 -91
- package/lib/features/modeling/behavior/DataInputAssociationBehavior.js +151 -151
- package/lib/features/modeling/behavior/DeleteLaneBehavior.js +107 -107
- package/lib/features/modeling/behavior/DropOnFlowBehavior.js +165 -131
- package/lib/features/modeling/behavior/ImportDockingFix.js +80 -80
- package/lib/features/modeling/behavior/LabelBehavior.js +222 -222
- package/lib/features/modeling/behavior/ModelingFeedback.js +50 -50
- package/lib/features/modeling/behavior/RemoveElementBehavior.js +73 -73
- package/lib/features/modeling/behavior/RemoveParticipantBehavior.js +50 -50
- package/lib/features/modeling/behavior/ReplaceConnectionBehavior.js +128 -128
- package/lib/features/modeling/behavior/ReplaceElementBehaviour.js +118 -116
- package/lib/features/modeling/behavior/ResizeLaneBehavior.js +59 -59
- package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.js +138 -138
- package/lib/features/modeling/behavior/UnclaimIdBehavior.js +27 -27
- package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.js +54 -54
- package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.js +156 -156
- package/lib/features/modeling/behavior/index.js +44 -44
- package/lib/features/modeling/behavior/util/GeometricUtil.js +129 -129
- package/lib/features/modeling/behavior/util/LabelLayoutUtil.js +218 -218
- package/lib/features/modeling/behavior/util/LineAttachmentUtil.js +233 -233
- package/lib/features/modeling/behavior/util/LineIntersect.js +36 -36
- package/lib/features/modeling/cmd/AddLaneHandler.js +83 -83
- package/lib/features/modeling/cmd/IdClaimHandler.js +41 -41
- package/lib/features/modeling/cmd/ResizeLaneHandler.js +125 -125
- package/lib/features/modeling/cmd/SplitLaneHandler.js +82 -82
- package/lib/features/modeling/cmd/UpdateCanvasRootHandler.js +78 -78
- package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.js +185 -185
- package/lib/features/modeling/cmd/UpdatePropertiesHandler.js +264 -264
- package/lib/features/modeling/index.js +23 -23
- package/lib/features/modeling/util/LaneUtil.js +157 -157
- package/lib/features/modeling/util/ModelingUtil.js +48 -48
- package/lib/features/ordering/BpmnOrderingProvider.js +147 -147
- package/lib/features/ordering/index.js +6 -6
- package/lib/features/palette/PaletteProvider.js +158 -158
- package/lib/features/palette/index.js +13 -13
- package/lib/features/popup-menu/ReplaceMenuProvider.js +479 -479
- package/lib/features/popup-menu/index.js +7 -7
- package/lib/features/popup-menu/util/TypeUtil.js +41 -41
- package/lib/features/replace/BpmnReplace.js +197 -197
- package/lib/features/replace/ReplaceOptions.js +787 -787
- package/lib/features/replace/index.js +7 -7
- package/lib/features/replace-preview/BpmnReplacePreview.js +113 -113
- package/lib/features/replace-preview/index.js +5 -5
- package/lib/features/rules/BpmnRules.js +807 -806
- package/lib/features/rules/index.js +7 -7
- package/lib/features/search/BpmnSearchProvider.js +128 -128
- package/lib/features/search/index.js +7 -7
- package/lib/features/snapping/BpmnSnapping.js +511 -495
- package/lib/features/snapping/BpmnSnappingUtil.js +159 -159
- package/lib/features/snapping/index.js +3 -3
- package/lib/import/BpmnImporter.js +302 -302
- package/lib/import/BpmnTreeWalker.js +445 -445
- package/lib/import/Importer.js +69 -69
- package/lib/import/Util.js +8 -8
- package/lib/import/index.js +5 -5
- package/lib/util/DiUtil.js +60 -60
- package/lib/util/LabelUtil.js +139 -139
- package/lib/util/ModelUtil.js +31 -31
- package/lib/util/PoweredByUtil.js +82 -82
- package/lib/util/model/ModelCloneHelper.js +201 -201
- package/lib/util/model/ModelCloneUtils.js +35 -35
- package/package.json +22 -22
- package/resources/initial.bpmn +12 -12
- package/resources/screencast.gif +0 -0
- package/tasks/banner.txt +11 -11
- package/tasks/bundle.js +162 -162
- package/test/TestHelper.js +17 -17
- package/test/config/karma.unit.js +46 -46
- package/test/config/translation-reporter.js +48 -48
- package/test/fixtures/bpmn/align-elements.bpmn +136 -136
- package/test/fixtures/bpmn/basic.bpmn +17 -17
- package/test/fixtures/bpmn/boundary-events.bpmn +59 -59
- package/test/fixtures/bpmn/collaboration/collaboration-empty-participant.bpmn +13 -13
- package/test/fixtures/bpmn/collaboration/collaboration-message-flows.bpmn +89 -89
- package/test/fixtures/bpmn/collaboration/collaboration-participant.bpmn +59 -59
- package/test/fixtures/bpmn/collaboration/process-empty.bpmn +6 -6
- package/test/fixtures/bpmn/collaboration/process.bpmn +47 -47
- package/test/fixtures/bpmn/collaboration-data-items.bpmn +81 -81
- package/test/fixtures/bpmn/collaboration-message-flows.bpmn +82 -82
- package/test/fixtures/bpmn/collaboration-sequence-flows.bpmn +83 -83
- package/test/fixtures/bpmn/collaboration.bpmn +50 -50
- package/test/fixtures/bpmn/complex.bpmn +2151 -2151
- package/test/fixtures/bpmn/conditions.bpmn +82 -82
- package/test/fixtures/bpmn/containers.bpmn +128 -128
- package/test/fixtures/bpmn/distribute-elements-filtering.bpmn +58 -58
- package/test/fixtures/bpmn/distribute-elements.bpmn +232 -232
- package/test/fixtures/bpmn/draw/activity-markers-combination.bpmn +141 -141
- package/test/fixtures/bpmn/draw/activity-markers-simple.bpmn +47 -47
- package/test/fixtures/bpmn/draw/activity-markers.bpmn +212 -212
- package/test/fixtures/bpmn/draw/associations.bpmn +55 -55
- package/test/fixtures/bpmn/draw/boundary-event-with-refnode.bpmn +81 -81
- package/test/fixtures/bpmn/draw/boundary-event-without-refnode.bpmn +81 -81
- package/test/fixtures/bpmn/draw/boundary-event-z-index.bpmn +82 -82
- package/test/fixtures/bpmn/draw/call-activity.bpmn +12 -12
- package/test/fixtures/bpmn/draw/colors.bpmn +411 -411
- package/test/fixtures/bpmn/draw/conditional-flow-default.bpmn +100 -100
- package/test/fixtures/bpmn/draw/conditional-flow-gateways.bpmn +72 -72
- package/test/fixtures/bpmn/draw/conditional-flow-typed-task.bpmn +33 -33
- package/test/fixtures/bpmn/draw/conditional-flow.bpmn +248 -248
- package/test/fixtures/bpmn/draw/data-objects.bpmn +265 -265
- package/test/fixtures/bpmn/draw/event-subprocesses-collapsed.bpmn +200 -200
- package/test/fixtures/bpmn/draw/event-subprocesses-expanded.bpmn +274 -274
- package/test/fixtures/bpmn/draw/events-interrupting.bpmn +370 -370
- package/test/fixtures/bpmn/draw/events.bpmn +374 -374
- package/test/fixtures/bpmn/draw/gateway-type-default.bpmn +45 -45
- package/test/fixtures/bpmn/draw/gateways.bpmn +61 -61
- package/test/fixtures/bpmn/draw/group.bpmn +24 -24
- package/test/fixtures/bpmn/draw/message-marker.bpmn +112 -112
- package/test/fixtures/bpmn/draw/pools-with-collection-marker.bpmn +104 -104
- package/test/fixtures/bpmn/draw/pools.bpmn +82 -82
- package/test/fixtures/bpmn/draw/task-types.bpmn +77 -77
- package/test/fixtures/bpmn/draw/text-annotation.bpmn +71 -71
- package/test/fixtures/bpmn/draw/xor.bpmn +45 -45
- package/test/fixtures/bpmn/empty-definitions.bpmn +4 -4
- package/test/fixtures/bpmn/error/categoryValue.bpmn +26 -26
- package/test/fixtures/bpmn/error/di-plane-no-bpmn-element.bpmn +9 -9
- package/test/fixtures/bpmn/error/duplicate-ids.bpmn +14 -14
- package/test/fixtures/bpmn/error/invalid-child.bpmn +6 -6
- package/test/fixtures/bpmn/error/missing-namespace.bpmn +12 -12
- package/test/fixtures/bpmn/event-sub-processes.bpmn +47 -47
- package/test/fixtures/bpmn/extension/camunda.bpmn +52 -52
- package/test/fixtures/bpmn/extension/custom-override.bpmn +53 -53
- package/test/fixtures/bpmn/extension/custom.bpmn +53 -53
- package/test/fixtures/bpmn/features/copy-paste/basic.bpmn +111 -111
- package/test/fixtures/bpmn/features/copy-paste/collaboration-multiple.bpmn +102 -102
- package/test/fixtures/bpmn/features/copy-paste/collaboration.bpmn +74 -74
- package/test/fixtures/bpmn/features/copy-paste/data-associations.bpmn +61 -61
- package/test/fixtures/bpmn/features/copy-paste/properties.bpmn +43 -43
- package/test/fixtures/bpmn/features/drop/drop.bpmn +41 -41
- package/test/fixtures/bpmn/features/drop/recursive-task.bpmn +37 -37
- package/test/fixtures/bpmn/features/label-editing/labels.bpmn +178 -248
- package/test/fixtures/bpmn/features/modeling/update-label.bpmn +24 -24
- package/test/fixtures/bpmn/features/replace/01_replace.bpmn +193 -193
- package/test/fixtures/bpmn/features/replace/association-gateways.bpmn +173 -173
- package/test/fixtures/bpmn/features/replace/cancel-events.bpmn +49 -49
- package/test/fixtures/bpmn/features/replace/clone-properties.bpmn +141 -141
- package/test/fixtures/bpmn/features/replace/connection.bpmn +42 -42
- package/test/fixtures/bpmn/features/rules/event-based-gateway-outgoing-edge.bpmn +72 -72
- package/test/fixtures/bpmn/features/rules/link-event.bpmn +35 -35
- package/test/fixtures/bpmn/features/rules/text-annotation-association.bpmn +30 -30
- package/test/fixtures/bpmn/flow-markers.bpmn +212 -212
- package/test/fixtures/bpmn/import/boundaryEvent.bpmn +33 -33
- package/test/fixtures/bpmn/import/collaboration.bpmn +50 -50
- package/test/fixtures/bpmn/import/collapsed/collaboration.bpmn +76 -76
- package/test/fixtures/bpmn/import/collapsed/process.bpmn +84 -84
- package/test/fixtures/bpmn/import/collapsed/processWithChildren.bpmn +273 -273
- package/test/fixtures/bpmn/import/default-attrs.bpmn +24 -24
- package/test/fixtures/bpmn/import/error/boundaryEvent-invalidAttachToRef.bpmn +30 -30
- package/test/fixtures/bpmn/import/error/boundaryEvent-missingAttachToRef.bpmn +33 -33
- package/test/fixtures/bpmn/import/error/dangling-process-message-flow.bpmn +81 -81
- package/test/fixtures/bpmn/import/error/invalid-flow-element.bpmn +35 -35
- package/test/fixtures/bpmn/import/error/multiple-dis.bpmn +23 -23
- package/test/fixtures/bpmn/import/labels/collaboration-message-flows.bpmn +41 -41
- package/test/fixtures/bpmn/import/labels/collaboration.bpmn +72 -72
- package/test/fixtures/bpmn/import/labels/embedded.bpmn +39 -39
- package/test/fixtures/bpmn/import/labels/external-no-di.bpmn +42 -42
- package/test/fixtures/bpmn/import/labels/external.bpmn +69 -69
- package/test/fixtures/bpmn/import/position/position-testcase.bpmn +57 -57
- package/test/fixtures/bpmn/import/process.bpmn +60 -60
- package/test/fixtures/bpmn/nested-subprocesses.bpmn +118 -118
- package/test/fixtures/bpmn/sequence-flows.bpmn +60 -60
- package/test/fixtures/bpmn/simple-cropping.bpmn +84 -84
- package/test/fixtures/bpmn/simple-resizable.bpmn +50 -50
- package/test/fixtures/bpmn/simple.bpmn +60 -60
- package/test/fixtures/json/model/camunda.json +1042 -1042
- package/test/fixtures/json/model/custom-override.json +39 -39
- package/test/fixtures/json/model/custom.json +39 -39
- package/test/helper/TranslationCollector.js +17 -17
- package/test/helper/index.js +249 -249
- package/test/integration/CustomElementsSpec.js +223 -223
- package/test/integration/ReimportSpec.js +89 -89
- package/test/integration/SimpleModelingSpec.js +29 -29
- package/test/integration/custom-elements/CustomElementFactory.js +77 -77
- package/test/integration/custom-elements/CustomRenderer.js +151 -151
- package/test/integration/custom-elements/CustomRules.js +148 -148
- package/test/integration/custom-elements/CustomUpdater.js +115 -115
- package/test/integration/custom-elements/index.js +7 -7
- package/test/integration/model/BpmnModdleSpec.js +65 -65
- package/test/matchers/JSONMatcher.js +19 -19
- package/test/spec/ModelerSpec.js +401 -401
- package/test/spec/NavigatedViewerSpec.js +58 -58
- package/test/spec/ViewerSpec.js +977 -977
- package/test/spec/draw/BpmnRendererSpec.js +311 -311
- package/test/spec/environment/MockingSpec.js +53 -53
- package/test/spec/features/align-elements/BpmnAlignElementsSpec.js +137 -137
- package/test/spec/features/auto-resize/AutoResize.lanes.bpmn +54 -54
- package/test/spec/features/auto-resize/AutoResize.multi-selection.bpmn +22 -22
- package/test/spec/features/auto-resize/AutoResize.nested-sub-processes.bpmn +47 -47
- package/test/spec/features/auto-resize/AutoResize.participant.bpmn +38 -38
- package/test/spec/features/auto-resize/AutoResize.space-tool.bpmn +38 -38
- package/test/spec/features/auto-resize/AutoResize.sub-processes.bpmn +37 -37
- package/test/spec/features/auto-resize/AutoResizeSpec.js +607 -607
- package/test/spec/features/context-pad/ContextPad.activation.bpmn +51 -51
- package/test/spec/features/context-pad/ContextPadProviderSpec.js +440 -440
- package/test/spec/features/copy-paste/BpmnCopyPasteSpec.js +763 -725
- package/test/spec/features/copy-paste/DescriptorTree.js +58 -58
- package/test/spec/features/distribute-elements/BpmnDistributeElementsSpec.js +113 -113
- package/test/spec/features/editor-actions/BpmnEditorActionsSpec.js +72 -72
- package/test/spec/features/global-connect/BpmnGlobalConnectSpec.js +61 -61
- package/test/spec/features/keyboard/BpmnKeyBindingsSpec.js +142 -142
- package/test/spec/features/label-editing/LabelEditingPreviewSpec.js +133 -0
- package/test/spec/features/label-editing/LabelEditingProviderSpec.js +636 -601
- package/test/spec/features/label-editing/TouchIntegrationSpec.js +40 -40
- package/test/spec/features/modeling/AppendShapeSpec.js +332 -332
- package/test/spec/features/modeling/BendpointsSpec.js +25 -25
- package/test/spec/features/modeling/BpmnFactorySpec.js +73 -73
- package/test/spec/features/modeling/BpmnUpdater.bpmn +99 -99
- package/test/spec/features/modeling/BpmnUpdaterSpec.js +79 -79
- package/test/spec/features/modeling/CreateConnectionSpec.js +171 -171
- package/test/spec/features/modeling/DeleteConnectionSpec.js +75 -75
- package/test/spec/features/modeling/DeleteParticipantSpec.js +97 -97
- package/test/spec/features/modeling/DeleteShapeSpec.js +75 -75
- package/test/spec/features/modeling/DropSpec.js +123 -123
- package/test/spec/features/modeling/IdClaim.bpmn +13 -13
- package/test/spec/features/modeling/IdClaimSpec.js +50 -50
- package/test/spec/features/modeling/LabelBoundsSpec.js +342 -340
- package/test/spec/features/modeling/LabelBoundsSpec.simple.bpmn +27 -27
- package/test/spec/features/modeling/LabelLayouting.initial.bpmn +37 -37
- package/test/spec/features/modeling/LabelLayouting.move.bpmn +99 -99
- package/test/spec/features/modeling/LabelLayouting.special.bpmn +76 -76
- package/test/spec/features/modeling/LabelLayoutingSpec.js +603 -603
- package/test/spec/features/modeling/MoveConnectionSpec.js +101 -101
- package/test/spec/features/modeling/MoveElements.flow-collaboration.bpmn +45 -45
- package/test/spec/features/modeling/MoveElementsSpec.js +70 -70
- package/test/spec/features/modeling/MoveRulesSpec.js +151 -151
- package/test/spec/features/modeling/MoveShapeSpec.js +353 -353
- package/test/spec/features/modeling/ResizeShapeSpec.js +73 -73
- package/test/spec/features/modeling/SpaceToolSpec.js +251 -251
- package/test/spec/features/modeling/UpdateAttachmentSpec.js +96 -96
- package/test/spec/features/modeling/UpdateLabelSpec.js +130 -130
- package/test/spec/features/modeling/UpdatePropertiesSpec.js +503 -503
- package/test/spec/features/modeling/append/TextAnnotationSpec.js +136 -136
- package/test/spec/features/modeling/behavior/CompensationAssociationBehavior.bpmn +26 -26
- package/test/spec/features/modeling/behavior/CompensationAssociationBehaviorSpec.js +43 -43
- package/test/spec/features/modeling/behavior/CreateBoundaryEventBehaviorSpec.js +58 -58
- package/test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js +224 -224
- package/test/spec/features/modeling/behavior/DataInputAssociationBehavior.bpmn +33 -33
- package/test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js +146 -146
- package/test/spec/features/modeling/behavior/DataObjectBehavior.create-data-association.bpmn +21 -21
- package/test/spec/features/modeling/behavior/DataObjectBehavior.data-object-reference.bpmn +13 -13
- package/test/spec/features/modeling/behavior/DataObjectBehavior.remove-data-association.bpmn +41 -41
- package/test/spec/features/modeling/behavior/DataObjectBehaviorSpec.js +297 -297
- package/test/spec/features/modeling/behavior/DataStoreBehavior.bpmn +26 -26
- package/test/spec/features/modeling/behavior/DataStoreBehavior.connect.bpmn +57 -57
- package/test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js +228 -228
- package/test/spec/features/modeling/behavior/DropOnFlowBehavior.bpmn +71 -67
- package/test/spec/features/modeling/behavior/DropOnFlowBehaviorSpec.js +591 -418
- package/test/spec/features/modeling/behavior/ImportDockingFix.bpmn +61 -61
- package/test/spec/features/modeling/behavior/ImportDockingFixSpec.js +37 -37
- package/test/spec/features/modeling/behavior/LabelBehaviorSpec.js +277 -277
- package/test/spec/features/modeling/behavior/ReconnectConnection.data-association.bpmn +41 -41
- package/test/spec/features/modeling/behavior/ReconnectConnectionSpec.js +120 -120
- package/test/spec/features/modeling/behavior/RemoveElementBehavior.bpmn +181 -181
- package/test/spec/features/modeling/behavior/RemoveElementBehavior.perpendicular.bpmn +159 -159
- package/test/spec/features/modeling/behavior/RemoveElementBehaviorSpec.js +251 -251
- package/test/spec/features/modeling/behavior/RemoveParticipantBehaviorSpec.js +125 -125
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.association.bpmn +26 -26
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.boundary-events.bpmn +40 -40
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehavior.message-sequence-flow.bpmn +121 -121
- package/test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js +439 -439
- package/test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js +450 -450
- package/test/spec/features/modeling/behavior/ToggleElementCollapseBehaviourSpec.js +653 -653
- package/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.bpmn +48 -48
- package/test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.js +77 -77
- package/test/spec/features/modeling/behavior/util/GeometricUtilSpec.js +127 -127
- package/test/spec/features/modeling/behavior/util/LabelLayoutUtilSpec.js +75 -75
- package/test/spec/features/modeling/behavior/util/LineAttachmentUtilSpec.js +294 -294
- package/test/spec/features/modeling/behavior/util/LineIntersectSpec.js +32 -32
- package/test/spec/features/modeling/lanes/AddLaneSpec.js +263 -263
- package/test/spec/features/modeling/lanes/DeleteLaneSpec.js +126 -126
- package/test/spec/features/modeling/lanes/ResizeLaneSpec.js +366 -366
- package/test/spec/features/modeling/lanes/SplitLaneSpec.js +216 -216
- package/test/spec/features/modeling/lanes/UpdateFlowNodeRefsSpec.js +271 -271
- package/test/spec/features/modeling/lanes/flowNodeRefs.bpmn +56 -56
- package/test/spec/features/modeling/lanes/lanes.bpmn +83 -83
- package/test/spec/features/modeling/lanes/participant-lane.bpmn +27 -27
- package/test/spec/features/modeling/lanes/participant-no-lane.bpmn +22 -22
- package/test/spec/features/modeling/layout/Helper.js +64 -64
- package/test/spec/features/modeling/layout/LayoutAssociationSpec.js +101 -101
- package/test/spec/features/modeling/layout/LayoutConnectionSpec.js +98 -98
- package/test/spec/features/modeling/layout/LayoutDataAssociationSpec.js +98 -98
- package/test/spec/features/modeling/layout/LayoutMessageFlowSpec.bpmn +119 -119
- package/test/spec/features/modeling/layout/LayoutMessageFlowSpec.js +313 -313
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.boundaryEvents.bpmn +65 -65
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.flowElements.bpmn +70 -70
- package/test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js +323 -323
- package/test/spec/features/ordering/BpmnOrderingProviderSpec.js +231 -231
- package/test/spec/features/ordering/Helper.js +185 -185
- package/test/spec/features/ordering/ordering-start-event.bpmn +17 -17
- package/test/spec/features/ordering/ordering-subprocesses.bpmn +41 -41
- package/test/spec/features/ordering/ordering.bpmn +105 -105
- package/test/spec/features/palette/PaletteProviderSpec.js +33 -33
- package/test/spec/features/popup-menu/ReplaceMenuProvider.collapsedSubProcess.bpmn +13 -13
- package/test/spec/features/popup-menu/ReplaceMenuProvider.compensation-activity.bpmn +12 -12
- package/test/spec/features/popup-menu/ReplaceMenuProvider.conditionalFlows.bpmn +66 -66
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlows.bpmn +126 -126
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromComplexGateways.bpmn +48 -48
- package/test/spec/features/popup-menu/ReplaceMenuProvider.defaultFlowsFromInclusiveGateways.bpmn +48 -48
- package/test/spec/features/popup-menu/ReplaceMenuProviderSpec.js +1957 -1957
- package/test/spec/features/replace/BpmnReplace.collaboration.bpmn +70 -70
- package/test/spec/features/replace/BpmnReplace.compensation.bpmn +12 -12
- package/test/spec/features/replace/BpmnReplace.eventSubProcesses.bpmn +126 -126
- package/test/spec/features/replace/BpmnReplaceSpec.js +1302 -1302
- package/test/spec/features/replace/ReplaceRulesSpec.js +78 -78
- package/test/spec/features/replace/SubProcess-collapsed.bpmn +36 -36
- package/test/spec/features/replace-preview/BpmnReplacePreviewSpec.js +304 -304
- package/test/spec/features/rules/BpmnRules.boundaryEvent.bpmn +93 -93
- package/test/spec/features/rules/BpmnRules.collaboration-dataAssociation.bpmn +35 -35
- package/test/spec/features/rules/BpmnRules.collaboration-lanes.bpmn +79 -79
- package/test/spec/features/rules/BpmnRules.collaboration.bpmn +138 -138
- package/test/spec/features/rules/BpmnRules.compensation.bpmn +65 -65
- package/test/spec/features/rules/BpmnRules.dataAssociation.bpmn +33 -33
- package/test/spec/features/rules/BpmnRules.eventBasedGateway.bpmn +82 -82
- package/test/spec/features/rules/BpmnRules.messageFlow.bpmn +27 -27
- package/test/spec/features/rules/BpmnRules.multiSelectionPools.bpmn +37 -37
- package/test/spec/features/rules/BpmnRules.process.bpmn +91 -91
- package/test/spec/features/rules/BpmnRules.subProcess-dataAssociation.bpmn +44 -44
- package/test/spec/features/rules/BpmnRulesSpec.js +1468 -1424
- package/test/spec/features/rules/Helper.js +82 -82
- package/test/spec/features/search/BpmnSearchProviderSpec.js +158 -158
- package/test/spec/features/search/bpmn-search-collaboration.bpmn +106 -106
- package/test/spec/features/search/bpmn-search.bpmn +100 -100
- package/test/spec/features/snapping/BpmnSnapping.connect.bpmn +36 -36
- package/test/spec/features/snapping/BpmnSnapping.labels.bpmn +27 -27
- package/test/spec/features/snapping/BpmnSnapping.lanes-resize.bpmn +43 -43
- package/test/spec/features/snapping/BpmnSnapping.participant-resize.bpmn +50 -50
- package/test/spec/features/snapping/BpmnSnapping.sequenceFlow.bpmn +41 -0
- package/test/spec/features/snapping/BpmnSnapping.subProcess-resize.bpmn +21 -21
- package/test/spec/features/snapping/BpmnSnapping.textAnnotation-resize.bpmn +22 -22
- package/test/spec/features/snapping/BpmnSnappingSpec.js +824 -758
- package/test/spec/features/snapping/BpmnSnappingUtil.lanes-flowNodes.bpmn +82 -82
- package/test/spec/features/snapping/BpmnSnappingUtil.lanes.bpmn +35 -35
- package/test/spec/features/snapping/BpmnSnappingUtilSpec.js +285 -285
- package/test/spec/i18n/custom-translate/custom-translate.js +14 -14
- package/test/spec/i18n/custom-translate/index.js +2 -2
- package/test/spec/i18n/translateSpec.js +56 -56
- package/test/spec/import/ImporterSpec.js +428 -428
- package/test/spec/import/ModelWiringSpec.js +194 -194
- package/test/spec/import/elements/AssociationSpec.collaboration.bpmn +51 -51
- package/test/spec/import/elements/AssociationSpec.compensation.bpmn +28 -28
- package/test/spec/import/elements/AssociationSpec.data-association.bpmn +39 -39
- package/test/spec/import/elements/AssociationSpec.data-input-output.bpmn +40 -40
- package/test/spec/import/elements/AssociationSpec.events.bpmn +51 -51
- package/test/spec/import/elements/AssociationSpec.js +175 -175
- package/test/spec/import/elements/AssociationSpec.text-annotation.bpmn +37 -37
- package/test/spec/import/elements/CollapsedSpec.js +118 -118
- package/test/spec/import/elements/LabelSpec.js +85 -85
- package/test/spec/import/lane-flowNodes.bpmn +44 -44
- package/test/spec/import/lane-missing-flowNodeRef.bpmn +24 -24
- package/test/spec/util/ModelCloneHelperSpec.js +381 -381
- package/test/spec/util/ModelUtilSpec.js +65 -65
- package/test/spec/util/camunda-moddle.js +70 -70
- package/test/util/MockEvents.js +62 -62
- package/test/util/ModelingUtil.js +117 -117
- package/test/util/custom-rules/CustomRules.js +18 -18
- package/test/util/custom-rules/index.js +4 -4
package/test/spec/ViewerSpec.js
CHANGED
|
@@ -1,977 +1,977 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var TestContainer = require('mocha-test-container-support');
|
|
4
|
-
|
|
5
|
-
var Diagram = require('diagram-js/lib/Diagram');
|
|
6
|
-
|
|
7
|
-
var Viewer = require('../../lib/Viewer');
|
|
8
|
-
|
|
9
|
-
var inherits = require('inherits');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
describe('Viewer', function() {
|
|
13
|
-
|
|
14
|
-
var container;
|
|
15
|
-
|
|
16
|
-
beforeEach(function() {
|
|
17
|
-
container = TestContainer.get(this);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function createViewer(xml, done) {
|
|
22
|
-
var viewer = new Viewer({ container: container });
|
|
23
|
-
|
|
24
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
25
|
-
done(err, warnings, viewer);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
it('should import simple process', function(done) {
|
|
31
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
32
|
-
createViewer(xml, done);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
it('should re-import simple process', function(done) {
|
|
37
|
-
|
|
38
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
39
|
-
|
|
40
|
-
// given
|
|
41
|
-
createViewer(xml, function(err, warnings, viewer) {
|
|
42
|
-
|
|
43
|
-
if (err) {
|
|
44
|
-
return done(err);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// when
|
|
48
|
-
// mimic re-import of same diagram
|
|
49
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
50
|
-
|
|
51
|
-
if (err) {
|
|
52
|
-
return done(err);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// then
|
|
56
|
-
expect(warnings.length).to.equal(0);
|
|
57
|
-
|
|
58
|
-
done();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
it('should be instance of Diagram', function() {
|
|
66
|
-
|
|
67
|
-
// when
|
|
68
|
-
var viewer = new Viewer({ container: container });
|
|
69
|
-
|
|
70
|
-
// then
|
|
71
|
-
expect(viewer).to.be.instanceof(Diagram);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
describe('overlay support', function() {
|
|
76
|
-
|
|
77
|
-
it('should allow to add overlays', function(done) {
|
|
78
|
-
|
|
79
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
80
|
-
|
|
81
|
-
createViewer(xml, function(err, warnings, viewer) {
|
|
82
|
-
|
|
83
|
-
// when
|
|
84
|
-
var overlays = viewer.get('overlays'),
|
|
85
|
-
elementRegistry = viewer.get('elementRegistry');
|
|
86
|
-
|
|
87
|
-
// then
|
|
88
|
-
expect(overlays).to.exist;
|
|
89
|
-
expect(elementRegistry).to.exist;
|
|
90
|
-
|
|
91
|
-
// when
|
|
92
|
-
overlays.add('SubProcess_1', {
|
|
93
|
-
position: {
|
|
94
|
-
bottom: 0,
|
|
95
|
-
right: 0
|
|
96
|
-
},
|
|
97
|
-
html: '<div style="max-width: 50px">YUP GREAT STUFF!</div>'
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// then
|
|
101
|
-
expect(overlays.get({ element: 'SubProcess_1' }).length).to.equal(1);
|
|
102
|
-
|
|
103
|
-
done(err);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
describe('error handling', function() {
|
|
112
|
-
|
|
113
|
-
function expectMessage(e, expectedMessage) {
|
|
114
|
-
|
|
115
|
-
expect(e).to.exist;
|
|
116
|
-
|
|
117
|
-
if (expectedMessage instanceof RegExp) {
|
|
118
|
-
expect(e.message).to.match(expectedMessage);
|
|
119
|
-
} else {
|
|
120
|
-
expect(e.message).to.equal(expectedMessage);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function expectWarnings(warnings, expected) {
|
|
125
|
-
|
|
126
|
-
expect(warnings.length).to.equal(expected.length);
|
|
127
|
-
|
|
128
|
-
warnings.forEach(function(w, idx) {
|
|
129
|
-
expectMessage(w, expected[idx]);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
it('should handle non-bpmn input', function(done) {
|
|
135
|
-
|
|
136
|
-
var xml = 'invalid stuff';
|
|
137
|
-
|
|
138
|
-
createViewer(xml, function(err) {
|
|
139
|
-
|
|
140
|
-
expect(err).to.exist;
|
|
141
|
-
|
|
142
|
-
expectMessage(err, /Text data outside of root node./);
|
|
143
|
-
|
|
144
|
-
done();
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
it('should handle invalid BPMNPlane#bpmnElement', function(done) {
|
|
150
|
-
|
|
151
|
-
var xml = require('../fixtures/bpmn/error/di-plane-no-bpmn-element.bpmn');
|
|
152
|
-
|
|
153
|
-
// when
|
|
154
|
-
createViewer(xml, function(err, warnings) {
|
|
155
|
-
|
|
156
|
-
// then
|
|
157
|
-
expect(err).not.to.exist;
|
|
158
|
-
|
|
159
|
-
expectWarnings(warnings, [
|
|
160
|
-
'unresolved reference <Collaboration_2>',
|
|
161
|
-
'no bpmnElement referenced in <bpmndi:BPMNPlane id="BPMNPlane_1" />',
|
|
162
|
-
'correcting missing bpmnElement ' +
|
|
163
|
-
'on <bpmndi:BPMNPlane id="BPMNPlane_1" /> ' +
|
|
164
|
-
'to <bpmn:Process id="Process_1" />'
|
|
165
|
-
]);
|
|
166
|
-
|
|
167
|
-
done();
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
it('should handle invalid namespaced element', function(done) {
|
|
173
|
-
|
|
174
|
-
var xml = require('../fixtures/bpmn/error/categoryValue.bpmn');
|
|
175
|
-
|
|
176
|
-
// when
|
|
177
|
-
createViewer(xml, function(err, warnings) {
|
|
178
|
-
|
|
179
|
-
// then
|
|
180
|
-
expect(err).not.to.exist;
|
|
181
|
-
|
|
182
|
-
expectWarnings(warnings, [
|
|
183
|
-
/unparsable content <categoryValue> detected/,
|
|
184
|
-
'unresolved reference <sid-afd7e63e-916e-4bd0-a9f0-98cbff749193>'
|
|
185
|
-
]);
|
|
186
|
-
|
|
187
|
-
done();
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
it('should handle missing namespace', function(done) {
|
|
193
|
-
|
|
194
|
-
var xml = require('../fixtures/bpmn/error/missing-namespace.bpmn');
|
|
195
|
-
|
|
196
|
-
// when
|
|
197
|
-
createViewer(xml, function(err, warnings) {
|
|
198
|
-
|
|
199
|
-
// then
|
|
200
|
-
expect(err).to.exist;
|
|
201
|
-
expect(err.message).to.eql('no process or collaboration to display');
|
|
202
|
-
|
|
203
|
-
expectWarnings(warnings, [
|
|
204
|
-
/unparsable content <collaboration> detected/,
|
|
205
|
-
'unresolved reference <Participant_1>',
|
|
206
|
-
'no bpmnElement referenced in <bpmndi:BPMNPlane id="BPMNPlane_1" />',
|
|
207
|
-
'no bpmnElement referenced in <bpmndi:BPMNShape id="BPMNShape_Participant_1" />'
|
|
208
|
-
]);
|
|
209
|
-
|
|
210
|
-
done();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
it('should handle duplicate ids', function(done) {
|
|
216
|
-
|
|
217
|
-
var xml = require('../fixtures/bpmn/error/duplicate-ids.bpmn');
|
|
218
|
-
|
|
219
|
-
// when
|
|
220
|
-
createViewer(xml, function(err, warnings) {
|
|
221
|
-
|
|
222
|
-
// then
|
|
223
|
-
expect(err).not.to.exist;
|
|
224
|
-
|
|
225
|
-
expectWarnings(warnings, [
|
|
226
|
-
/duplicate ID <test>/
|
|
227
|
-
]);
|
|
228
|
-
|
|
229
|
-
done();
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
describe('dependency injection', function() {
|
|
237
|
-
|
|
238
|
-
it('should provide self as <bpmnjs>', function(done) {
|
|
239
|
-
|
|
240
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
241
|
-
|
|
242
|
-
createViewer(xml, function(err, warnings, viewer) {
|
|
243
|
-
|
|
244
|
-
expect(viewer.get('bpmnjs')).to.equal(viewer);
|
|
245
|
-
|
|
246
|
-
done(err);
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
it('should allow Diagram#get before import', function() {
|
|
252
|
-
|
|
253
|
-
// when
|
|
254
|
-
var viewer = new Viewer({ container: container });
|
|
255
|
-
|
|
256
|
-
// then
|
|
257
|
-
var eventBus = viewer.get('eventBus');
|
|
258
|
-
|
|
259
|
-
expect(eventBus).to.exist;
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
it('should keep references to services across re-import', function(done) {
|
|
264
|
-
|
|
265
|
-
// given
|
|
266
|
-
var someXML = require('../fixtures/bpmn/simple.bpmn'),
|
|
267
|
-
otherXML = require('../fixtures/bpmn/basic.bpmn');
|
|
268
|
-
|
|
269
|
-
var viewer = new Viewer({ container: container });
|
|
270
|
-
|
|
271
|
-
var eventBus = viewer.get('eventBus'),
|
|
272
|
-
canvas = viewer.get('canvas');
|
|
273
|
-
|
|
274
|
-
// when
|
|
275
|
-
viewer.importXML(someXML, function() {
|
|
276
|
-
|
|
277
|
-
// then
|
|
278
|
-
expect(viewer.get('canvas')).to.equal(canvas);
|
|
279
|
-
expect(viewer.get('eventBus')).to.equal(eventBus);
|
|
280
|
-
|
|
281
|
-
viewer.importXML(otherXML, function() {
|
|
282
|
-
|
|
283
|
-
// then
|
|
284
|
-
expect(viewer.get('canvas')).to.equal(canvas);
|
|
285
|
-
expect(viewer.get('eventBus')).to.equal(eventBus);
|
|
286
|
-
|
|
287
|
-
done();
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
describe('export', function() {
|
|
296
|
-
|
|
297
|
-
function currentTime() {
|
|
298
|
-
return new Date().getTime();
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function validSVG(svg) {
|
|
302
|
-
var expectedStart = '<?xml version="1.0" encoding="utf-8"?>';
|
|
303
|
-
var expectedEnd = '</svg>';
|
|
304
|
-
|
|
305
|
-
expect(svg.indexOf(expectedStart)).to.equal(0);
|
|
306
|
-
expect(svg.indexOf(expectedEnd)).to.equal(svg.length - expectedEnd.length);
|
|
307
|
-
|
|
308
|
-
// ensure correct rendering of SVG contents
|
|
309
|
-
expect(svg.indexOf('undefined')).to.equal(-1);
|
|
310
|
-
|
|
311
|
-
// expect header to be written only once
|
|
312
|
-
expect(svg.indexOf('<svg width="100%" height="100%">')).to.equal(-1);
|
|
313
|
-
expect(svg.indexOf('<g class="viewport"')).to.equal(-1);
|
|
314
|
-
|
|
315
|
-
var parser = new DOMParser();
|
|
316
|
-
var svgNode = parser.parseFromString(svg, 'image/svg+xml');
|
|
317
|
-
|
|
318
|
-
// [comment, <!DOCTYPE svg>, svg]
|
|
319
|
-
expect(svgNode.childNodes).to.have.length(3);
|
|
320
|
-
|
|
321
|
-
// no error body
|
|
322
|
-
expect(svgNode.body).not.to.exist;
|
|
323
|
-
|
|
324
|
-
// FIXME(nre): make matcher
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
it('should export XML', function(done) {
|
|
330
|
-
|
|
331
|
-
// given
|
|
332
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
333
|
-
|
|
334
|
-
createViewer(xml, function(err, warnings, viewer) {
|
|
335
|
-
|
|
336
|
-
if (err) {
|
|
337
|
-
return done(err);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// when
|
|
341
|
-
viewer.saveXML({ format: true }, function(err, xml) {
|
|
342
|
-
|
|
343
|
-
if (err) {
|
|
344
|
-
return done(err);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// then
|
|
348
|
-
expect(xml).to.contain('<?xml version="1.0" encoding="UTF-8"?>');
|
|
349
|
-
expect(xml).to.contain('<bpmn2:definitions');
|
|
350
|
-
expect(xml).to.contain(' ');
|
|
351
|
-
|
|
352
|
-
done();
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
it('should export svg', function(done) {
|
|
360
|
-
|
|
361
|
-
// given
|
|
362
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
363
|
-
|
|
364
|
-
createViewer(xml, function(err, warnings, viewer) {
|
|
365
|
-
|
|
366
|
-
if (err) {
|
|
367
|
-
return done(err);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// when
|
|
371
|
-
viewer.saveSVG(function(err, svg) {
|
|
372
|
-
|
|
373
|
-
if (err) {
|
|
374
|
-
return done(err);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// then
|
|
378
|
-
expect(validSVG(svg)).to.be.true;
|
|
379
|
-
|
|
380
|
-
done();
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
it('should export huge svg', function(done) {
|
|
387
|
-
|
|
388
|
-
this.timeout(3000);
|
|
389
|
-
|
|
390
|
-
// given
|
|
391
|
-
var xml = require('../fixtures/bpmn/complex.bpmn');
|
|
392
|
-
|
|
393
|
-
createViewer(xml, function(err, warnings, viewer) {
|
|
394
|
-
|
|
395
|
-
if (err) {
|
|
396
|
-
return done(err);
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
var time = currentTime();
|
|
400
|
-
|
|
401
|
-
// when
|
|
402
|
-
viewer.saveSVG(function(err, svg) {
|
|
403
|
-
|
|
404
|
-
if (err) {
|
|
405
|
-
return done(err);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// then
|
|
409
|
-
expect(validSVG(svg)).to.be.true;
|
|
410
|
-
|
|
411
|
-
// no svg export should not take too long
|
|
412
|
-
expect(currentTime() - time).to.be.below(1000);
|
|
413
|
-
|
|
414
|
-
done();
|
|
415
|
-
});
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
it('should remove outer-makers on export', function(done) {
|
|
421
|
-
|
|
422
|
-
// given
|
|
423
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
424
|
-
function appendTestRect(svgDoc) {
|
|
425
|
-
var rect = document.createElementNS(svgDoc.namespaceURI, 'rect');
|
|
426
|
-
rect.setAttribute('class', 'outer-bound-marker');
|
|
427
|
-
rect.setAttribute('width', 500);
|
|
428
|
-
rect.setAttribute('height', 500);
|
|
429
|
-
rect.setAttribute('x', 10000);
|
|
430
|
-
rect.setAttribute('y', 10000);
|
|
431
|
-
svgDoc.appendChild(rect);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
createViewer(xml, function(err, warnings, viewer) {
|
|
435
|
-
|
|
436
|
-
if (err) {
|
|
437
|
-
return done(err);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
var svgDoc = viewer.container.childNodes[1].childNodes[1];
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
appendTestRect(svgDoc);
|
|
445
|
-
appendTestRect(svgDoc);
|
|
446
|
-
|
|
447
|
-
expect(svgDoc.querySelectorAll('.outer-bound-marker')).to.exist;
|
|
448
|
-
|
|
449
|
-
// when
|
|
450
|
-
viewer.saveSVG(function(err, svg) {
|
|
451
|
-
|
|
452
|
-
if (err) {
|
|
453
|
-
return done(err);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
var svgDoc = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
457
|
-
svgDoc.innerHTML = svg;
|
|
458
|
-
|
|
459
|
-
// then
|
|
460
|
-
expect(validSVG(svg)).to.be.true;
|
|
461
|
-
expect(svgDoc.querySelector('.outer-bound-marker')).to.be.null;
|
|
462
|
-
|
|
463
|
-
done();
|
|
464
|
-
});
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
describe('creation', function() {
|
|
472
|
-
|
|
473
|
-
var testModules = [
|
|
474
|
-
{ logger: [ 'type', function() { this.called = true; } ] }
|
|
475
|
-
];
|
|
476
|
-
|
|
477
|
-
// given
|
|
478
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
479
|
-
|
|
480
|
-
var viewer;
|
|
481
|
-
|
|
482
|
-
afterEach(function() {
|
|
483
|
-
viewer.destroy();
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
it('should override default modules', function(done) {
|
|
487
|
-
|
|
488
|
-
// given
|
|
489
|
-
viewer = new Viewer({ container: container, modules: testModules });
|
|
490
|
-
|
|
491
|
-
// when
|
|
492
|
-
viewer.importXML(xml, function(err) {
|
|
493
|
-
|
|
494
|
-
// then
|
|
495
|
-
expect(err.message).to.equal('No provider for "bpmnImporter"! (Resolving: bpmnImporter)');
|
|
496
|
-
done();
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
it('should add module to default modules', function(done) {
|
|
503
|
-
|
|
504
|
-
// given
|
|
505
|
-
viewer = new Viewer({ container: container, additionalModules: testModules });
|
|
506
|
-
|
|
507
|
-
// when
|
|
508
|
-
viewer.importXML(xml, function(err) {
|
|
509
|
-
|
|
510
|
-
// then
|
|
511
|
-
var logger = viewer.get('logger');
|
|
512
|
-
expect(logger.called).to.be.true;
|
|
513
|
-
|
|
514
|
-
done(err);
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
it('should use custom size and position', function() {
|
|
521
|
-
|
|
522
|
-
// when
|
|
523
|
-
viewer = new Viewer({
|
|
524
|
-
container: container,
|
|
525
|
-
width: 200,
|
|
526
|
-
height: 100,
|
|
527
|
-
position: 'fixed'
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
// then
|
|
531
|
-
expect(viewer.container.style.position).to.equal('fixed');
|
|
532
|
-
expect(viewer.container.style.width).to.equal('200px');
|
|
533
|
-
expect(viewer.container.style.height).to.equal('100px');
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
var camundaPackage = require('../fixtures/json/model/camunda');
|
|
538
|
-
|
|
539
|
-
it('should provide custom moddle extensions', function(done) {
|
|
540
|
-
|
|
541
|
-
var xml = require('../fixtures/bpmn/extension/camunda.bpmn');
|
|
542
|
-
|
|
543
|
-
// given
|
|
544
|
-
viewer = new Viewer({
|
|
545
|
-
container: container,
|
|
546
|
-
moddleExtensions: {
|
|
547
|
-
camunda: camundaPackage
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
// when
|
|
552
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
553
|
-
|
|
554
|
-
var elementRegistry = viewer.get('elementRegistry');
|
|
555
|
-
|
|
556
|
-
var taskShape = elementRegistry.get('send'),
|
|
557
|
-
sendTask = taskShape.businessObject;
|
|
558
|
-
|
|
559
|
-
// then
|
|
560
|
-
expect(sendTask).to.exist;
|
|
561
|
-
|
|
562
|
-
var extensionElements = sendTask.extensionElements;
|
|
563
|
-
|
|
564
|
-
// receive task should be moddle extended
|
|
565
|
-
expect(sendTask.$instanceOf('camunda:ServiceTaskLike')).to.be.true;
|
|
566
|
-
|
|
567
|
-
// extension elements should provide typed element
|
|
568
|
-
expect(extensionElements).to.exist;
|
|
569
|
-
|
|
570
|
-
expect(extensionElements.values.length).to.equal(1);
|
|
571
|
-
expect(extensionElements.values[0].$instanceOf('camunda:InputOutput')).to.be.true;
|
|
572
|
-
|
|
573
|
-
done(err);
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
it('should allow to add default custom moddle extensions', function(done) {
|
|
580
|
-
|
|
581
|
-
// given
|
|
582
|
-
var xml = require('../fixtures/bpmn/extension/custom.bpmn'),
|
|
583
|
-
additionalModdleDescriptors = {
|
|
584
|
-
custom: require('../fixtures/json/model/custom')
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
function CustomViewer(options) {
|
|
588
|
-
Viewer.call(this, options);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
inherits(CustomViewer, Viewer);
|
|
592
|
-
|
|
593
|
-
CustomViewer.prototype._moddleExtensions = additionalModdleDescriptors;
|
|
594
|
-
|
|
595
|
-
viewer = new CustomViewer({
|
|
596
|
-
container: container,
|
|
597
|
-
moddleExtensions: {
|
|
598
|
-
camunda: camundaPackage
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
// when
|
|
603
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
604
|
-
|
|
605
|
-
var elementRegistry = viewer.get('elementRegistry');
|
|
606
|
-
|
|
607
|
-
var taskShape = elementRegistry.get('send'),
|
|
608
|
-
sendTask = taskShape.businessObject;
|
|
609
|
-
|
|
610
|
-
// then
|
|
611
|
-
expect(sendTask).to.exist;
|
|
612
|
-
|
|
613
|
-
var extensionElements = sendTask.extensionElements;
|
|
614
|
-
|
|
615
|
-
// receive task should be moddle extended
|
|
616
|
-
expect(sendTask.$instanceOf('camunda:ServiceTaskLike')).to.be.true;
|
|
617
|
-
expect(sendTask.$instanceOf('custom:ServiceTaskGroup')).to.be.true;
|
|
618
|
-
|
|
619
|
-
// extension elements should provide typed element
|
|
620
|
-
expect(extensionElements).to.exist;
|
|
621
|
-
|
|
622
|
-
expect(extensionElements.values.length).to.equal(2);
|
|
623
|
-
expect(extensionElements.values[0].$instanceOf('camunda:InputOutput')).to.be.true;
|
|
624
|
-
|
|
625
|
-
expect(extensionElements.values[1].$instanceOf('custom:CustomSendElement')).to.be.true;
|
|
626
|
-
|
|
627
|
-
done(err);
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
it('should allow user to override default custom moddle extensions', function(done) {
|
|
634
|
-
|
|
635
|
-
// given
|
|
636
|
-
var xml = require('../fixtures/bpmn/extension/custom-override.bpmn'),
|
|
637
|
-
additionalModdleDescriptors = {
|
|
638
|
-
custom: require('../fixtures/json/model/custom')
|
|
639
|
-
},
|
|
640
|
-
customOverride = require('../fixtures/json/model/custom-override');
|
|
641
|
-
|
|
642
|
-
function CustomViewer(options) {
|
|
643
|
-
Viewer.call(this, options);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
inherits(CustomViewer, Viewer);
|
|
647
|
-
|
|
648
|
-
CustomViewer.prototype._moddleExtensions = additionalModdleDescriptors;
|
|
649
|
-
|
|
650
|
-
viewer = new CustomViewer({
|
|
651
|
-
container: container,
|
|
652
|
-
moddleExtensions: {
|
|
653
|
-
camunda: camundaPackage,
|
|
654
|
-
custom : customOverride
|
|
655
|
-
}
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
// when
|
|
659
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
660
|
-
|
|
661
|
-
var elementRegistry = viewer.get('elementRegistry');
|
|
662
|
-
|
|
663
|
-
var taskShape = elementRegistry.get('send'),
|
|
664
|
-
sendTask = taskShape.businessObject;
|
|
665
|
-
|
|
666
|
-
// then
|
|
667
|
-
expect(sendTask).to.exist;
|
|
668
|
-
|
|
669
|
-
var extensionElements = sendTask.extensionElements;
|
|
670
|
-
|
|
671
|
-
// receive task should be moddle extended
|
|
672
|
-
expect(sendTask.$instanceOf('camunda:ServiceTaskLike')).to.be.true;
|
|
673
|
-
expect(sendTask.$instanceOf('custom:ServiceTaskGroupOverride')).to.be.true;
|
|
674
|
-
|
|
675
|
-
// extension elements should provide typed element
|
|
676
|
-
expect(extensionElements).to.exist;
|
|
677
|
-
|
|
678
|
-
expect(extensionElements.values.length).to.equal(2);
|
|
679
|
-
expect(extensionElements.values[0].$instanceOf('camunda:InputOutput')).to.be.true;
|
|
680
|
-
|
|
681
|
-
expect(extensionElements.values[1].$instanceOf('custom:CustomSendElementOverride')).to.be.true;
|
|
682
|
-
|
|
683
|
-
done(err);
|
|
684
|
-
});
|
|
685
|
-
|
|
686
|
-
});
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
it('should throw error due to missing diagram', function(done) {
|
|
690
|
-
|
|
691
|
-
var xml = require('../fixtures/bpmn/empty-definitions.bpmn');
|
|
692
|
-
|
|
693
|
-
// given
|
|
694
|
-
viewer = new Viewer({ container: container, additionalModules: testModules });
|
|
695
|
-
|
|
696
|
-
// when
|
|
697
|
-
viewer.importXML(xml, function(err) {
|
|
698
|
-
|
|
699
|
-
// then
|
|
700
|
-
expect(err.message).to.eql('no diagram to display');
|
|
701
|
-
|
|
702
|
-
done();
|
|
703
|
-
});
|
|
704
|
-
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
});
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
describe('configuration', function() {
|
|
711
|
-
|
|
712
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
713
|
-
|
|
714
|
-
it('should configure Canvas', function(done) {
|
|
715
|
-
|
|
716
|
-
// given
|
|
717
|
-
var viewer = new Viewer({
|
|
718
|
-
container: container,
|
|
719
|
-
canvas: {
|
|
720
|
-
deferUpdate: true
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
|
|
724
|
-
// when
|
|
725
|
-
viewer.importXML(xml, function(err) {
|
|
726
|
-
|
|
727
|
-
var canvasConfig = viewer.get('config.canvas');
|
|
728
|
-
|
|
729
|
-
// then
|
|
730
|
-
expect(canvasConfig.deferUpdate).to.be.true;
|
|
731
|
-
|
|
732
|
-
done();
|
|
733
|
-
});
|
|
734
|
-
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
it('should attach the viewer to the given parent', function(done) {
|
|
738
|
-
|
|
739
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
740
|
-
|
|
741
|
-
var viewer = new Viewer({ container: container });
|
|
742
|
-
|
|
743
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
744
|
-
|
|
745
|
-
expect(viewer.container.parentNode).to.equal(container);
|
|
746
|
-
|
|
747
|
-
done(err, warnings);
|
|
748
|
-
});
|
|
749
|
-
});
|
|
750
|
-
|
|
751
|
-
it('should not attach the viewer automatically if no parent was given', function(done) {
|
|
752
|
-
|
|
753
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
754
|
-
|
|
755
|
-
var viewer = new Viewer();
|
|
756
|
-
|
|
757
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
758
|
-
|
|
759
|
-
expect(viewer.container.parentNode).to.equal(null);
|
|
760
|
-
|
|
761
|
-
done(err, warnings);
|
|
762
|
-
});
|
|
763
|
-
});
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
describe('#importXML', function() {
|
|
768
|
-
|
|
769
|
-
it('should emit <import.*> events', function(done) {
|
|
770
|
-
|
|
771
|
-
// given
|
|
772
|
-
var viewer = new Viewer({ container: container });
|
|
773
|
-
|
|
774
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
775
|
-
|
|
776
|
-
var events = [];
|
|
777
|
-
|
|
778
|
-
viewer.on([
|
|
779
|
-
'import.parse.start',
|
|
780
|
-
'import.parse.complete',
|
|
781
|
-
'import.render.start',
|
|
782
|
-
'import.render.complete',
|
|
783
|
-
'import.done'
|
|
784
|
-
], function(e) {
|
|
785
|
-
// log event type + event arguments
|
|
786
|
-
events.push([
|
|
787
|
-
e.type,
|
|
788
|
-
Object.keys(e).filter(function(key) {
|
|
789
|
-
return key !== 'type';
|
|
790
|
-
})
|
|
791
|
-
]);
|
|
792
|
-
});
|
|
793
|
-
|
|
794
|
-
// when
|
|
795
|
-
viewer.importXML(xml, function(err) {
|
|
796
|
-
|
|
797
|
-
// then
|
|
798
|
-
expect(events).to.eql([
|
|
799
|
-
[ 'import.parse.start', [ 'xml' ] ],
|
|
800
|
-
[ 'import.parse.complete', ['error', 'definitions', 'context' ] ],
|
|
801
|
-
[ 'import.render.start', [ 'definitions' ] ],
|
|
802
|
-
[ 'import.render.complete', [ 'error', 'warnings' ] ],
|
|
803
|
-
[ 'import.done', [ 'error', 'warnings' ] ]
|
|
804
|
-
]);
|
|
805
|
-
|
|
806
|
-
done(err);
|
|
807
|
-
});
|
|
808
|
-
});
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
it('should work without callback', function(done) {
|
|
812
|
-
|
|
813
|
-
// given
|
|
814
|
-
var viewer = new Viewer({ container: container });
|
|
815
|
-
|
|
816
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
817
|
-
|
|
818
|
-
// when
|
|
819
|
-
viewer.importXML(xml);
|
|
820
|
-
|
|
821
|
-
// then
|
|
822
|
-
viewer.on('import.done', function(event) {
|
|
823
|
-
done();
|
|
824
|
-
});
|
|
825
|
-
});
|
|
826
|
-
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
describe('#on', function() {
|
|
831
|
-
|
|
832
|
-
it('should fire with given three', function(done) {
|
|
833
|
-
|
|
834
|
-
// given
|
|
835
|
-
var viewer = new Viewer({ container: container });
|
|
836
|
-
|
|
837
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
838
|
-
|
|
839
|
-
// when
|
|
840
|
-
viewer.on('foo', 1000, function() {
|
|
841
|
-
return 'bar';
|
|
842
|
-
}, viewer);
|
|
843
|
-
|
|
844
|
-
// then
|
|
845
|
-
viewer.importXML(xml, function(err) {
|
|
846
|
-
var eventBus = viewer.get('eventBus');
|
|
847
|
-
|
|
848
|
-
var result = eventBus.fire('foo');
|
|
849
|
-
|
|
850
|
-
expect(result).to.equal('bar');
|
|
851
|
-
|
|
852
|
-
done();
|
|
853
|
-
});
|
|
854
|
-
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
});
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
describe('#off', function() {
|
|
861
|
-
|
|
862
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
863
|
-
|
|
864
|
-
it('should remove listener permanently', function(done) {
|
|
865
|
-
|
|
866
|
-
// given
|
|
867
|
-
var viewer = new Viewer({ container: container });
|
|
868
|
-
|
|
869
|
-
var handler = function() {
|
|
870
|
-
return 'bar';
|
|
871
|
-
};
|
|
872
|
-
|
|
873
|
-
viewer.on('foo', 1000, handler);
|
|
874
|
-
|
|
875
|
-
// when
|
|
876
|
-
viewer.off('foo');
|
|
877
|
-
|
|
878
|
-
// then
|
|
879
|
-
viewer.importXML(xml, function(err) {
|
|
880
|
-
var eventBus = viewer.get('eventBus');
|
|
881
|
-
|
|
882
|
-
var result = eventBus.fire('foo');
|
|
883
|
-
|
|
884
|
-
expect(result).not.to.exist;
|
|
885
|
-
|
|
886
|
-
done();
|
|
887
|
-
});
|
|
888
|
-
|
|
889
|
-
});
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
it('should remove listener on existing diagram instance', function(done) {
|
|
893
|
-
|
|
894
|
-
// given
|
|
895
|
-
var viewer = new Viewer({ container: container });
|
|
896
|
-
|
|
897
|
-
var handler = function() {
|
|
898
|
-
return 'bar';
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
viewer.on('foo', 1000, handler);
|
|
902
|
-
|
|
903
|
-
// when
|
|
904
|
-
viewer.importXML(xml, function(err) {
|
|
905
|
-
var eventBus = viewer.get('eventBus');
|
|
906
|
-
|
|
907
|
-
// when
|
|
908
|
-
viewer.off('foo', handler);
|
|
909
|
-
|
|
910
|
-
var result = eventBus.fire('foo');
|
|
911
|
-
|
|
912
|
-
expect(result).not.to.exist;
|
|
913
|
-
|
|
914
|
-
done();
|
|
915
|
-
});
|
|
916
|
-
|
|
917
|
-
});
|
|
918
|
-
|
|
919
|
-
});
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
describe('#destroy', function() {
|
|
923
|
-
|
|
924
|
-
it('should remove traces in document tree', function() {
|
|
925
|
-
|
|
926
|
-
// given
|
|
927
|
-
var viewer = new Viewer({
|
|
928
|
-
container: container
|
|
929
|
-
});
|
|
930
|
-
|
|
931
|
-
// when
|
|
932
|
-
viewer.destroy();
|
|
933
|
-
|
|
934
|
-
// then
|
|
935
|
-
expect(viewer.container.parentNode).not.to.exist;
|
|
936
|
-
});
|
|
937
|
-
|
|
938
|
-
});
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
describe('#attachTo', function() {
|
|
942
|
-
it('should attach the viewer', function(done) {
|
|
943
|
-
|
|
944
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
945
|
-
|
|
946
|
-
var viewer = new Viewer();
|
|
947
|
-
|
|
948
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
949
|
-
|
|
950
|
-
expect(viewer.container.parentNode).to.equal(null);
|
|
951
|
-
viewer.attachTo(container);
|
|
952
|
-
expect(viewer.container.parentNode).to.equal(container);
|
|
953
|
-
|
|
954
|
-
done(err, warnings);
|
|
955
|
-
});
|
|
956
|
-
});
|
|
957
|
-
});
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
describe('#detach', function() {
|
|
961
|
-
it('should detach the viewer', function(done) {
|
|
962
|
-
|
|
963
|
-
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
964
|
-
|
|
965
|
-
var viewer = new Viewer({ container: container });
|
|
966
|
-
|
|
967
|
-
viewer.importXML(xml, function(err, warnings) {
|
|
968
|
-
|
|
969
|
-
expect(viewer.container.parentNode).to.equal(container);
|
|
970
|
-
viewer.detach();
|
|
971
|
-
expect(viewer.container.parentNode).to.equal(null);
|
|
972
|
-
|
|
973
|
-
done(err, warnings);
|
|
974
|
-
});
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var TestContainer = require('mocha-test-container-support');
|
|
4
|
+
|
|
5
|
+
var Diagram = require('diagram-js/lib/Diagram');
|
|
6
|
+
|
|
7
|
+
var Viewer = require('../../lib/Viewer');
|
|
8
|
+
|
|
9
|
+
var inherits = require('inherits');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
describe('Viewer', function() {
|
|
13
|
+
|
|
14
|
+
var container;
|
|
15
|
+
|
|
16
|
+
beforeEach(function() {
|
|
17
|
+
container = TestContainer.get(this);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
function createViewer(xml, done) {
|
|
22
|
+
var viewer = new Viewer({ container: container });
|
|
23
|
+
|
|
24
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
25
|
+
done(err, warnings, viewer);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
it('should import simple process', function(done) {
|
|
31
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
32
|
+
createViewer(xml, done);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
it('should re-import simple process', function(done) {
|
|
37
|
+
|
|
38
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
39
|
+
|
|
40
|
+
// given
|
|
41
|
+
createViewer(xml, function(err, warnings, viewer) {
|
|
42
|
+
|
|
43
|
+
if (err) {
|
|
44
|
+
return done(err);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// when
|
|
48
|
+
// mimic re-import of same diagram
|
|
49
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
50
|
+
|
|
51
|
+
if (err) {
|
|
52
|
+
return done(err);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// then
|
|
56
|
+
expect(warnings.length).to.equal(0);
|
|
57
|
+
|
|
58
|
+
done();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
it('should be instance of Diagram', function() {
|
|
66
|
+
|
|
67
|
+
// when
|
|
68
|
+
var viewer = new Viewer({ container: container });
|
|
69
|
+
|
|
70
|
+
// then
|
|
71
|
+
expect(viewer).to.be.instanceof(Diagram);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
describe('overlay support', function() {
|
|
76
|
+
|
|
77
|
+
it('should allow to add overlays', function(done) {
|
|
78
|
+
|
|
79
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
80
|
+
|
|
81
|
+
createViewer(xml, function(err, warnings, viewer) {
|
|
82
|
+
|
|
83
|
+
// when
|
|
84
|
+
var overlays = viewer.get('overlays'),
|
|
85
|
+
elementRegistry = viewer.get('elementRegistry');
|
|
86
|
+
|
|
87
|
+
// then
|
|
88
|
+
expect(overlays).to.exist;
|
|
89
|
+
expect(elementRegistry).to.exist;
|
|
90
|
+
|
|
91
|
+
// when
|
|
92
|
+
overlays.add('SubProcess_1', {
|
|
93
|
+
position: {
|
|
94
|
+
bottom: 0,
|
|
95
|
+
right: 0
|
|
96
|
+
},
|
|
97
|
+
html: '<div style="max-width: 50px">YUP GREAT STUFF!</div>'
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// then
|
|
101
|
+
expect(overlays.get({ element: 'SubProcess_1' }).length).to.equal(1);
|
|
102
|
+
|
|
103
|
+
done(err);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
describe('error handling', function() {
|
|
112
|
+
|
|
113
|
+
function expectMessage(e, expectedMessage) {
|
|
114
|
+
|
|
115
|
+
expect(e).to.exist;
|
|
116
|
+
|
|
117
|
+
if (expectedMessage instanceof RegExp) {
|
|
118
|
+
expect(e.message).to.match(expectedMessage);
|
|
119
|
+
} else {
|
|
120
|
+
expect(e.message).to.equal(expectedMessage);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function expectWarnings(warnings, expected) {
|
|
125
|
+
|
|
126
|
+
expect(warnings.length).to.equal(expected.length);
|
|
127
|
+
|
|
128
|
+
warnings.forEach(function(w, idx) {
|
|
129
|
+
expectMessage(w, expected[idx]);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
it('should handle non-bpmn input', function(done) {
|
|
135
|
+
|
|
136
|
+
var xml = 'invalid stuff';
|
|
137
|
+
|
|
138
|
+
createViewer(xml, function(err) {
|
|
139
|
+
|
|
140
|
+
expect(err).to.exist;
|
|
141
|
+
|
|
142
|
+
expectMessage(err, /Text data outside of root node./);
|
|
143
|
+
|
|
144
|
+
done();
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
it('should handle invalid BPMNPlane#bpmnElement', function(done) {
|
|
150
|
+
|
|
151
|
+
var xml = require('../fixtures/bpmn/error/di-plane-no-bpmn-element.bpmn');
|
|
152
|
+
|
|
153
|
+
// when
|
|
154
|
+
createViewer(xml, function(err, warnings) {
|
|
155
|
+
|
|
156
|
+
// then
|
|
157
|
+
expect(err).not.to.exist;
|
|
158
|
+
|
|
159
|
+
expectWarnings(warnings, [
|
|
160
|
+
'unresolved reference <Collaboration_2>',
|
|
161
|
+
'no bpmnElement referenced in <bpmndi:BPMNPlane id="BPMNPlane_1" />',
|
|
162
|
+
'correcting missing bpmnElement ' +
|
|
163
|
+
'on <bpmndi:BPMNPlane id="BPMNPlane_1" /> ' +
|
|
164
|
+
'to <bpmn:Process id="Process_1" />'
|
|
165
|
+
]);
|
|
166
|
+
|
|
167
|
+
done();
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
it('should handle invalid namespaced element', function(done) {
|
|
173
|
+
|
|
174
|
+
var xml = require('../fixtures/bpmn/error/categoryValue.bpmn');
|
|
175
|
+
|
|
176
|
+
// when
|
|
177
|
+
createViewer(xml, function(err, warnings) {
|
|
178
|
+
|
|
179
|
+
// then
|
|
180
|
+
expect(err).not.to.exist;
|
|
181
|
+
|
|
182
|
+
expectWarnings(warnings, [
|
|
183
|
+
/unparsable content <categoryValue> detected/,
|
|
184
|
+
'unresolved reference <sid-afd7e63e-916e-4bd0-a9f0-98cbff749193>'
|
|
185
|
+
]);
|
|
186
|
+
|
|
187
|
+
done();
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
it('should handle missing namespace', function(done) {
|
|
193
|
+
|
|
194
|
+
var xml = require('../fixtures/bpmn/error/missing-namespace.bpmn');
|
|
195
|
+
|
|
196
|
+
// when
|
|
197
|
+
createViewer(xml, function(err, warnings) {
|
|
198
|
+
|
|
199
|
+
// then
|
|
200
|
+
expect(err).to.exist;
|
|
201
|
+
expect(err.message).to.eql('no process or collaboration to display');
|
|
202
|
+
|
|
203
|
+
expectWarnings(warnings, [
|
|
204
|
+
/unparsable content <collaboration> detected/,
|
|
205
|
+
'unresolved reference <Participant_1>',
|
|
206
|
+
'no bpmnElement referenced in <bpmndi:BPMNPlane id="BPMNPlane_1" />',
|
|
207
|
+
'no bpmnElement referenced in <bpmndi:BPMNShape id="BPMNShape_Participant_1" />'
|
|
208
|
+
]);
|
|
209
|
+
|
|
210
|
+
done();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
it('should handle duplicate ids', function(done) {
|
|
216
|
+
|
|
217
|
+
var xml = require('../fixtures/bpmn/error/duplicate-ids.bpmn');
|
|
218
|
+
|
|
219
|
+
// when
|
|
220
|
+
createViewer(xml, function(err, warnings) {
|
|
221
|
+
|
|
222
|
+
// then
|
|
223
|
+
expect(err).not.to.exist;
|
|
224
|
+
|
|
225
|
+
expectWarnings(warnings, [
|
|
226
|
+
/duplicate ID <test>/
|
|
227
|
+
]);
|
|
228
|
+
|
|
229
|
+
done();
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
describe('dependency injection', function() {
|
|
237
|
+
|
|
238
|
+
it('should provide self as <bpmnjs>', function(done) {
|
|
239
|
+
|
|
240
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
241
|
+
|
|
242
|
+
createViewer(xml, function(err, warnings, viewer) {
|
|
243
|
+
|
|
244
|
+
expect(viewer.get('bpmnjs')).to.equal(viewer);
|
|
245
|
+
|
|
246
|
+
done(err);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
it('should allow Diagram#get before import', function() {
|
|
252
|
+
|
|
253
|
+
// when
|
|
254
|
+
var viewer = new Viewer({ container: container });
|
|
255
|
+
|
|
256
|
+
// then
|
|
257
|
+
var eventBus = viewer.get('eventBus');
|
|
258
|
+
|
|
259
|
+
expect(eventBus).to.exist;
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
it('should keep references to services across re-import', function(done) {
|
|
264
|
+
|
|
265
|
+
// given
|
|
266
|
+
var someXML = require('../fixtures/bpmn/simple.bpmn'),
|
|
267
|
+
otherXML = require('../fixtures/bpmn/basic.bpmn');
|
|
268
|
+
|
|
269
|
+
var viewer = new Viewer({ container: container });
|
|
270
|
+
|
|
271
|
+
var eventBus = viewer.get('eventBus'),
|
|
272
|
+
canvas = viewer.get('canvas');
|
|
273
|
+
|
|
274
|
+
// when
|
|
275
|
+
viewer.importXML(someXML, function() {
|
|
276
|
+
|
|
277
|
+
// then
|
|
278
|
+
expect(viewer.get('canvas')).to.equal(canvas);
|
|
279
|
+
expect(viewer.get('eventBus')).to.equal(eventBus);
|
|
280
|
+
|
|
281
|
+
viewer.importXML(otherXML, function() {
|
|
282
|
+
|
|
283
|
+
// then
|
|
284
|
+
expect(viewer.get('canvas')).to.equal(canvas);
|
|
285
|
+
expect(viewer.get('eventBus')).to.equal(eventBus);
|
|
286
|
+
|
|
287
|
+
done();
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
describe('export', function() {
|
|
296
|
+
|
|
297
|
+
function currentTime() {
|
|
298
|
+
return new Date().getTime();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function validSVG(svg) {
|
|
302
|
+
var expectedStart = '<?xml version="1.0" encoding="utf-8"?>';
|
|
303
|
+
var expectedEnd = '</svg>';
|
|
304
|
+
|
|
305
|
+
expect(svg.indexOf(expectedStart)).to.equal(0);
|
|
306
|
+
expect(svg.indexOf(expectedEnd)).to.equal(svg.length - expectedEnd.length);
|
|
307
|
+
|
|
308
|
+
// ensure correct rendering of SVG contents
|
|
309
|
+
expect(svg.indexOf('undefined')).to.equal(-1);
|
|
310
|
+
|
|
311
|
+
// expect header to be written only once
|
|
312
|
+
expect(svg.indexOf('<svg width="100%" height="100%">')).to.equal(-1);
|
|
313
|
+
expect(svg.indexOf('<g class="viewport"')).to.equal(-1);
|
|
314
|
+
|
|
315
|
+
var parser = new DOMParser();
|
|
316
|
+
var svgNode = parser.parseFromString(svg, 'image/svg+xml');
|
|
317
|
+
|
|
318
|
+
// [comment, <!DOCTYPE svg>, svg]
|
|
319
|
+
expect(svgNode.childNodes).to.have.length(3);
|
|
320
|
+
|
|
321
|
+
// no error body
|
|
322
|
+
expect(svgNode.body).not.to.exist;
|
|
323
|
+
|
|
324
|
+
// FIXME(nre): make matcher
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
it('should export XML', function(done) {
|
|
330
|
+
|
|
331
|
+
// given
|
|
332
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
333
|
+
|
|
334
|
+
createViewer(xml, function(err, warnings, viewer) {
|
|
335
|
+
|
|
336
|
+
if (err) {
|
|
337
|
+
return done(err);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// when
|
|
341
|
+
viewer.saveXML({ format: true }, function(err, xml) {
|
|
342
|
+
|
|
343
|
+
if (err) {
|
|
344
|
+
return done(err);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// then
|
|
348
|
+
expect(xml).to.contain('<?xml version="1.0" encoding="UTF-8"?>');
|
|
349
|
+
expect(xml).to.contain('<bpmn2:definitions');
|
|
350
|
+
expect(xml).to.contain(' ');
|
|
351
|
+
|
|
352
|
+
done();
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
it('should export svg', function(done) {
|
|
360
|
+
|
|
361
|
+
// given
|
|
362
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
363
|
+
|
|
364
|
+
createViewer(xml, function(err, warnings, viewer) {
|
|
365
|
+
|
|
366
|
+
if (err) {
|
|
367
|
+
return done(err);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// when
|
|
371
|
+
viewer.saveSVG(function(err, svg) {
|
|
372
|
+
|
|
373
|
+
if (err) {
|
|
374
|
+
return done(err);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// then
|
|
378
|
+
expect(validSVG(svg)).to.be.true;
|
|
379
|
+
|
|
380
|
+
done();
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
it('should export huge svg', function(done) {
|
|
387
|
+
|
|
388
|
+
this.timeout(3000);
|
|
389
|
+
|
|
390
|
+
// given
|
|
391
|
+
var xml = require('../fixtures/bpmn/complex.bpmn');
|
|
392
|
+
|
|
393
|
+
createViewer(xml, function(err, warnings, viewer) {
|
|
394
|
+
|
|
395
|
+
if (err) {
|
|
396
|
+
return done(err);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
var time = currentTime();
|
|
400
|
+
|
|
401
|
+
// when
|
|
402
|
+
viewer.saveSVG(function(err, svg) {
|
|
403
|
+
|
|
404
|
+
if (err) {
|
|
405
|
+
return done(err);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// then
|
|
409
|
+
expect(validSVG(svg)).to.be.true;
|
|
410
|
+
|
|
411
|
+
// no svg export should not take too long
|
|
412
|
+
expect(currentTime() - time).to.be.below(1000);
|
|
413
|
+
|
|
414
|
+
done();
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
it('should remove outer-makers on export', function(done) {
|
|
421
|
+
|
|
422
|
+
// given
|
|
423
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
424
|
+
function appendTestRect(svgDoc) {
|
|
425
|
+
var rect = document.createElementNS(svgDoc.namespaceURI, 'rect');
|
|
426
|
+
rect.setAttribute('class', 'outer-bound-marker');
|
|
427
|
+
rect.setAttribute('width', 500);
|
|
428
|
+
rect.setAttribute('height', 500);
|
|
429
|
+
rect.setAttribute('x', 10000);
|
|
430
|
+
rect.setAttribute('y', 10000);
|
|
431
|
+
svgDoc.appendChild(rect);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
createViewer(xml, function(err, warnings, viewer) {
|
|
435
|
+
|
|
436
|
+
if (err) {
|
|
437
|
+
return done(err);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
var svgDoc = viewer.container.childNodes[1].childNodes[1];
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
appendTestRect(svgDoc);
|
|
445
|
+
appendTestRect(svgDoc);
|
|
446
|
+
|
|
447
|
+
expect(svgDoc.querySelectorAll('.outer-bound-marker')).to.exist;
|
|
448
|
+
|
|
449
|
+
// when
|
|
450
|
+
viewer.saveSVG(function(err, svg) {
|
|
451
|
+
|
|
452
|
+
if (err) {
|
|
453
|
+
return done(err);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
var svgDoc = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
457
|
+
svgDoc.innerHTML = svg;
|
|
458
|
+
|
|
459
|
+
// then
|
|
460
|
+
expect(validSVG(svg)).to.be.true;
|
|
461
|
+
expect(svgDoc.querySelector('.outer-bound-marker')).to.be.null;
|
|
462
|
+
|
|
463
|
+
done();
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
describe('creation', function() {
|
|
472
|
+
|
|
473
|
+
var testModules = [
|
|
474
|
+
{ logger: [ 'type', function() { this.called = true; } ] }
|
|
475
|
+
];
|
|
476
|
+
|
|
477
|
+
// given
|
|
478
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
479
|
+
|
|
480
|
+
var viewer;
|
|
481
|
+
|
|
482
|
+
afterEach(function() {
|
|
483
|
+
viewer.destroy();
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
it('should override default modules', function(done) {
|
|
487
|
+
|
|
488
|
+
// given
|
|
489
|
+
viewer = new Viewer({ container: container, modules: testModules });
|
|
490
|
+
|
|
491
|
+
// when
|
|
492
|
+
viewer.importXML(xml, function(err) {
|
|
493
|
+
|
|
494
|
+
// then
|
|
495
|
+
expect(err.message).to.equal('No provider for "bpmnImporter"! (Resolving: bpmnImporter)');
|
|
496
|
+
done();
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
it('should add module to default modules', function(done) {
|
|
503
|
+
|
|
504
|
+
// given
|
|
505
|
+
viewer = new Viewer({ container: container, additionalModules: testModules });
|
|
506
|
+
|
|
507
|
+
// when
|
|
508
|
+
viewer.importXML(xml, function(err) {
|
|
509
|
+
|
|
510
|
+
// then
|
|
511
|
+
var logger = viewer.get('logger');
|
|
512
|
+
expect(logger.called).to.be.true;
|
|
513
|
+
|
|
514
|
+
done(err);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
it('should use custom size and position', function() {
|
|
521
|
+
|
|
522
|
+
// when
|
|
523
|
+
viewer = new Viewer({
|
|
524
|
+
container: container,
|
|
525
|
+
width: 200,
|
|
526
|
+
height: 100,
|
|
527
|
+
position: 'fixed'
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
// then
|
|
531
|
+
expect(viewer.container.style.position).to.equal('fixed');
|
|
532
|
+
expect(viewer.container.style.width).to.equal('200px');
|
|
533
|
+
expect(viewer.container.style.height).to.equal('100px');
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
var camundaPackage = require('../fixtures/json/model/camunda');
|
|
538
|
+
|
|
539
|
+
it('should provide custom moddle extensions', function(done) {
|
|
540
|
+
|
|
541
|
+
var xml = require('../fixtures/bpmn/extension/camunda.bpmn');
|
|
542
|
+
|
|
543
|
+
// given
|
|
544
|
+
viewer = new Viewer({
|
|
545
|
+
container: container,
|
|
546
|
+
moddleExtensions: {
|
|
547
|
+
camunda: camundaPackage
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// when
|
|
552
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
553
|
+
|
|
554
|
+
var elementRegistry = viewer.get('elementRegistry');
|
|
555
|
+
|
|
556
|
+
var taskShape = elementRegistry.get('send'),
|
|
557
|
+
sendTask = taskShape.businessObject;
|
|
558
|
+
|
|
559
|
+
// then
|
|
560
|
+
expect(sendTask).to.exist;
|
|
561
|
+
|
|
562
|
+
var extensionElements = sendTask.extensionElements;
|
|
563
|
+
|
|
564
|
+
// receive task should be moddle extended
|
|
565
|
+
expect(sendTask.$instanceOf('camunda:ServiceTaskLike')).to.be.true;
|
|
566
|
+
|
|
567
|
+
// extension elements should provide typed element
|
|
568
|
+
expect(extensionElements).to.exist;
|
|
569
|
+
|
|
570
|
+
expect(extensionElements.values.length).to.equal(1);
|
|
571
|
+
expect(extensionElements.values[0].$instanceOf('camunda:InputOutput')).to.be.true;
|
|
572
|
+
|
|
573
|
+
done(err);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
it('should allow to add default custom moddle extensions', function(done) {
|
|
580
|
+
|
|
581
|
+
// given
|
|
582
|
+
var xml = require('../fixtures/bpmn/extension/custom.bpmn'),
|
|
583
|
+
additionalModdleDescriptors = {
|
|
584
|
+
custom: require('../fixtures/json/model/custom')
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
function CustomViewer(options) {
|
|
588
|
+
Viewer.call(this, options);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
inherits(CustomViewer, Viewer);
|
|
592
|
+
|
|
593
|
+
CustomViewer.prototype._moddleExtensions = additionalModdleDescriptors;
|
|
594
|
+
|
|
595
|
+
viewer = new CustomViewer({
|
|
596
|
+
container: container,
|
|
597
|
+
moddleExtensions: {
|
|
598
|
+
camunda: camundaPackage
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
// when
|
|
603
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
604
|
+
|
|
605
|
+
var elementRegistry = viewer.get('elementRegistry');
|
|
606
|
+
|
|
607
|
+
var taskShape = elementRegistry.get('send'),
|
|
608
|
+
sendTask = taskShape.businessObject;
|
|
609
|
+
|
|
610
|
+
// then
|
|
611
|
+
expect(sendTask).to.exist;
|
|
612
|
+
|
|
613
|
+
var extensionElements = sendTask.extensionElements;
|
|
614
|
+
|
|
615
|
+
// receive task should be moddle extended
|
|
616
|
+
expect(sendTask.$instanceOf('camunda:ServiceTaskLike')).to.be.true;
|
|
617
|
+
expect(sendTask.$instanceOf('custom:ServiceTaskGroup')).to.be.true;
|
|
618
|
+
|
|
619
|
+
// extension elements should provide typed element
|
|
620
|
+
expect(extensionElements).to.exist;
|
|
621
|
+
|
|
622
|
+
expect(extensionElements.values.length).to.equal(2);
|
|
623
|
+
expect(extensionElements.values[0].$instanceOf('camunda:InputOutput')).to.be.true;
|
|
624
|
+
|
|
625
|
+
expect(extensionElements.values[1].$instanceOf('custom:CustomSendElement')).to.be.true;
|
|
626
|
+
|
|
627
|
+
done(err);
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
it('should allow user to override default custom moddle extensions', function(done) {
|
|
634
|
+
|
|
635
|
+
// given
|
|
636
|
+
var xml = require('../fixtures/bpmn/extension/custom-override.bpmn'),
|
|
637
|
+
additionalModdleDescriptors = {
|
|
638
|
+
custom: require('../fixtures/json/model/custom')
|
|
639
|
+
},
|
|
640
|
+
customOverride = require('../fixtures/json/model/custom-override');
|
|
641
|
+
|
|
642
|
+
function CustomViewer(options) {
|
|
643
|
+
Viewer.call(this, options);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
inherits(CustomViewer, Viewer);
|
|
647
|
+
|
|
648
|
+
CustomViewer.prototype._moddleExtensions = additionalModdleDescriptors;
|
|
649
|
+
|
|
650
|
+
viewer = new CustomViewer({
|
|
651
|
+
container: container,
|
|
652
|
+
moddleExtensions: {
|
|
653
|
+
camunda: camundaPackage,
|
|
654
|
+
custom : customOverride
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
|
|
658
|
+
// when
|
|
659
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
660
|
+
|
|
661
|
+
var elementRegistry = viewer.get('elementRegistry');
|
|
662
|
+
|
|
663
|
+
var taskShape = elementRegistry.get('send'),
|
|
664
|
+
sendTask = taskShape.businessObject;
|
|
665
|
+
|
|
666
|
+
// then
|
|
667
|
+
expect(sendTask).to.exist;
|
|
668
|
+
|
|
669
|
+
var extensionElements = sendTask.extensionElements;
|
|
670
|
+
|
|
671
|
+
// receive task should be moddle extended
|
|
672
|
+
expect(sendTask.$instanceOf('camunda:ServiceTaskLike')).to.be.true;
|
|
673
|
+
expect(sendTask.$instanceOf('custom:ServiceTaskGroupOverride')).to.be.true;
|
|
674
|
+
|
|
675
|
+
// extension elements should provide typed element
|
|
676
|
+
expect(extensionElements).to.exist;
|
|
677
|
+
|
|
678
|
+
expect(extensionElements.values.length).to.equal(2);
|
|
679
|
+
expect(extensionElements.values[0].$instanceOf('camunda:InputOutput')).to.be.true;
|
|
680
|
+
|
|
681
|
+
expect(extensionElements.values[1].$instanceOf('custom:CustomSendElementOverride')).to.be.true;
|
|
682
|
+
|
|
683
|
+
done(err);
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
it('should throw error due to missing diagram', function(done) {
|
|
690
|
+
|
|
691
|
+
var xml = require('../fixtures/bpmn/empty-definitions.bpmn');
|
|
692
|
+
|
|
693
|
+
// given
|
|
694
|
+
viewer = new Viewer({ container: container, additionalModules: testModules });
|
|
695
|
+
|
|
696
|
+
// when
|
|
697
|
+
viewer.importXML(xml, function(err) {
|
|
698
|
+
|
|
699
|
+
// then
|
|
700
|
+
expect(err.message).to.eql('no diagram to display');
|
|
701
|
+
|
|
702
|
+
done();
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
describe('configuration', function() {
|
|
711
|
+
|
|
712
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
713
|
+
|
|
714
|
+
it('should configure Canvas', function(done) {
|
|
715
|
+
|
|
716
|
+
// given
|
|
717
|
+
var viewer = new Viewer({
|
|
718
|
+
container: container,
|
|
719
|
+
canvas: {
|
|
720
|
+
deferUpdate: true
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
// when
|
|
725
|
+
viewer.importXML(xml, function(err) {
|
|
726
|
+
|
|
727
|
+
var canvasConfig = viewer.get('config.canvas');
|
|
728
|
+
|
|
729
|
+
// then
|
|
730
|
+
expect(canvasConfig.deferUpdate).to.be.true;
|
|
731
|
+
|
|
732
|
+
done();
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
it('should attach the viewer to the given parent', function(done) {
|
|
738
|
+
|
|
739
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
740
|
+
|
|
741
|
+
var viewer = new Viewer({ container: container });
|
|
742
|
+
|
|
743
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
744
|
+
|
|
745
|
+
expect(viewer.container.parentNode).to.equal(container);
|
|
746
|
+
|
|
747
|
+
done(err, warnings);
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
it('should not attach the viewer automatically if no parent was given', function(done) {
|
|
752
|
+
|
|
753
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
754
|
+
|
|
755
|
+
var viewer = new Viewer();
|
|
756
|
+
|
|
757
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
758
|
+
|
|
759
|
+
expect(viewer.container.parentNode).to.equal(null);
|
|
760
|
+
|
|
761
|
+
done(err, warnings);
|
|
762
|
+
});
|
|
763
|
+
});
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
describe('#importXML', function() {
|
|
768
|
+
|
|
769
|
+
it('should emit <import.*> events', function(done) {
|
|
770
|
+
|
|
771
|
+
// given
|
|
772
|
+
var viewer = new Viewer({ container: container });
|
|
773
|
+
|
|
774
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
775
|
+
|
|
776
|
+
var events = [];
|
|
777
|
+
|
|
778
|
+
viewer.on([
|
|
779
|
+
'import.parse.start',
|
|
780
|
+
'import.parse.complete',
|
|
781
|
+
'import.render.start',
|
|
782
|
+
'import.render.complete',
|
|
783
|
+
'import.done'
|
|
784
|
+
], function(e) {
|
|
785
|
+
// log event type + event arguments
|
|
786
|
+
events.push([
|
|
787
|
+
e.type,
|
|
788
|
+
Object.keys(e).filter(function(key) {
|
|
789
|
+
return key !== 'type';
|
|
790
|
+
})
|
|
791
|
+
]);
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
// when
|
|
795
|
+
viewer.importXML(xml, function(err) {
|
|
796
|
+
|
|
797
|
+
// then
|
|
798
|
+
expect(events).to.eql([
|
|
799
|
+
[ 'import.parse.start', [ 'xml' ] ],
|
|
800
|
+
[ 'import.parse.complete', ['error', 'definitions', 'context' ] ],
|
|
801
|
+
[ 'import.render.start', [ 'definitions' ] ],
|
|
802
|
+
[ 'import.render.complete', [ 'error', 'warnings' ] ],
|
|
803
|
+
[ 'import.done', [ 'error', 'warnings' ] ]
|
|
804
|
+
]);
|
|
805
|
+
|
|
806
|
+
done(err);
|
|
807
|
+
});
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
it('should work without callback', function(done) {
|
|
812
|
+
|
|
813
|
+
// given
|
|
814
|
+
var viewer = new Viewer({ container: container });
|
|
815
|
+
|
|
816
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
817
|
+
|
|
818
|
+
// when
|
|
819
|
+
viewer.importXML(xml);
|
|
820
|
+
|
|
821
|
+
// then
|
|
822
|
+
viewer.on('import.done', function(event) {
|
|
823
|
+
done();
|
|
824
|
+
});
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
describe('#on', function() {
|
|
831
|
+
|
|
832
|
+
it('should fire with given three', function(done) {
|
|
833
|
+
|
|
834
|
+
// given
|
|
835
|
+
var viewer = new Viewer({ container: container });
|
|
836
|
+
|
|
837
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
838
|
+
|
|
839
|
+
// when
|
|
840
|
+
viewer.on('foo', 1000, function() {
|
|
841
|
+
return 'bar';
|
|
842
|
+
}, viewer);
|
|
843
|
+
|
|
844
|
+
// then
|
|
845
|
+
viewer.importXML(xml, function(err) {
|
|
846
|
+
var eventBus = viewer.get('eventBus');
|
|
847
|
+
|
|
848
|
+
var result = eventBus.fire('foo');
|
|
849
|
+
|
|
850
|
+
expect(result).to.equal('bar');
|
|
851
|
+
|
|
852
|
+
done();
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
describe('#off', function() {
|
|
861
|
+
|
|
862
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
863
|
+
|
|
864
|
+
it('should remove listener permanently', function(done) {
|
|
865
|
+
|
|
866
|
+
// given
|
|
867
|
+
var viewer = new Viewer({ container: container });
|
|
868
|
+
|
|
869
|
+
var handler = function() {
|
|
870
|
+
return 'bar';
|
|
871
|
+
};
|
|
872
|
+
|
|
873
|
+
viewer.on('foo', 1000, handler);
|
|
874
|
+
|
|
875
|
+
// when
|
|
876
|
+
viewer.off('foo');
|
|
877
|
+
|
|
878
|
+
// then
|
|
879
|
+
viewer.importXML(xml, function(err) {
|
|
880
|
+
var eventBus = viewer.get('eventBus');
|
|
881
|
+
|
|
882
|
+
var result = eventBus.fire('foo');
|
|
883
|
+
|
|
884
|
+
expect(result).not.to.exist;
|
|
885
|
+
|
|
886
|
+
done();
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
it('should remove listener on existing diagram instance', function(done) {
|
|
893
|
+
|
|
894
|
+
// given
|
|
895
|
+
var viewer = new Viewer({ container: container });
|
|
896
|
+
|
|
897
|
+
var handler = function() {
|
|
898
|
+
return 'bar';
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
viewer.on('foo', 1000, handler);
|
|
902
|
+
|
|
903
|
+
// when
|
|
904
|
+
viewer.importXML(xml, function(err) {
|
|
905
|
+
var eventBus = viewer.get('eventBus');
|
|
906
|
+
|
|
907
|
+
// when
|
|
908
|
+
viewer.off('foo', handler);
|
|
909
|
+
|
|
910
|
+
var result = eventBus.fire('foo');
|
|
911
|
+
|
|
912
|
+
expect(result).not.to.exist;
|
|
913
|
+
|
|
914
|
+
done();
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
describe('#destroy', function() {
|
|
923
|
+
|
|
924
|
+
it('should remove traces in document tree', function() {
|
|
925
|
+
|
|
926
|
+
// given
|
|
927
|
+
var viewer = new Viewer({
|
|
928
|
+
container: container
|
|
929
|
+
});
|
|
930
|
+
|
|
931
|
+
// when
|
|
932
|
+
viewer.destroy();
|
|
933
|
+
|
|
934
|
+
// then
|
|
935
|
+
expect(viewer.container.parentNode).not.to.exist;
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
describe('#attachTo', function() {
|
|
942
|
+
it('should attach the viewer', function(done) {
|
|
943
|
+
|
|
944
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
945
|
+
|
|
946
|
+
var viewer = new Viewer();
|
|
947
|
+
|
|
948
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
949
|
+
|
|
950
|
+
expect(viewer.container.parentNode).to.equal(null);
|
|
951
|
+
viewer.attachTo(container);
|
|
952
|
+
expect(viewer.container.parentNode).to.equal(container);
|
|
953
|
+
|
|
954
|
+
done(err, warnings);
|
|
955
|
+
});
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
describe('#detach', function() {
|
|
961
|
+
it('should detach the viewer', function(done) {
|
|
962
|
+
|
|
963
|
+
var xml = require('../fixtures/bpmn/simple.bpmn');
|
|
964
|
+
|
|
965
|
+
var viewer = new Viewer({ container: container });
|
|
966
|
+
|
|
967
|
+
viewer.importXML(xml, function(err, warnings) {
|
|
968
|
+
|
|
969
|
+
expect(viewer.container.parentNode).to.equal(container);
|
|
970
|
+
viewer.detach();
|
|
971
|
+
expect(viewer.container.parentNode).to.equal(null);
|
|
972
|
+
|
|
973
|
+
done(err, warnings);
|
|
974
|
+
});
|
|
975
|
+
});
|
|
976
|
+
});
|
|
977
|
+
});
|