@@ -10,6 +10,8 @@ import {
10
10
11
11
import BpmnModdle from 'bpmn-moddle' ;
12
12
13
+ import ZeebeModdle from 'zeebe-bpmn-moddle/resources/zeebe' ;
14
+
13
15
import {
14
16
insertCoreStyles
15
17
} from 'test/TestHelper' ;
@@ -37,7 +39,9 @@ const noopElement = {
37
39
}
38
40
} ;
39
41
40
- const moddle = new BpmnModdle ( ) ;
42
+ const moddle = new BpmnModdle ( {
43
+ zeebe : ZeebeModdle
44
+ } ) ;
41
45
42
46
43
47
describe ( '<PanelHeaderProvider>' , function ( ) {
@@ -184,7 +188,7 @@ describe('<PanelHeaderProvider>', function() {
184
188
185
189
describe ( '#getElementIcon' , function ( ) {
186
190
187
- it ( 'should get icon - no element templates ' , function ( ) {
191
+ it ( 'should get icon - no template ' , function ( ) {
188
192
189
193
// given
190
194
const element = createElement ( 'bpmn:Task' ) ;
@@ -201,138 +205,41 @@ describe('<PanelHeaderProvider>', function() {
201
205
} ) ;
202
206
203
207
204
- it ( 'should get icon - no template icon' , function ( ) {
205
-
206
- // given
207
- const element = createElement ( 'bpmn:Task' ) ;
208
-
209
- const elementTemplates = {
210
- get : ( ) => { return { id : 'foo' } ; } ,
211
- getTemplateId : ( ) => 'foo'
212
- } ;
213
-
214
- const context = {
215
- getService : ( ) => {
216
- return new ElementTemplates ( elementTemplates ) ;
217
- }
218
- } ;
219
-
220
- // when
221
- const result = createHeader ( { container, element, context } ) ;
222
-
223
- const iconNode = domQuery ( '.bio-properties-panel-header-icon' , result . container ) ;
224
- const templateIconNode = domQuery ( '.bio-properties-panel-header-template-icon' , iconNode ) ;
225
-
226
- // then
227
- expect ( iconNode ) . to . exist ;
228
- expect ( templateIconNode ) . to . not . exist ;
229
- } ) ;
230
-
231
-
232
208
it ( 'should get template icon - data URI' , function ( ) {
233
209
234
210
// given
235
- const element = createElement ( 'bpmn:Task' ) ;
236
-
237
- const template = {
238
- id : 'foo' ,
239
- icon : {
240
- contents : "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='100' width='100'%3E%3Ccircle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red' /%3E%3C/svg%3E"
241
- }
242
- } ;
243
-
244
- const elementTemplates = {
245
- get : ( ) => { return template ; } ,
246
- getTemplateId : ( ) => 'foo'
247
- } ;
248
-
249
- const context = {
250
- getService : ( ) => {
251
- return new ElementTemplates ( elementTemplates ) ;
252
- }
253
- } ;
211
+ const element = createElement ( 'bpmn:Task' , {
212
+ 'zeebe:modelerTemplateIcon' : "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='100' width='100'%3E%3Ccircle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red' /%3E%3C/svg%3E"
213
+ } ) ;
254
214
255
215
// when
256
- const result = createHeader ( { container, element, context } ) ;
216
+ const result = createHeader ( { container, element } ) ;
257
217
258
218
const iconNode = domQuery ( '.bio-properties-panel-header-icon' , result . container ) ;
259
219
const templateIconNode = domQuery ( '.bio-properties-panel-header-template-icon' , iconNode ) ;
260
220
261
221
// then
262
222
expect ( templateIconNode ) . to . exist ;
263
- expect ( templateIconNode . src ) . to . eql ( template . icon . contents ) ;
223
+ expect ( templateIconNode . src ) . to . eql ( element . businessObject . get ( 'zeebe:modelerTemplateIcon' ) ) ;
264
224
} ) ;
265
225
266
226
267
227
it ( 'should get template icon - https URI' , function ( ) {
268
228
269
229
// given
270
- const element = createElement ( 'bpmn:Task' ) ;
271
-
272
- const template = {
273
- id : 'foo' ,
274
- icon : {
275
- contents : 'https://camunda.com/wp-content/uploads/2020/05/logo-camunda-black.svg'
276
- }
277
- } ;
278
-
279
- const elementTemplates = {
280
- get : ( ) => { return template ; } ,
281
- getTemplateId : ( ) => 'foo'
282
- } ;
283
-
284
- const context = {
285
- getService : ( ) => {
286
- return new ElementTemplates ( elementTemplates ) ;
287
- }
288
- } ;
289
-
290
- // when
291
- const result = createHeader ( { container, element, context } ) ;
292
-
293
- const iconNode = domQuery ( '.bio-properties-panel-header-icon' , result . container ) ;
294
- const templateIconNode = domQuery ( '.bio-properties-panel-header-template-icon' , iconNode ) ;
295
-
296
- // then
297
- expect ( templateIconNode ) . to . exist ;
298
- expect ( templateIconNode . src ) . to . eql ( template . icon . contents ) ;
299
- } ) ;
300
-
301
-
302
- it ( 'should get template icon - versioned' , function ( ) {
303
-
304
- // given
305
- const element = createElement ( 'bpmn:Task' ) ;
306
-
307
- const template = {
308
- id : 'foo' ,
309
- version : 1 ,
310
- icon : {
311
- contents : "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='100' width='100'%3E%3Ccircle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red' /%3E%3C/svg%3E"
312
- }
313
- } ;
314
-
315
- const elementTemplates = {
316
- get : ( ) => { return template ; } ,
317
- getTemplateId : ( ) => 'foo' ,
318
- getTemplateVersion : ( ) => 1
319
- } ;
320
-
321
- const context = {
322
- getService : ( ) => {
323
- return new ElementTemplates ( elementTemplates ) ;
324
- }
325
- } ;
230
+ const element = createElement ( 'bpmn:Task' , {
231
+ 'zeebe:modelerTemplateIcon' : 'https://camunda.com/wp-content/uploads/2020/05/logo-camunda-black.svg'
232
+ } ) ;
326
233
327
234
// when
328
- const result = createHeader ( { container, element, context } ) ;
235
+ const result = createHeader ( { container, element } ) ;
329
236
330
237
const iconNode = domQuery ( '.bio-properties-panel-header-icon' , result . container ) ;
331
238
const templateIconNode = domQuery ( '.bio-properties-panel-header-template-icon' , iconNode ) ;
332
239
333
240
// then
334
241
expect ( templateIconNode ) . to . exist ;
335
- expect ( templateIconNode . src ) . to . eql ( template . icon . contents ) ;
242
+ expect ( templateIconNode . src ) . to . eql ( element . businessObject . get ( 'zeebe:modelerTemplateIcon' ) ) ;
336
243
} ) ;
337
244
338
245
} ) ;
0 commit comments