@@ -143,4 +143,43 @@ describe('files: Rename nodes', { testIsolation: true }, () => {
143143 . findByRole ( 'textbox' , { name : 'Filename' } )
144144 . should ( 'not.exist' )
145145 } )
146+
147+ it ( 'cancel renaming on esc press' , ( ) => {
148+ // All are visible by default
149+ getRowForFile ( 'file.txt' ) . should ( 'be.visible' )
150+
151+ triggerActionForFile ( 'file.txt' , 'rename' )
152+
153+ getRowForFile ( 'file.txt' )
154+ . findByRole ( 'textbox' , { name : 'Filename' } )
155+ . should ( 'be.visible' )
156+ . type ( '{selectAll}other.txt' )
157+ . should ( haveValidity ( '' ) )
158+ . type ( '{esc}' )
159+
160+ // See it is not renamed
161+ getRowForFile ( 'other.txt' ) . should ( 'not.exist' )
162+ getRowForFile ( 'file.txt' )
163+ . should ( 'be.visible' )
164+ . find ( 'input[type="text"]' )
165+ . should ( 'not.exist' )
166+ } )
167+
168+ it ( 'cancel on enter if no new name is entered' , ( ) => {
169+ // All are visible by default
170+ getRowForFile ( 'file.txt' ) . should ( 'be.visible' )
171+
172+ triggerActionForFile ( 'file.txt' , 'rename' )
173+
174+ getRowForFile ( 'file.txt' )
175+ . findByRole ( 'textbox' , { name : 'Filename' } )
176+ . should ( 'be.visible' )
177+ . type ( '{enter}' )
178+
179+ // See it is not renamed
180+ getRowForFile ( 'file.txt' )
181+ . should ( 'be.visible' )
182+ . find ( 'input[type="text"]' )
183+ . should ( 'not.exist' )
184+ } )
146185} )
0 commit comments