@@ -670,9 +670,7 @@ test.describe('Doc Editor', () => {
670
670
) . toBeHidden ( ) ;
671
671
} ) ;
672
672
673
- test ( 'it checks if callout custom block' , async ( { page, browserName } ) => {
674
- await createDoc ( page , 'doc-toolbar' , browserName , 1 ) ;
675
-
673
+ test ( 'it checks if callout custom block' , async ( { page } ) => {
676
674
const editor = page . locator ( '.ProseMirror' ) ;
677
675
await editor . click ( ) ;
678
676
await page . locator ( '.bn-block-outer' ) . last ( ) . fill ( '/' ) ;
@@ -706,4 +704,115 @@ test.describe('Doc Editor', () => {
706
704
'pink' ,
707
705
) ;
708
706
} ) ;
707
+
708
+ test ( 'it checks callout block navigation' , async ( { page } ) => {
709
+ const editor = page . locator ( '.ProseMirror' ) ;
710
+ await editor . click ( ) ;
711
+
712
+ await page . locator ( '.bn-block-outer' ) . last ( ) . fill ( '/' ) ;
713
+ await page . getByText ( 'Add a callout block' ) . click ( ) ;
714
+
715
+ const ta = 'first callout' ;
716
+ const calloutA = page . locator ( 'div[data-content-type="callout"]' ) . first ( ) ;
717
+ const inlineA = calloutA . locator ( '.inline-content' ) ;
718
+ await inlineA . fill ( ta ) ;
719
+
720
+ await editor . press ( 'Escape' ) ;
721
+
722
+ await page . locator ( '.bn-block-outer' ) . last ( ) . fill ( '/' ) ;
723
+ await page . getByText ( 'Add a callout block' ) . click ( ) ;
724
+
725
+ const tb = 'second callout' ;
726
+ const calloutB = page . locator ( 'div[data-content-type="callout"]' ) . nth ( 1 ) ;
727
+ const inlineB = calloutB . locator ( '.inline-content' ) ;
728
+ await inlineB . fill ( tb ) ;
729
+
730
+ await editor . press ( 'Escape' ) ;
731
+
732
+ await page . locator ( '.bn-block-outer' ) . last ( ) . fill ( '/' ) ;
733
+ await page . getByText ( 'Add a callout block' ) . click ( ) ;
734
+
735
+ const tc = 'third callout' ;
736
+ const calloutC = page . locator ( 'div[data-content-type="callout"]' ) . nth ( 2 ) ;
737
+ const inlineC = calloutC . locator ( '.inline-content' ) ;
738
+ await inlineC . fill ( tc ) ;
739
+
740
+ await editor . press ( 'Escape' ) ;
741
+
742
+ // focuses the first callout
743
+ await inlineA . click ( ) ;
744
+
745
+ // arrow up and down navigation
746
+ await editor . press ( 'ArrowDown' ) ;
747
+
748
+ let sel = await inlineB . evaluate ( ( element ) =>
749
+ document
750
+ . getSelection ( )
751
+ ?. focusNode ?. parentElement ?. parentElement ?. isSameNode ( element ) ,
752
+ ) ;
753
+ expect ( sel ) . toBeTruthy ( ) ;
754
+
755
+ await editor . press ( 'ArrowDown' ) ;
756
+ sel = await inlineC . evaluate ( ( element ) =>
757
+ document
758
+ . getSelection ( )
759
+ ?. focusNode ?. parentElement ?. parentElement ?. isSameNode ( element ) ,
760
+ ) ;
761
+ expect ( sel ) . toBeTruthy ( ) ;
762
+
763
+ await editor . press ( 'ArrowUp' ) ;
764
+ sel = await inlineB . evaluate ( ( element ) =>
765
+ document
766
+ . getSelection ( )
767
+ ?. focusNode ?. parentElement ?. parentElement ?. isSameNode ( element ) ,
768
+ ) ;
769
+ expect ( sel ) . toBeTruthy ( ) ;
770
+
771
+ await editor . press ( 'ArrowUp' ) ;
772
+ sel = await inlineA . evaluate ( ( element ) =>
773
+ document
774
+ . getSelection ( )
775
+ ?. focusNode ?. parentElement ?. parentElement ?. isSameNode ( element ) ,
776
+ ) ;
777
+ expect ( sel ) . toBeTruthy ( ) ;
778
+
779
+ await editor . press ( 'ArrowUp' ) ;
780
+ await editor . press ( 'ArrowUp' ) ;
781
+ await editor . press ( 'ArrowUp' ) ;
782
+ sel = await inlineA . evaluate ( ( element ) =>
783
+ document
784
+ . getSelection ( )
785
+ ?. focusNode ?. parentElement ?. parentElement ?. isSameNode ( element ) ,
786
+ ) ;
787
+ expect ( sel ) . toBeTruthy ( ) ;
788
+
789
+ await editor . press ( 'Escape' ) ;
790
+
791
+ await inlineA . click ( ) ;
792
+ await editor . press ( 'ArrowRight' ) ;
793
+ sel = await inlineB . evaluate ( ( element ) =>
794
+ document
795
+ . getSelection ( )
796
+ ?. focusNode ?. parentElement ?. parentElement ?. isSameNode ( element ) ,
797
+ ) ;
798
+ expect ( sel ) . toBeTruthy ( ) ;
799
+
800
+ for ( let i = 0 ; i <= tb . length ; i ++ ) {
801
+ await editor . press ( 'ArrowRight' ) ;
802
+ }
803
+ sel = await inlineC . evaluate ( ( element ) =>
804
+ document
805
+ . getSelection ( )
806
+ ?. focusNode ?. parentElement ?. parentElement ?. isSameNode ( element ) ,
807
+ ) ;
808
+ expect ( sel ) . toBeTruthy ( ) ;
809
+
810
+ await editor . press ( 'ArrowLeft' ) ;
811
+ sel = await inlineB . evaluate ( ( element ) =>
812
+ document
813
+ . getSelection ( )
814
+ ?. focusNode ?. parentElement ?. parentElement ?. isSameNode ( element ) ,
815
+ ) ;
816
+ expect ( sel ) . toBeTruthy ( ) ;
817
+ } ) ;
709
818
} ) ;
0 commit comments