test(e2e): edit flow
This commit is contained in:
parent
4b97663aa4
commit
e6533965bd
15 changed files with 227 additions and 31 deletions
|
|
@ -6,6 +6,7 @@
|
|||
},
|
||||
"plugins": ["@typescript-eslint", "import"],
|
||||
"rules": {
|
||||
"@typescript-eslint/naming-convention": "off",
|
||||
"@typescript-eslint/semi": "warn",
|
||||
"curly": "warn",
|
||||
"eqeqeq": "warn",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
},
|
||||
"extends": ["../../.eslintrc.shared.json"],
|
||||
"rules": {
|
||||
"@typescript-eslint/naming-convention": "warn"
|
||||
"@typescript-eslint/naming-convention": "off"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
import { expect } from "chai";
|
||||
import {
|
||||
Key,
|
||||
WebElement,
|
||||
waitForAttributeValue,
|
||||
} from "vscode-extension-tester";
|
||||
import { Key } from "vscode-extension-tester";
|
||||
|
||||
import { DEFAULT_TIMEOUT } from "./constants";
|
||||
|
||||
export class TestUtils {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { TextEditor } from "vscode-extension-tester";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
import { AutocompleteSelectors } from "../selectors/Autocomplete.selectors";
|
||||
import { expect } from "chai";
|
||||
import { TextEditor } from "vscode-extension-tester";
|
||||
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { AutocompleteSelectors } from "../selectors/Autocomplete.selectors";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
|
||||
export class AutocompleteActions {
|
||||
public static async testCompletions(editor: TextEditor) {
|
||||
|
|
|
|||
40
extensions/vscode/e2e/actions/Edit.actions.ts
Normal file
40
extensions/vscode/e2e/actions/Edit.actions.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { TextEditor, WebView } from "vscode-extension-tester";
|
||||
|
||||
import { EditSelectors } from "../selectors/Edit.selectors";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
|
||||
export class EditActions {
|
||||
static async invokeEditShortcut(editor: TextEditor) {
|
||||
editor
|
||||
.getDriver()
|
||||
.actions()
|
||||
.keyDown(TestUtils.osControlKey)
|
||||
.sendKeys("i")
|
||||
.keyUp(TestUtils.osControlKey)
|
||||
.perform();
|
||||
}
|
||||
|
||||
static async acceptEditInGUI(view: WebView): Promise<void> {
|
||||
await TestUtils.waitForSuccess(async () =>
|
||||
(await EditSelectors.getEditAcceptButton(view)).click(),
|
||||
);
|
||||
await view.switchBack();
|
||||
}
|
||||
|
||||
static async rejectEditInGUI(view: WebView): Promise<void> {
|
||||
await TestUtils.waitForSuccess(async () =>
|
||||
(await EditSelectors.getEditRejectButton(view)).click(),
|
||||
);
|
||||
await view.switchBack();
|
||||
}
|
||||
|
||||
static async acceptEditWithCodeLens(editor: TextEditor): Promise<void> {
|
||||
const acceptCodeLens = await editor.getCodeLens("Accept");
|
||||
await acceptCodeLens?.click();
|
||||
}
|
||||
|
||||
static async rejectEditWithCodeLens(editor: TextEditor): Promise<void> {
|
||||
const rejectCodeLens = await editor.getCodeLens("Reject");
|
||||
await rejectCodeLens?.click();
|
||||
}
|
||||
}
|
||||
|
|
@ -6,9 +6,10 @@ import {
|
|||
WebView,
|
||||
Workbench,
|
||||
} from "vscode-extension-tester";
|
||||
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { GUISelectors } from "../selectors/GUI.selectors";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
|
||||
export class GUIActions {
|
||||
public static moveContinueToSidebar = async (driver: WebDriver) => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,29 @@
|
|||
import { VSBrowser, WebView } from "vscode-extension-tester";
|
||||
import {
|
||||
EditorView,
|
||||
InputBox,
|
||||
TextEditor,
|
||||
VSBrowser,
|
||||
Workbench,
|
||||
} from "vscode-extension-tester";
|
||||
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
|
||||
export class GlobalActions {
|
||||
public static async openTestWorkspace() {
|
||||
return VSBrowser.instance.openResources("e2e/test-continue");
|
||||
}
|
||||
|
||||
public static async createAndOpenNewTextFile(): Promise<{
|
||||
editor: TextEditor;
|
||||
}> {
|
||||
await new Workbench().executeCommand("Create: New File...");
|
||||
await (
|
||||
await InputBox.create(DEFAULT_TIMEOUT.MD)
|
||||
).selectQuickPick("Text File");
|
||||
const editor = (await new EditorView().openEditor(
|
||||
"Untitled-1",
|
||||
)) as TextEditor;
|
||||
|
||||
return { editor };
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { TextEditor, WebDriver, WebView } from "vscode-extension-tester";
|
||||
|
||||
import { TestUtils } from "../TestUtils";
|
||||
import { TextEditor } from "vscode-extension-tester";
|
||||
|
||||
export class KeyboardShortcutsActions {
|
||||
/**
|
||||
|
|
|
|||
13
extensions/vscode/e2e/selectors/Edit.selectors.ts
Normal file
13
extensions/vscode/e2e/selectors/Edit.selectors.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import { WebView } from "vscode-extension-tester";
|
||||
|
||||
import { SelectorUtils } from "./SelectorUtils";
|
||||
|
||||
export class EditSelectors {
|
||||
public static getEditAcceptButton(view: WebView) {
|
||||
return SelectorUtils.getElementByDataTestId(view, "edit-accept-button");
|
||||
}
|
||||
|
||||
public static getEditRejectButton(view: WebView) {
|
||||
return SelectorUtils.getElementByDataTestId(view, "edit-reject-button");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { By, until, WebDriver, WebView } from "vscode-extension-tester";
|
||||
import { By, WebDriver, WebView } from "vscode-extension-tester";
|
||||
|
||||
import { SelectorUtils } from "./SelectorUtils";
|
||||
|
||||
export class GUISelectors {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
import {
|
||||
EditorView,
|
||||
TextEditor,
|
||||
InputBox,
|
||||
Workbench,
|
||||
} from "vscode-extension-tester";
|
||||
import { EditorView, TextEditor } from "vscode-extension-tester";
|
||||
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { GlobalActions } from "../actions/Global.actions";
|
||||
import { AutocompleteActions } from "../actions/Autocomplete.actions";
|
||||
import { GlobalActions } from "../actions/Global.actions";
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
|
||||
describe("Autocomplete", () => {
|
||||
let editor: TextEditor;
|
||||
|
|
@ -16,11 +11,7 @@ describe("Autocomplete", () => {
|
|||
this.timeout(DEFAULT_TIMEOUT.XL);
|
||||
|
||||
await GlobalActions.openTestWorkspace();
|
||||
await new Workbench().executeCommand("Create: New File...");
|
||||
await (
|
||||
await InputBox.create(DEFAULT_TIMEOUT.MD)
|
||||
).selectQuickPick("Text File");
|
||||
editor = (await new EditorView().openEditor("Untitled-1")) as TextEditor;
|
||||
({ editor } = await GlobalActions.createAndOpenNewTextFile());
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
|
|
|
|||
125
extensions/vscode/e2e/tests/Edit.test.ts
Normal file
125
extensions/vscode/e2e/tests/Edit.test.ts
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
import {
|
||||
EditorView,
|
||||
WebView,
|
||||
WebDriver,
|
||||
Key,
|
||||
VSBrowser,
|
||||
InputBox,
|
||||
TextEditor,
|
||||
Workbench,
|
||||
} from "vscode-extension-tester";
|
||||
|
||||
import { EditActions } from "../actions/Edit.actions";
|
||||
import { GlobalActions } from "../actions/Global.actions";
|
||||
import { GUIActions } from "../actions/GUI.actions";
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { EditSelectors } from "../selectors/Edit.selectors";
|
||||
import { GUISelectors } from "../selectors/GUI.selectors";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
|
||||
describe("Edit Test", () => {
|
||||
let view: WebView;
|
||||
let editor: TextEditor;
|
||||
let originalEditorText = "Hello world!";
|
||||
let { userMessage, llmResponse } = TestUtils.generateTestMessagePair();
|
||||
|
||||
before(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.XL);
|
||||
await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
|
||||
await GlobalActions.openTestWorkspace();
|
||||
({ editor } = await GlobalActions.createAndOpenNewTextFile());
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.XL);
|
||||
|
||||
await GUIActions.toggleGui();
|
||||
|
||||
await editor.typeTextAt(1, 1, originalEditorText);
|
||||
await editor.selectText(originalEditorText);
|
||||
|
||||
await EditActions.invokeEditShortcut(editor);
|
||||
|
||||
({ view } = await GUIActions.switchToReactIframe());
|
||||
|
||||
await GUIActions.sendMessage({
|
||||
view,
|
||||
message: userMessage,
|
||||
inputFieldIndex: 0,
|
||||
});
|
||||
|
||||
await view.switchBack();
|
||||
|
||||
await TestUtils.waitForSuccess(async () => {
|
||||
const editorText = await editor.getText();
|
||||
return editorText.includes(llmResponse);
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
this.timeout(DEFAULT_TIMEOUT.XL);
|
||||
await editor.clearText();
|
||||
});
|
||||
|
||||
it("Accepts an Edit in the GUI", async () => {
|
||||
({ view } = await GUIActions.switchToReactIframe());
|
||||
|
||||
await EditActions.acceptEditInGUI(view);
|
||||
|
||||
await view.switchBack();
|
||||
|
||||
const editorText = await editor.getText();
|
||||
|
||||
await TestUtils.waitForSuccess(
|
||||
async () =>
|
||||
!editorText.includes(originalEditorText) &&
|
||||
editorText.includes(llmResponse),
|
||||
DEFAULT_TIMEOUT.SM,
|
||||
);
|
||||
}).timeout(DEFAULT_TIMEOUT.XL);
|
||||
|
||||
it("Rejects an Edit in the GUI", async () => {
|
||||
({ view } = await GUIActions.switchToReactIframe());
|
||||
|
||||
await EditActions.rejectEditInGUI(view);
|
||||
|
||||
await view.switchBack();
|
||||
|
||||
const editorText = await editor.getText();
|
||||
|
||||
await TestUtils.waitForSuccess(
|
||||
async () =>
|
||||
editorText.includes(originalEditorText) &&
|
||||
!editorText.includes(llmResponse),
|
||||
DEFAULT_TIMEOUT.SM,
|
||||
);
|
||||
}).timeout(DEFAULT_TIMEOUT.XL);
|
||||
|
||||
it("Accepts an Edit using CodeLens buttons", async () => {
|
||||
const acceptCodeLens = await editor.getCodeLens("Accept");
|
||||
await acceptCodeLens?.click();
|
||||
|
||||
const editorText = await editor.getText();
|
||||
|
||||
await TestUtils.waitForSuccess(
|
||||
async () =>
|
||||
!editorText.includes(originalEditorText) &&
|
||||
editorText.includes(llmResponse),
|
||||
DEFAULT_TIMEOUT.SM,
|
||||
);
|
||||
}).timeout(DEFAULT_TIMEOUT.XL);
|
||||
|
||||
it("Rejects an Edit using CodeLens buttons", async () => {
|
||||
const rejectCodeLens = await editor.getCodeLens("Reject");
|
||||
await rejectCodeLens?.click();
|
||||
|
||||
const editorText = await editor.getText();
|
||||
|
||||
await TestUtils.waitForSuccess(
|
||||
async () =>
|
||||
!editorText.includes(originalEditorText) &&
|
||||
editorText.includes(llmResponse),
|
||||
DEFAULT_TIMEOUT.SM,
|
||||
);
|
||||
}).timeout(DEFAULT_TIMEOUT.XL);
|
||||
});
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import { expect } from "chai";
|
||||
import {
|
||||
EditorView,
|
||||
WebView,
|
||||
|
|
@ -7,12 +8,12 @@ import {
|
|||
VSBrowser,
|
||||
until,
|
||||
} from "vscode-extension-tester";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { GlobalActions } from "../actions/Global.actions";
|
||||
import { GUIActions } from "../actions/GUI.actions";
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { GUISelectors } from "../selectors/GUI.selectors";
|
||||
import { TestUtils } from "../TestUtils";
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { GlobalActions } from "../actions/Global.actions";
|
||||
|
||||
describe("GUI Test", () => {
|
||||
let view: WebView;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
// "plugin:@typescript-eslint/recommended-requiring-type-checking"
|
||||
// "plugin:react/recommended"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/naming-convention": "off"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["src/**/*.{js,ts,jsx,tsx}"]
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ export default function AcceptRejectAllButtons({
|
|||
<button
|
||||
className="flex cursor-pointer items-center border-none bg-transparent px-2 py-1 text-xs text-gray-300 opacity-80 hover:opacity-100 hover:brightness-125"
|
||||
onClick={() => handleAcceptOrReject("rejectDiff")}
|
||||
data-testid="edit-reject-button"
|
||||
>
|
||||
<XMarkIcon className="mr-1 h-4 w-4 text-red-600" />
|
||||
{isSingleRangeEdit ? (
|
||||
|
|
@ -53,6 +54,7 @@ export default function AcceptRejectAllButtons({
|
|||
<button
|
||||
className="flex cursor-pointer items-center border-none bg-transparent px-2 py-1 text-xs text-gray-300 opacity-80 hover:opacity-100 hover:brightness-125"
|
||||
onClick={() => handleAcceptOrReject("acceptDiff")}
|
||||
data-testid="edit-accept-button"
|
||||
>
|
||||
<CheckIcon className="mr-1 h-4 w-4 text-green-600" />
|
||||
{isSingleRangeEdit ? (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue