@umbraco/playwright-testhelpers 2.0.0-beta.64 → 2.0.0-beta.66
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/dist/lib/helpers/ContentUiHelper.d.ts +11 -1
- package/dist/lib/helpers/ContentUiHelper.js +38 -5
- package/dist/lib/helpers/ContentUiHelper.js.map +1 -1
- package/dist/lib/helpers/DataTypeApiHelper.d.ts +60 -0
- package/dist/lib/helpers/DataTypeApiHelper.js +483 -0
- package/dist/lib/helpers/DataTypeApiHelper.js.map +1 -1
- package/dist/lib/helpers/DataTypeUiHelper.d.ts +92 -0
- package/dist/lib/helpers/DataTypeUiHelper.js +290 -0
- package/dist/lib/helpers/DataTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentApiHelper.d.ts +1 -0
- package/dist/lib/helpers/DocumentApiHelper.js +14 -0
- package/dist/lib/helpers/DocumentApiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentTypeApiHelper.d.ts +1 -0
- package/dist/lib/helpers/DocumentTypeApiHelper.js +23 -1
- package/dist/lib/helpers/DocumentTypeApiHelper.js.map +1 -1
- package/dist/lib/helpers/StylesheetApiHelper.d.ts +1 -0
- package/dist/lib/helpers/StylesheetApiHelper.js +8 -6
- package/dist/lib/helpers/StylesheetApiHelper.js.map +1 -1
- package/dist/lib/helpers/UiBaseLocators.d.ts +5 -4
- package/dist/lib/helpers/UiBaseLocators.js +16 -11
- package/dist/lib/helpers/UiBaseLocators.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -7
|
@@ -184,6 +184,489 @@ class DataTypeApiHelper {
|
|
|
184
184
|
.build();
|
|
185
185
|
return await this.save(dataType);
|
|
186
186
|
}
|
|
187
|
+
async createCheckboxListDataType(name, options) {
|
|
188
|
+
await this.ensureNameNotExists(name);
|
|
189
|
+
const dataType = new json_models_builders_1.CheckboxListDataTypeBuilder()
|
|
190
|
+
.withName(name)
|
|
191
|
+
.withItems(options)
|
|
192
|
+
.build();
|
|
193
|
+
return await this.save(dataType);
|
|
194
|
+
}
|
|
195
|
+
async createContentPickerDataTypeWithStartNode(name, startNodeId) {
|
|
196
|
+
await this.ensureNameNotExists(name);
|
|
197
|
+
const dataType = new json_models_builders_1.ContentPickerDataTypeBuilder()
|
|
198
|
+
.withName(name)
|
|
199
|
+
.withStartNodeId(startNodeId)
|
|
200
|
+
.build();
|
|
201
|
+
return await this.save(dataType);
|
|
202
|
+
}
|
|
203
|
+
async createContentPickerDataTypeWithShowOpenButton(name) {
|
|
204
|
+
await this.ensureNameNotExists(name);
|
|
205
|
+
const dataType = new json_models_builders_1.ContentPickerDataTypeBuilder()
|
|
206
|
+
.withName(name)
|
|
207
|
+
.withShowOpenButton(true)
|
|
208
|
+
.build();
|
|
209
|
+
return await this.save(dataType);
|
|
210
|
+
}
|
|
211
|
+
async createContentPickerDataTypeWithIgnoreUserStartNodes(name, startNodeId) {
|
|
212
|
+
await this.ensureNameNotExists(name);
|
|
213
|
+
const dataType = new json_models_builders_1.ContentPickerDataTypeBuilder()
|
|
214
|
+
.withName(name)
|
|
215
|
+
.withStartNodeId(startNodeId)
|
|
216
|
+
.withIgnoreUserStartNodes(true)
|
|
217
|
+
.build();
|
|
218
|
+
return await this.save(dataType);
|
|
219
|
+
}
|
|
220
|
+
async createDatePickerDataType(name, dateFormat) {
|
|
221
|
+
await this.ensureNameNotExists(name);
|
|
222
|
+
const dataType = new json_models_builders_1.DatePickerDataTypeBuilder()
|
|
223
|
+
.withName(name)
|
|
224
|
+
.withFormat(dateFormat)
|
|
225
|
+
.build();
|
|
226
|
+
return await this.save(dataType);
|
|
227
|
+
}
|
|
228
|
+
async createDropdownDataType(name, isMultiple, options) {
|
|
229
|
+
await this.ensureNameNotExists(name);
|
|
230
|
+
const dataType = new json_models_builders_1.DropdownDataTypeBuilder()
|
|
231
|
+
.withName(name)
|
|
232
|
+
.withMultiple(isMultiple)
|
|
233
|
+
.withItems(options)
|
|
234
|
+
.build();
|
|
235
|
+
return await this.save(dataType);
|
|
236
|
+
}
|
|
237
|
+
// BlockListEditor
|
|
238
|
+
async createEmptyBlockListDataType(name) {
|
|
239
|
+
await this.ensureNameNotExists(name);
|
|
240
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
241
|
+
.withName(name)
|
|
242
|
+
.build();
|
|
243
|
+
return await this.save(blockList);
|
|
244
|
+
}
|
|
245
|
+
async createBlockListDataTypeWithABlock(name, contentElementTypeId) {
|
|
246
|
+
await this.ensureNameNotExists(name);
|
|
247
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
248
|
+
.withName(name)
|
|
249
|
+
.addBlock()
|
|
250
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
251
|
+
.done()
|
|
252
|
+
.build();
|
|
253
|
+
return await this.save(blockList);
|
|
254
|
+
}
|
|
255
|
+
async createBlockListDataTypeWithContentAndSettingsElementType(name, contentElementTypeId, settingsElementTypeId) {
|
|
256
|
+
await this.ensureNameNotExists(name);
|
|
257
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
258
|
+
.withName(name)
|
|
259
|
+
.addBlock()
|
|
260
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
261
|
+
.withSettingsElementTypeKey(settingsElementTypeId)
|
|
262
|
+
.done()
|
|
263
|
+
.build();
|
|
264
|
+
return await this.save(blockList);
|
|
265
|
+
}
|
|
266
|
+
async createBlockListDataTypeWithMinAndMaxAmount(name, minAmount = 0, maxAmount = 0) {
|
|
267
|
+
await this.ensureNameNotExists(name);
|
|
268
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
269
|
+
.withName(name)
|
|
270
|
+
.withMinValue(minAmount)
|
|
271
|
+
.withMaxValue(maxAmount)
|
|
272
|
+
.build();
|
|
273
|
+
return await this.save(blockList);
|
|
274
|
+
}
|
|
275
|
+
async createBlockListDataTypeWithSingleBlockMode(name, enabled) {
|
|
276
|
+
await this.ensureNameNotExists(name);
|
|
277
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
278
|
+
.withName(name)
|
|
279
|
+
.withSingleBlockMode(enabled)
|
|
280
|
+
.build();
|
|
281
|
+
return await this.save(blockList);
|
|
282
|
+
}
|
|
283
|
+
async createBlockListDataTypeWithLiveEditingMode(name, enabled) {
|
|
284
|
+
await this.ensureNameNotExists(name);
|
|
285
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
286
|
+
.withName(name)
|
|
287
|
+
.withLiveEditing(enabled)
|
|
288
|
+
.build();
|
|
289
|
+
return await this.save(blockList);
|
|
290
|
+
}
|
|
291
|
+
async createBlockListDataTypeWithInlineEditingMode(name, enabled) {
|
|
292
|
+
await this.ensureNameNotExists(name);
|
|
293
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
294
|
+
.withName(name)
|
|
295
|
+
.withInlineEditingAsDefault(enabled)
|
|
296
|
+
.build();
|
|
297
|
+
return await this.save(blockList);
|
|
298
|
+
}
|
|
299
|
+
async createBlockListDataTypeWithPropertyEditorWidth(name, width) {
|
|
300
|
+
await this.ensureNameNotExists(name);
|
|
301
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
302
|
+
.withName(name)
|
|
303
|
+
.withMaxPropertyWidth(width)
|
|
304
|
+
.build();
|
|
305
|
+
return await this.save(blockList);
|
|
306
|
+
}
|
|
307
|
+
async createBlockListWithBlockWithEditorAppearance(name, elementTypeId, label = '', overlaySize = 'small') {
|
|
308
|
+
await this.ensureNameNotExists(name);
|
|
309
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
310
|
+
.withName(name)
|
|
311
|
+
.addBlock()
|
|
312
|
+
.withContentElementTypeKey(elementTypeId)
|
|
313
|
+
.withLabel(label)
|
|
314
|
+
.withEditorSize(overlaySize)
|
|
315
|
+
.done()
|
|
316
|
+
.build();
|
|
317
|
+
return await this.save(blockList);
|
|
318
|
+
}
|
|
319
|
+
async createBlockListWithBlockWithCatalogueAppearance(name, elementTypeId, backgroundColor = '', iconColor = '', customStylesheet = '') {
|
|
320
|
+
await this.ensureNameNotExists(name);
|
|
321
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
322
|
+
.withName(name)
|
|
323
|
+
.addBlock()
|
|
324
|
+
.withContentElementTypeKey(elementTypeId)
|
|
325
|
+
.withBackgroundColor(backgroundColor)
|
|
326
|
+
.withIconColor(iconColor)
|
|
327
|
+
.withStylesheet(customStylesheet)
|
|
328
|
+
.done()
|
|
329
|
+
.build();
|
|
330
|
+
return await this.save(blockList);
|
|
331
|
+
}
|
|
332
|
+
async createBlockListWithBlockWithHideContentEditor(name, elementTypeId, hideContentEditor) {
|
|
333
|
+
await this.ensureNameNotExists(name);
|
|
334
|
+
const blockList = new json_models_builders_1.BlockListDataTypeBuilder()
|
|
335
|
+
.withName(name)
|
|
336
|
+
.addBlock()
|
|
337
|
+
.withContentElementTypeKey(elementTypeId)
|
|
338
|
+
.withHideContentEditor(hideContentEditor)
|
|
339
|
+
.done()
|
|
340
|
+
.build();
|
|
341
|
+
return await this.save(blockList);
|
|
342
|
+
}
|
|
343
|
+
async isSingleBlockModeEnabledForBlockList(blockListName, enabled) {
|
|
344
|
+
const blockList = await this.getByName(blockListName);
|
|
345
|
+
const singleBlockModeValue = blockList.values.find(value => value.alias === 'useSingleBlockMode');
|
|
346
|
+
return singleBlockModeValue?.value === enabled;
|
|
347
|
+
}
|
|
348
|
+
async isInlineEditingModeEnabledForBlockList(blockListName, enabled) {
|
|
349
|
+
const blockList = await this.getByName(blockListName);
|
|
350
|
+
const inlineEditingModeValue = blockList.values.find(value => value.alias === 'useInlineEditingAsDefault');
|
|
351
|
+
return inlineEditingModeValue?.value === enabled;
|
|
352
|
+
}
|
|
353
|
+
// Block Grid
|
|
354
|
+
async createEmptyBlockGrid(blockGridName) {
|
|
355
|
+
await this.ensureNameNotExists(blockGridName);
|
|
356
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
357
|
+
.withName(blockGridName)
|
|
358
|
+
.build();
|
|
359
|
+
return await this.save(blockGrid);
|
|
360
|
+
}
|
|
361
|
+
async createBlockGridWithABlock(blockGridName, contentElementTypeId) {
|
|
362
|
+
await this.ensureNameNotExists(blockGridName);
|
|
363
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
364
|
+
.withName(blockGridName)
|
|
365
|
+
.addBlock()
|
|
366
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
367
|
+
.done()
|
|
368
|
+
.build();
|
|
369
|
+
return await this.save(blockGrid);
|
|
370
|
+
}
|
|
371
|
+
async createBlockGridWithABlockInAGroup(blockGridName, contentElementTypeId, groupName) {
|
|
372
|
+
await this.ensureNameNotExists(blockGridName);
|
|
373
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
374
|
+
.withName(blockGridName)
|
|
375
|
+
.addBlockGroup()
|
|
376
|
+
.withName(groupName)
|
|
377
|
+
.done()
|
|
378
|
+
.addBlock()
|
|
379
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
380
|
+
.withGroupName(groupName)
|
|
381
|
+
.done()
|
|
382
|
+
.build();
|
|
383
|
+
return await this.save(blockGrid);
|
|
384
|
+
}
|
|
385
|
+
async createBlockGridWithMinAndMaxAmount(blockGridName, minAmount = 0, maxAmount = 0) {
|
|
386
|
+
await this.ensureNameNotExists(blockGridName);
|
|
387
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
388
|
+
.withName(blockGridName)
|
|
389
|
+
.withMinValue(minAmount)
|
|
390
|
+
.withMaxValue(maxAmount)
|
|
391
|
+
.build();
|
|
392
|
+
return await this.save(blockGrid);
|
|
393
|
+
}
|
|
394
|
+
async createBlockGridWithLiveEditingMode(blockGridName, enabled) {
|
|
395
|
+
await this.ensureNameNotExists(blockGridName);
|
|
396
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
397
|
+
.withName(blockGridName)
|
|
398
|
+
.withLiveEditing(enabled)
|
|
399
|
+
.build();
|
|
400
|
+
return await this.save(blockGrid);
|
|
401
|
+
}
|
|
402
|
+
async createBlockGridWithPropertyEditorWidth(blockGridName, width) {
|
|
403
|
+
await this.ensureNameNotExists(blockGridName);
|
|
404
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
405
|
+
.withName(blockGridName)
|
|
406
|
+
.withMaxPropertyWidth(width)
|
|
407
|
+
.build();
|
|
408
|
+
return await this.save(blockGrid);
|
|
409
|
+
}
|
|
410
|
+
async createBlockGridWithCreateButtonLabel(blockGridName, label = '') {
|
|
411
|
+
await this.ensureNameNotExists(blockGridName);
|
|
412
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
413
|
+
.withName(blockGridName)
|
|
414
|
+
.withCreateLabel(label)
|
|
415
|
+
.build();
|
|
416
|
+
return await this.save(blockGrid);
|
|
417
|
+
}
|
|
418
|
+
async createBlockGridWithGridColumns(blockGridName, columns = 12) {
|
|
419
|
+
await this.ensureNameNotExists(blockGridName);
|
|
420
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
421
|
+
.withName(blockGridName)
|
|
422
|
+
.withGridColumns(columns)
|
|
423
|
+
.build();
|
|
424
|
+
return await this.save(blockGrid);
|
|
425
|
+
}
|
|
426
|
+
async createBlockGridWithLayoutStylesheet(blockGridName, stylesheet = ['']) {
|
|
427
|
+
await this.ensureNameNotExists(blockGridName);
|
|
428
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
429
|
+
.withName(blockGridName)
|
|
430
|
+
.withLayoutStylesheet(stylesheet)
|
|
431
|
+
.build();
|
|
432
|
+
return await this.save(blockGrid);
|
|
433
|
+
}
|
|
434
|
+
async createBlockGridWithAnAreaInABlock(blockGridName, contentElementTypeId, areaAlias = 'area', createButtonLabel = '', columnSpan = 6, rowSpan = 1, minAllowed = 0, maxAllowed = 2) {
|
|
435
|
+
await this.ensureNameNotExists(blockGridName);
|
|
436
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
437
|
+
.withName(blockGridName)
|
|
438
|
+
.addBlock()
|
|
439
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
440
|
+
.addArea()
|
|
441
|
+
.withAlias(areaAlias)
|
|
442
|
+
.withCreateLabel(createButtonLabel)
|
|
443
|
+
.withColumnSpan(columnSpan)
|
|
444
|
+
.withRowSpan(rowSpan)
|
|
445
|
+
.withMinAllowed(minAllowed)
|
|
446
|
+
.withMaxAllowed(maxAllowed)
|
|
447
|
+
.done()
|
|
448
|
+
.done()
|
|
449
|
+
.build();
|
|
450
|
+
return await this.save(blockGrid);
|
|
451
|
+
}
|
|
452
|
+
async createBlockGridWithAdvancedSettingsInBlock(blockGridName, contentElementTypeId, customViewPath = '', customStylesheetPath = '', overlaySize = 'small', inlineEditing = false, hideContentEditor = false) {
|
|
453
|
+
await this.ensureNameNotExists(blockGridName);
|
|
454
|
+
const encodedViewPath = await this.api.stylesheet.encodeStylesheetPath(customViewPath);
|
|
455
|
+
const encodedStylesheetPath = await this.api.stylesheet.encodeStylesheetPath(customStylesheetPath);
|
|
456
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
457
|
+
.withName(blockGridName)
|
|
458
|
+
.addBlock()
|
|
459
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
460
|
+
.withView(encodedViewPath)
|
|
461
|
+
.withStylesheet(encodedStylesheetPath)
|
|
462
|
+
.withEditorSize(overlaySize)
|
|
463
|
+
.withInlineEditing(inlineEditing)
|
|
464
|
+
.withHideContentEditor(hideContentEditor)
|
|
465
|
+
.done()
|
|
466
|
+
.build();
|
|
467
|
+
return await this.save(blockGrid);
|
|
468
|
+
}
|
|
469
|
+
async createBlockGridWithCatalogueAppearanceInBlock(blockGridName, contentElementTypeId, backgroundColor = '', iconColor = '', thumbnail = '') {
|
|
470
|
+
await this.ensureNameNotExists(blockGridName);
|
|
471
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
472
|
+
.withName(blockGridName)
|
|
473
|
+
.addBlock()
|
|
474
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
475
|
+
.withBackgroundColor(backgroundColor)
|
|
476
|
+
.withIconColor(iconColor)
|
|
477
|
+
.withThumbnail(thumbnail)
|
|
478
|
+
.done()
|
|
479
|
+
.build();
|
|
480
|
+
return await this.save(blockGrid);
|
|
481
|
+
}
|
|
482
|
+
async createBlockGridWithContentAndSettingsElementType(blockGridName, contentElementTypeId, settingsElementTypeId) {
|
|
483
|
+
await this.ensureNameNotExists(blockGridName);
|
|
484
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
485
|
+
.withName(blockGridName)
|
|
486
|
+
.addBlock()
|
|
487
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
488
|
+
.withSettingsElementTypeKey(settingsElementTypeId)
|
|
489
|
+
.done()
|
|
490
|
+
.build();
|
|
491
|
+
return await this.save(blockGrid);
|
|
492
|
+
}
|
|
493
|
+
async createBlockGridWithLabel(blockGridName, contentElementTypeId, label) {
|
|
494
|
+
await this.ensureNameNotExists(blockGridName);
|
|
495
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
496
|
+
.withName(blockGridName)
|
|
497
|
+
.addBlock()
|
|
498
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
499
|
+
.withLabel(label)
|
|
500
|
+
.done()
|
|
501
|
+
.build();
|
|
502
|
+
return await this.save(blockGrid);
|
|
503
|
+
}
|
|
504
|
+
async createBlockGridWithPermissions(blockGridName, contentElementTypeId, toAllowInRoot = false, toAllowInAreas = false) {
|
|
505
|
+
await this.ensureNameNotExists(blockGridName);
|
|
506
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
507
|
+
.withName(blockGridName)
|
|
508
|
+
.addBlock()
|
|
509
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
510
|
+
.withAllowAtRoot(toAllowInRoot)
|
|
511
|
+
.withAllowInAreas(toAllowInAreas)
|
|
512
|
+
.done()
|
|
513
|
+
.build();
|
|
514
|
+
return await this.save(blockGrid);
|
|
515
|
+
}
|
|
516
|
+
async createBlockGridWithSizeOptions(blockGridName, contentElementTypeId, columnSpans = 0, minRowSpan = 0, maxRowSpan = 12) {
|
|
517
|
+
await this.ensureNameNotExists(blockGridName);
|
|
518
|
+
const blockGrid = new json_models_builders_1.BlockGridDataTypeBuilder()
|
|
519
|
+
.withName(blockGridName)
|
|
520
|
+
.addBlock()
|
|
521
|
+
.withContentElementTypeKey(contentElementTypeId)
|
|
522
|
+
.addColumnSpanOptions(columnSpans)
|
|
523
|
+
.withMinRowSpan(minRowSpan)
|
|
524
|
+
.withMaxRowSpan(maxRowSpan)
|
|
525
|
+
.done()
|
|
526
|
+
.build();
|
|
527
|
+
return await this.save(blockGrid);
|
|
528
|
+
}
|
|
529
|
+
async doesBlockEditorContainBlocksWithContentTypeIds(blockEditorName, elementTypeIds) {
|
|
530
|
+
if (!elementTypeIds || elementTypeIds.length === 0) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
const blockEditor = await this.getByName(blockEditorName);
|
|
534
|
+
const blocksValue = blockEditor.values.find(value => value.alias === 'blocks');
|
|
535
|
+
if (!blocksValue || blocksValue.value.length === 0) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
const contentElementTypeKeys = blocksValue.value.map(block => block.contentElementTypeKey);
|
|
539
|
+
return elementTypeIds.every(id => contentElementTypeKeys.includes(id));
|
|
540
|
+
}
|
|
541
|
+
async doesBlockEditorContainBlocksWithSettingsTypeIds(blockEditorName, elementTypeIds) {
|
|
542
|
+
if (!elementTypeIds || elementTypeIds.length === 0) {
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
const blockEditor = await this.getByName(blockEditorName);
|
|
546
|
+
const blocksValue = blockEditor.values.find(value => value.alias === 'blocks');
|
|
547
|
+
if (!blocksValue || blocksValue.value.length === 0) {
|
|
548
|
+
return false;
|
|
549
|
+
}
|
|
550
|
+
const settingsElementTypeKeys = blocksValue.value.map(block => block.settingsElementTypeKey);
|
|
551
|
+
return elementTypeIds.every(id => settingsElementTypeKeys.includes(id));
|
|
552
|
+
}
|
|
553
|
+
async isLiveEditingModeEnabledForBlockEditor(blockEditorName, enabled) {
|
|
554
|
+
const blockEditor = await this.getByName(blockEditorName);
|
|
555
|
+
const liveEditingModeValue = blockEditor.values.find(value => value.alias === 'useLiveEditing');
|
|
556
|
+
return liveEditingModeValue?.value === enabled;
|
|
557
|
+
}
|
|
558
|
+
async doesMaxPropertyContainWidthForBlockEditor(blockEditorName, width) {
|
|
559
|
+
const blockEditor = await this.getByName(blockEditorName);
|
|
560
|
+
const maxPropertyWidthValue = blockEditor.values.find(value => value.alias === 'maxPropertyWidth');
|
|
561
|
+
return maxPropertyWidthValue?.value === width;
|
|
562
|
+
}
|
|
563
|
+
async doesBlockEditorBlockContainLabel(blockName, elementTypeKey, label) {
|
|
564
|
+
const block = await this.getBlockWithContentElementTypeId(blockName, elementTypeKey);
|
|
565
|
+
return block.label === label;
|
|
566
|
+
}
|
|
567
|
+
async doesBlockGridGroupContainCorrectBlocks(blockGridName, groupName, elementTypeIds) {
|
|
568
|
+
if (!elementTypeIds || elementTypeIds.length === 0) {
|
|
569
|
+
return false;
|
|
570
|
+
}
|
|
571
|
+
const blockEditor = await this.getByName(blockGridName);
|
|
572
|
+
// We need to get the GroupKey, so we can use it to find the blocks that use the Key.
|
|
573
|
+
const blockGroupsValue = blockEditor.values.find(value => value.alias === 'blockGroups');
|
|
574
|
+
if (!blockGroupsValue || blockGroupsValue.value.length === 0) {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
const blockGroupKey = blockGroupsValue.value.find(blockGroup => blockGroup.name === groupName).key;
|
|
578
|
+
const blocksValue = blockEditor.values.find(value => value.alias === 'blocks');
|
|
579
|
+
if (!blocksValue || blocksValue.value.length === 0) {
|
|
580
|
+
return false;
|
|
581
|
+
}
|
|
582
|
+
const blocksWithGroupKey = blocksValue.value.filter(block => block.groupKey === blockGroupKey);
|
|
583
|
+
return elementTypeIds.every(id => blocksWithGroupKey.some(block => block.contentElementTypeKey === id));
|
|
584
|
+
}
|
|
585
|
+
async doesBlockGridContainCreateButtonLabel(blockGridName, label) {
|
|
586
|
+
const blockEditor = await this.getByName(blockGridName);
|
|
587
|
+
const createLabelValue = blockEditor.values.find(value => value.alias === 'createLabel');
|
|
588
|
+
return createLabelValue?.value === label;
|
|
589
|
+
}
|
|
590
|
+
async doesBlockGridContainGridColumns(blockGridName, columns) {
|
|
591
|
+
const blockEditor = await this.getByName(blockGridName);
|
|
592
|
+
const gridColumnsValue = blockEditor.values.find(value => value.alias === 'gridColumns');
|
|
593
|
+
return gridColumnsValue?.value === columns;
|
|
594
|
+
}
|
|
595
|
+
async doesBlockEditorBlockHaveAllowInRootEnabled(blockGridName, elementTypeKey) {
|
|
596
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
597
|
+
return block.allowAtRoot;
|
|
598
|
+
}
|
|
599
|
+
async doesBlockEditorBlockHaveAllowInAreasEnabled(blockGridName, elementTypeKey) {
|
|
600
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
601
|
+
return block.allowInAreas;
|
|
602
|
+
}
|
|
603
|
+
async doesBlockEditorBlockContainColumnSpanOptions(blockGridName, elementTypeKey, expectedColumnSpans) {
|
|
604
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
605
|
+
// If the block does not have any columnSpanOptions, and we are not expecting any, return true
|
|
606
|
+
if (block.columnSpanOptions.length === 0 && expectedColumnSpans.length === 0) {
|
|
607
|
+
return true;
|
|
608
|
+
}
|
|
609
|
+
const columnSpans = block.columnSpanOptions.map(option => option.columnSpan);
|
|
610
|
+
return expectedColumnSpans.every(span => columnSpans.includes(span)) && columnSpans.every(span => expectedColumnSpans.includes(span));
|
|
611
|
+
}
|
|
612
|
+
async doesBlockEditorBlockContainRowSpanOptions(blockGridName, elementTypeKey, minRowSpan, maxRowSpan) {
|
|
613
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
614
|
+
return block.rowMinSpan === minRowSpan && block.rowMaxSpan === maxRowSpan;
|
|
615
|
+
}
|
|
616
|
+
async doesBlockEditorBlockContainAreaGridColumns(blockGridName, elementTypeKey, areaGridColumns) {
|
|
617
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
618
|
+
return block.areaGridColumns === areaGridColumns;
|
|
619
|
+
}
|
|
620
|
+
async doesBlockEditorBlockContainAreaWithAlias(blockGridName, elementTypeKey, areaAlias = 'area') {
|
|
621
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
622
|
+
return block.areas.find(area => area.alias === areaAlias);
|
|
623
|
+
}
|
|
624
|
+
async doesBlockEditorBlockContainAreaWithCreateButtonLabel(blockGridName, elementTypeKey, areaAlias = 'area', createButtonLabel) {
|
|
625
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
626
|
+
return block.areas.find(area => area.createLabel === createButtonLabel && area.alias === areaAlias);
|
|
627
|
+
}
|
|
628
|
+
async doesBlockEditorBlockContainAreaWithMinAllowed(blockGridName, elementTypeKey, areaAlias = 'area', minAllowed) {
|
|
629
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
630
|
+
return block.areas.find(area => area.minAllowed === minAllowed && area.alias === areaAlias);
|
|
631
|
+
}
|
|
632
|
+
async doesBlockEditorBlockContainAreaWithMaxAllowed(blockGridName, elementTypeKey, areaAlias = 'area', maxAllowed) {
|
|
633
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
634
|
+
return block.areas.find(area => area.maxAllowed === maxAllowed && area.alias === areaAlias);
|
|
635
|
+
}
|
|
636
|
+
async doesBlockEditorBlockContainStylesheet(blockGridName, elementTypeKey, stylesheetPath) {
|
|
637
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
638
|
+
const encodedSecondStylesheetPath = await this.api.stylesheet.encodeStylesheetPath(stylesheetPath);
|
|
639
|
+
return block.stylesheet[0] === encodedSecondStylesheetPath;
|
|
640
|
+
}
|
|
641
|
+
async doesBlockEditorBlockContainOverlaySize(blockGridName, elementTypeKey, overlaySize) {
|
|
642
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
643
|
+
return block.editorSize === overlaySize;
|
|
644
|
+
}
|
|
645
|
+
async doesBlockEditorBlockContainInlineEditing(blockGridName, elementTypeKey, inlineEditing) {
|
|
646
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
647
|
+
return block.inlineEditing === inlineEditing;
|
|
648
|
+
}
|
|
649
|
+
async doesBlockEditorBlockContainHideContentEditor(blockGridName, elementTypeKey, hideContentEditor) {
|
|
650
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
651
|
+
return block.hideContentEditor === hideContentEditor;
|
|
652
|
+
}
|
|
653
|
+
async doesBlockEditorBlockContainBackgroundColor(blockGridName, elementTypeKey, backgroundColor) {
|
|
654
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
655
|
+
return block.backgroundColor === backgroundColor;
|
|
656
|
+
}
|
|
657
|
+
async doesBlockEditorBlockContainIconColor(blockGridName, elementTypeKey, iconColor) {
|
|
658
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
659
|
+
return block.iconColor === iconColor;
|
|
660
|
+
}
|
|
661
|
+
async doesBlockEditorBlockContainThumbnail(blockGridName, elementTypeKey, thumbnail) {
|
|
662
|
+
const block = await this.getBlockWithContentElementTypeId(blockGridName, elementTypeKey);
|
|
663
|
+
return block.thumbnail === thumbnail;
|
|
664
|
+
}
|
|
665
|
+
async getBlockWithContentElementTypeId(blockGridName, contentElementTypeKey) {
|
|
666
|
+
const blockEditor = await this.getByName(blockGridName);
|
|
667
|
+
const blocks = blockEditor.values.find(value => value.alias === 'blocks');
|
|
668
|
+
return blocks.value.find(block => block.contentElementTypeKey === contentElementTypeKey);
|
|
669
|
+
}
|
|
187
670
|
}
|
|
188
671
|
exports.DataTypeApiHelper = DataTypeApiHelper;
|
|
189
672
|
//# sourceMappingURL=DataTypeApiHelper.js.map
|