@@ -6,14 +6,13 @@ import {
6
6
newPost ,
7
7
newDesktopBrowserPage ,
8
8
getHTMLFromCodeEditor ,
9
+ pressWithModifier ,
10
+ pressTimes ,
9
11
} from '../support/utils' ;
10
12
11
13
describe ( 'adding blocks' , ( ) => {
12
- beforeAll ( async ( ) => {
13
- await newDesktopBrowserPage ( ) ;
14
- } ) ;
15
-
16
14
beforeEach ( async ( ) => {
15
+ await newDesktopBrowserPage ( ) ;
17
16
await newPost ( ) ;
18
17
} ) ;
19
18
@@ -64,4 +63,60 @@ describe( 'adding blocks', () => {
64
63
65
64
expect ( await getHTMLFromCodeEditor ( ) ) . toMatchSnapshot ( ) ;
66
65
} ) ;
66
+
67
+ it ( 'should navigate around inline boundaries' , async ( ) => {
68
+ // Add demo content
69
+ await page . click ( '.editor-default-block-appender__content' ) ;
70
+ await page . keyboard . type ( 'First' ) ;
71
+ await page . keyboard . press ( 'Enter' ) ;
72
+ await page . keyboard . type ( 'Second' ) ;
73
+ await page . keyboard . press ( 'Enter' ) ;
74
+ await page . keyboard . type ( 'Third' ) ;
75
+
76
+ // Navigate to second paragraph
77
+ await pressTimes ( 'ArrowLeft' , 6 ) ;
78
+
79
+ // Bold second paragraph text
80
+ await page . keyboard . down ( 'Shift' ) ;
81
+ await pressTimes ( 'ArrowLeft' , 6 ) ;
82
+ await page . keyboard . up ( 'Shift' ) ;
83
+ await pressWithModifier ( 'mod' , 'b' ) ;
84
+
85
+ // Arrow left from selected bold should traverse into first.
86
+ await page . keyboard . press ( 'ArrowLeft' ) ;
87
+ await page . keyboard . type ( 'After' ) ;
88
+
89
+ // Arrow right from end of first should traverse to second, *BEFORE*
90
+ // the bolded text. Another press should move within inline boundary.
91
+ await pressTimes ( 'ArrowRight' , 2 ) ;
92
+ await page . keyboard . type ( 'Inside' ) ;
93
+
94
+ // Arrow left from end of beginning of inline boundary should move to
95
+ // the outside of the inline boundary.
96
+ await pressTimes ( 'ArrowLeft' , 6 ) ;
97
+ await page . keyboard . press ( 'ArrowLeft' ) ; // Separate for emphasis.
98
+ await page . keyboard . type ( 'Before' ) ;
99
+
100
+ // Likewise, test at the end of the inline boundary for same effect.
101
+ await page . keyboard . press ( 'ArrowRight' ) ; // Move inside
102
+ await pressTimes ( 'ArrowRight' , 12 ) ;
103
+ await page . keyboard . type ( 'Inside' ) ;
104
+ await page . keyboard . press ( 'ArrowRight' ) ;
105
+
106
+ // Edge case: Verify that workaround to test for ZWSP at beginning of
107
+ // focus node does not take effect when on the right edge of inline
108
+ // boundary (thus preventing traversing to the next block by arrow).
109
+ await page . keyboard . press ( 'ArrowRight' ) ;
110
+ await page . keyboard . press ( 'ArrowLeft' ) ;
111
+
112
+ // Should be after the inline boundary again.
113
+ await page . keyboard . type ( 'After' ) ;
114
+
115
+ // Finally, ensure that ArrowRight from end of unbolded text moves to
116
+ // the last paragraph
117
+ await page . keyboard . press ( 'ArrowRight' ) ;
118
+ await page . keyboard . type ( 'Before' ) ;
119
+
120
+ expect ( await getHTMLFromCodeEditor ( ) ) . toMatchSnapshot ( ) ;
121
+ } ) ;
67
122
} ) ;
0 commit comments