@@ -526,6 +526,28 @@ describe('telepath: wagtail.widgets.DraftailRichTextArea', () => {
526
526
} ) ;
527
527
parentCapabilities = new Map ( ) ;
528
528
parentCapabilities . set ( 'split' , { enabled : true , fn : jest . fn ( ) } ) ;
529
+ parentCapabilities . set ( 'addSibling' , {
530
+ enabled : true ,
531
+ getBlockMax : ( ) => 5 ,
532
+ blockGroups : [
533
+ [
534
+ 'Media' ,
535
+ [
536
+ {
537
+ name : 'image_block' ,
538
+ meta : {
539
+ icon : 'image' ,
540
+ label : 'Image' ,
541
+ blockDefId : 'blockdef-1234' ,
542
+ isPreviewable : true ,
543
+ description : 'Full-width image' ,
544
+ } ,
545
+ } ,
546
+ ] ,
547
+ ] ,
548
+ ] ,
549
+ fn : jest . fn ( ) ,
550
+ } ) ;
529
551
const inputId = 'the-id' ;
530
552
boundWidget = widgetDef . render (
531
553
document . getElementById ( 'placeholder' ) ,
@@ -616,11 +638,23 @@ describe('telepath: wagtail.widgets.DraftailRichTextArea', () => {
616
638
ReactTestUtils . act ( ( ) =>
617
639
boundWidget . setCapabilityOptions ( 'split' , { enabled : true } ) ,
618
640
) ;
619
- expect ( inputElement . draftailEditor . props . commands ) . toHaveLength ( 3 ) ;
620
- expect ( inputElement . draftailEditor . props . commands [ 2 ] . items [ 0 ] . type ) . toBe (
641
+ expect ( inputElement . draftailEditor . props . commands ) . toHaveLength ( 4 ) ;
642
+ expect ( inputElement . draftailEditor . props . commands [ 3 ] . items [ 0 ] . type ) . toBe (
621
643
'split' ,
622
644
) ;
623
645
} ) ;
646
+
647
+ test ( 'configures the block chooser based on siblings capability' , ( ) => {
648
+ expect ( inputElement . draftailEditor . props . commands [ 2 ] . items [ 0 ] ) . toEqual (
649
+ expect . objectContaining ( {
650
+ icon : 'image' ,
651
+ label : 'Image' ,
652
+ blockDefId : 'blockdef-1234' ,
653
+ isPreviewable : true ,
654
+ description : 'Full-width image' ,
655
+ } ) ,
656
+ ) ;
657
+ } ) ;
624
658
} ) ;
625
659
626
660
describe ( 'telepath: wagtail.widgets.DateInput' , ( ) => {
0 commit comments