Elffuss BraidHub

kikocis/continue public

71fd2e7d4456 · 1.3 KiBRawPermalink
1import { expect } from "chai";
2import { TextEditor } from "vscode-extension-tester";
3
4import { DEFAULT_TIMEOUT } from "../constants";
5import { AutocompleteSelectors } from "../selectors/Autocomplete.selectors";
6import { TestUtils } from "../TestUtils";
7
8export class AutocompleteActions {
9 public static async testCompletions(editor: TextEditor) {
10 const driver = editor.getDriver();
11
12 const messagePair0 = TestUtils.generateTestMessagePair(0);
13 await editor.typeTextAt(1, 1, messagePair0.userMessage);
14 await editor.typeTextAt(1, messagePair0.userMessage.length + 1, " ");
15 const ghostText0 = await TestUtils.waitForSuccess(
16 () => AutocompleteSelectors.getGhostTextContent(driver),
17 // The first completion takes longer because Continue needs to load
18 DEFAULT_TIMEOUT.XL,
19 );
20 expect(ghostText0).to.equal(messagePair0.llmResponse);
21
22 await editor.clearText();
23
24 const messagePair1 = TestUtils.generateTestMessagePair(1);
25 await editor.typeTextAt(1, 1, messagePair1.userMessage);
26 await editor.typeTextAt(1, messagePair1.userMessage.length + 1, " ");
27 const ghostText1 = await TestUtils.waitForSuccess(() =>
28 AutocompleteSelectors.getGhostTextContent(driver),
29 );
30 expect(ghostText1).to.equal(messagePair1.llmResponse);
31 }
32}