-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3328 from continuedev/tomasz/e2e-completions
E2E Completion Test
- Loading branch information
Showing
8 changed files
with
95 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { VSBrowser, WebView } from "vscode-extension-tester"; | ||
import * as path from "path"; | ||
|
||
export class GlobalActions { | ||
public static async openTestWorkspace() { | ||
return VSBrowser.instance.openResources(path.join("e2e/test-continue")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const DEFAULT_TIMEOUT = 30_000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { By, WebDriver } from "vscode-extension-tester"; | ||
|
||
export class AutocompleteSelectors { | ||
public static async getGhostTextContent(driver: WebDriver) { | ||
const element = await driver.findElement( | ||
By.xpath("//span[contains(@class, 'ghost-text-decoration')]"), | ||
); | ||
|
||
return element.getText(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
EditorView, | ||
TextEditor, | ||
InputBox, | ||
Workbench, | ||
} from "vscode-extension-tester"; | ||
|
||
import { TestUtils } from "../TestUtils"; | ||
import { DEFAULT_TIMEOUT } from "../constants"; | ||
import { AutocompleteSelectors } from "../selectors/Autocomplete.selectors"; | ||
import { expect } from "chai"; | ||
import { GlobalActions } from "../actions/Global.actions"; | ||
|
||
describe("Autocomplete", () => { | ||
let editor: TextEditor; | ||
|
||
beforeEach(async function () { | ||
this.timeout(DEFAULT_TIMEOUT); | ||
|
||
await GlobalActions.openTestWorkspace(); | ||
await new Workbench().executeCommand("Create: New File..."); | ||
await (await InputBox.create()).selectQuickPick("Text File"); | ||
editor = (await new EditorView().openEditor("Untitled-1")) as TextEditor; | ||
}); | ||
|
||
afterEach(async function () { | ||
this.timeout(DEFAULT_TIMEOUT); | ||
await editor.clearText(); | ||
await new EditorView().closeAllEditors(); | ||
}); | ||
|
||
it("Should display completions", async () => { | ||
const driver = editor.getDriver(); | ||
|
||
const messagePair0 = TestUtils.generateTestMessagePair(0); | ||
await editor.typeTextAt(1, 1, messagePair0.userMessage); | ||
await editor.typeTextAt(1, messagePair0.userMessage.length + 1, " "); | ||
const ghostText0 = await TestUtils.waitForElement( | ||
() => AutocompleteSelectors.getGhostTextContent(driver), | ||
// The first completion takes longer because Continue needs to load | ||
DEFAULT_TIMEOUT, | ||
); | ||
expect(ghostText0).to.equal(messagePair0.llmResponse); | ||
|
||
await editor.clearText(); | ||
|
||
const messagePair1 = TestUtils.generateTestMessagePair(1); | ||
await editor.typeTextAt(1, 1, messagePair1.userMessage); | ||
await editor.typeTextAt(1, messagePair1.userMessage.length + 1, " "); | ||
const ghostText1 = await TestUtils.waitForElement(() => | ||
AutocompleteSelectors.getGhostTextContent(driver), | ||
); | ||
expect(ghostText1).to.equal(messagePair1.llmResponse); | ||
}).timeout(DEFAULT_TIMEOUT); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.