Skip to content

Commit 1696eb2

Browse files
committed
Fix KeyboardShortcuts tests
Signed-off-by: Fred Bricon <[email protected]>
1 parent 8cf5004 commit 1696eb2

File tree

1 file changed

+51
-25
lines changed

1 file changed

+51
-25
lines changed

extensions/vscode/e2e/tests/KeyboardShortcuts.test.ts

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import {
44
InputBox,
55
Key,
66
TextEditor,
7+
until,
78
VSBrowser,
89
WebDriver,
910
WebElement,
1011
WebView,
11-
Workbench,
12-
until,
12+
Workbench
1313
} from "vscode-extension-tester";
1414

1515
import { GUIActions } from "../actions/GUI.actions";
@@ -103,10 +103,12 @@ describe("Keyboard Shortcuts", () => {
103103
);
104104
}).timeout(DEFAULT_TIMEOUT.XL);
105105

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!";
108109

109110
await editor.setText(text);
111+
await editor.moveCursor(1, 1);//Move cursor to the 1st line
110112

111113
await GUIActions.executeFocusContinueInputShortcut(driver);
112114

@@ -115,9 +117,54 @@ describe("Keyboard Shortcuts", () => {
115117
await TestUtils.expectNoElement(async () => {
116118
return GUISelectors.getInputBoxCodeBlockAtIndex(view, 0);
117119
}, 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+
118164
await GUIActions.executeFocusContinueInputShortcut(driver);
119165
}).timeout(DEFAULT_TIMEOUT.XL);
120166

167+
121168
it("Fresh VS Code window → sidebar closed → cmd+L with no code highlighted → opens sidebar and focuses input → cmd+L closes sidebar", async () => {
122169
await GUIActions.executeFocusContinueInputShortcut(driver);
123170
({ view } = await GUIActions.switchToReactIframe());
@@ -174,25 +221,4 @@ describe("Keyboard Shortcuts", () => {
174221
expect(await textInput.isDisplayed()).to.equal(false);
175222
}).timeout(DEFAULT_TIMEOUT.XL);
176223

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);
198224
});

0 commit comments

Comments
 (0)