@@ -95,7 +95,6 @@ describe('Slash keydown', function () {
9595
9696 describe ( 'pressed outside editor' , function ( ) {
9797 it ( 'should not modify any text outside editor when text block is selected' , ( ) => {
98- // Create editor with an empty block
9998 cy . createEditor ( {
10099 data : {
101100 blocks : [
@@ -109,50 +108,42 @@ describe('Slash keydown', function () {
109108 } ,
110109 } ) ;
111110
112- // First click the plus button to open the toolbox
111+ cy . document ( ) . then ( ( doc ) => {
112+ const title = doc . querySelector ( 'h1' ) ;
113+
114+ if ( title ) {
115+ title . setAttribute ( 'data-cy' , 'page-title' ) ;
116+ }
117+ } ) ;
118+
119+ // Step 1
120+ // Click on the plus button and select the text option
113121 cy . get ( '[data-cy=editorjs]' )
114122 . find ( '.ce-paragraph' )
115123 . click ( ) ;
116-
124+ cy . get ( '[data-cy=editorjs]' )
125+ . find ( '.ce-toolbar__plus' )
126+ . click ( { force : true } ) ;
117127 cy . get ( '[data-cy="toolbox"] .ce-popover__container' )
118- . should ( 'not.be.visible' ) ;
128+ . contains ( 'Text' )
129+ . click ( ) ;
119130
120- // Get the heading text content before the slash key press
121- cy . get ( 'h1' )
122- . contains ( 'Editor.js test page' )
123- . invoke ( 'text' )
124- . then ( ( originalText ) => {
125- // Simulate selecting the heading text
126- cy . get ( 'h1' )
127- . contains ( 'Editor.js test page' )
128- . trigger ( 'mousedown' )
129- . trigger ( 'mouseup' ) ;
130-
131- // Press the slash key
132- cy . get ( 'h1' )
133- . contains ( 'Editor.js test page' )
134- . trigger ( 'keydown' , {
135- key : '/' ,
136- code : 'Slash' ,
137- keyCode : 191 ,
138- which : 191 ,
139- ctrlKey : false ,
140- metaKey : false
141- } ) ;
142-
143- // Verify the heading text hasn't changed
144- cy . get ( 'h1' )
145- . contains ( 'Editor.js test page' )
146- . should ( 'have.text' , originalText ) ;
147-
148- // Verify editor content hasn't changed and toolbox isn't open
149- cy . get ( '[data-cy=editorjs]' )
150- . find ( '.ce-paragraph' )
151- . should ( 'have.text' , '' ) ;
152-
153- cy . get ( '[data-cy="toolbox"] .ce-popover__container' )
154- . should ( 'not.be.visible' ) ;
155- } ) ;
131+ // Step 2
132+ // Select the 'Editor.js test page' text
133+ cy . get ( '[data-cy=page-title]' )
134+ . invoke ( 'attr' , 'contenteditable' , 'true' )
135+ . click ( )
136+ . type ( '{selectall}' )
137+ . invoke ( 'removeAttr' , 'contenteditable' ) ;
138+
139+ // Step 3
140+ // Press the Slash key
141+ cy . get ( '[data-cy=page-title]' )
142+ . trigger ( 'keydown' , { key : '/' ,
143+ code : 'Slash' ,
144+ which : 191 } ) ;
145+
146+ cy . get ( '[data-cy=page-title]' ) . should ( 'have.text' , 'Editor.js test page' ) ;
156147 } ) ;
157148 } ) ;
158149} ) ;
0 commit comments