@@ -4,12 +4,12 @@ import {
4
4
InputBox ,
5
5
Key ,
6
6
TextEditor ,
7
+ until ,
7
8
VSBrowser ,
8
9
WebDriver ,
9
10
WebElement ,
10
11
WebView ,
11
- Workbench ,
12
- until ,
12
+ Workbench
13
13
} from "vscode-extension-tester" ;
14
14
15
15
import { GUIActions } from "../actions/GUI.actions" ;
@@ -103,10 +103,12 @@ describe("Keyboard Shortcuts", () => {
103
103
) ;
104
104
} ) . timeout ( DEFAULT_TIMEOUT . XL ) ;
105
105
106
- it ( "Should not create a code block when Cmd+L is pressed without text highlighted" , async ( ) => {
107
- const text = "Hello, world!" ;
106
+
107
+ it ( "Should not create a code block when Cmd+L is pressed on an empty line" , async ( ) => {
108
+ const text = "\n\nHello, world!" ;
108
109
109
110
await editor . setText ( text ) ;
111
+ await editor . moveCursor ( 1 , 1 ) ; //Move cursor to the 1st line
110
112
111
113
await GUIActions . executeFocusContinueInputShortcut ( driver ) ;
112
114
@@ -115,9 +117,54 @@ describe("Keyboard Shortcuts", () => {
115
117
await TestUtils . expectNoElement ( async ( ) => {
116
118
return GUISelectors . getInputBoxCodeBlockAtIndex ( view , 0 ) ;
117
119
} , DEFAULT_TIMEOUT . XS ) ;
120
+
121
+ } ) ;
122
+
123
+ it ( "Should create a code block when Cmd+L is pressed with text highlighted" , async ( ) => {
124
+ const text = "Hello, world!" ;
125
+
126
+ await editor . setText ( text ) ;
127
+ await editor . selectText ( text ) ;
128
+
129
+ await GUIActions . executeFocusContinueInputShortcut ( driver ) ;
130
+
131
+ ( { view } = await GUIActions . switchToReactIframe ( ) ) ;
132
+
133
+ const codeBlock = await TestUtils . waitForSuccess ( ( ) =>
134
+ GUISelectors . getInputBoxCodeBlockAtIndex ( view , 0 ) ,
135
+ ) ;
136
+ const codeblockContent = await codeBlock . getAttribute (
137
+ "data-codeblockcontent" ,
138
+ ) ;
139
+
140
+ expect ( codeblockContent ) . to . equal ( text ) ;
141
+
142
+ await GUIActions . executeFocusContinueInputShortcut ( driver ) ;
143
+ } ) . timeout ( DEFAULT_TIMEOUT . XL ) ;
144
+
145
+ it ( "Should create a code block when Cmd+L is pressed on a non-empty line" , async ( ) => {
146
+ const text = "Hello, world!" ;
147
+
148
+ await editor . setText ( text ) ;
149
+ await editor . moveCursor ( 1 , 7 ) ; //Move cursor to the 1st space
150
+
151
+ await GUIActions . executeFocusContinueInputShortcut ( driver ) ;
152
+
153
+ ( { view } = await GUIActions . switchToReactIframe ( ) ) ;
154
+
155
+ const codeBlock = await TestUtils . waitForSuccess ( ( ) =>
156
+ GUISelectors . getInputBoxCodeBlockAtIndex ( view , 0 ) ,
157
+ ) ;
158
+ const codeblockContent = await codeBlock . getAttribute (
159
+ "data-codeblockcontent" ,
160
+ ) ;
161
+
162
+ expect ( codeblockContent ) . to . equal ( text ) ;
163
+
118
164
await GUIActions . executeFocusContinueInputShortcut ( driver ) ;
119
165
} ) . timeout ( DEFAULT_TIMEOUT . XL ) ;
120
166
167
+
121
168
it ( "Fresh VS Code window → sidebar closed → cmd+L with no code highlighted → opens sidebar and focuses input → cmd+L closes sidebar" , async ( ) => {
122
169
await GUIActions . executeFocusContinueInputShortcut ( driver ) ;
123
170
( { view } = await GUIActions . switchToReactIframe ( ) ) ;
@@ -174,25 +221,4 @@ describe("Keyboard Shortcuts", () => {
174
221
expect ( await textInput . isDisplayed ( ) ) . to . equal ( false ) ;
175
222
} ) . timeout ( DEFAULT_TIMEOUT . XL ) ;
176
223
177
- it ( "Should create a code block when Cmd+L is pressed with text highlighted" , async ( ) => {
178
- const text = "Hello, world!" ;
179
-
180
- await editor . setText ( text ) ;
181
- await editor . selectText ( text ) ;
182
-
183
- await GUIActions . executeFocusContinueInputShortcut ( driver ) ;
184
-
185
- ( { view } = await GUIActions . switchToReactIframe ( ) ) ;
186
-
187
- const codeBlock = await TestUtils . waitForSuccess ( ( ) =>
188
- GUISelectors . getInputBoxCodeBlockAtIndex ( view , 0 ) ,
189
- ) ;
190
- const codeblockContent = await codeBlock . getAttribute (
191
- "data-codeblockcontent" ,
192
- ) ;
193
-
194
- expect ( codeblockContent ) . to . equal ( text ) ;
195
-
196
- await GUIActions . executeFocusContinueInputShortcut ( driver ) ;
197
- } ) . timeout ( DEFAULT_TIMEOUT . XL ) ;
198
224
} ) ;
0 commit comments