Skip to content

Commit dcffd35

Browse files
committed
test: add force autocomplete test case
- Adds `forceCompletion` method to `AutocompleteActions` to trigger autocomplete via command. - Includes new test case to verify forced autocomplete functionality. - Attempted to test these tests to the best of my ability`
1 parent cc50768 commit dcffd35

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

extensions/vscode/e2e/actions/Autocomplete.actions.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from "chai";
2-
import { TextEditor } from "vscode-extension-tester";
2+
import { TextEditor, VSBrowser, Workbench } from "vscode-extension-tester";
33

44
import { DEFAULT_TIMEOUT } from "../constants";
55
import { AutocompleteSelectors } from "../selectors/Autocomplete.selectors";
@@ -29,4 +29,17 @@ export class AutocompleteActions {
2929
);
3030
expect(ghostText1).to.equal(messagePair1.llmResponse);
3131
}
32+
33+
public static async forceCompletion(editor: TextEditor): Promise<string> {
34+
await editor.setText("def main():\n ");
35+
await editor.moveCursor(2, 5);
36+
37+
await new Workbench().executeCommand("Continue: Force Autocomplete");
38+
39+
const ghostText = await TestUtils.waitForSuccess(() =>
40+
AutocompleteSelectors.getGhostTextContent(VSBrowser.instance.driver)
41+
);
42+
43+
return ghostText;
44+
}
3245
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect } from "chai";
12
import { EditorView, TextEditor } from "vscode-extension-tester";
23

34
import { AutocompleteActions } from "../actions/Autocomplete.actions";
@@ -23,4 +24,8 @@ describe("Autocomplete", () => {
2324
it("Should display completions", async () => {
2425
await AutocompleteActions.testCompletions(editor);
2526
}).timeout(DEFAULT_TIMEOUT.XL);
27+
it("Should force a completion using the command", async () => {
28+
const ghostText = await AutocompleteActions.forceCompletion(editor);
29+
expect(ghostText).to.not.be.empty;
30+
}).timeout(DEFAULT_TIMEOUT.XL);
2631
});

0 commit comments

Comments
 (0)