Elffuss BraidHub

kikocis/continue public

main · 3.3 KiBRawPermalink
1import { TextEditor, VSBrowser, WebView } from "vscode-extension-tester";
2
3import { ApplyActions } from "../actions/Apply.actions";
4import { GlobalActions } from "../actions/Global.actions";
5import { GUIActions } from "../actions/GUI.actions";
6import { KeyboardShortcutsActions } from "../actions/KeyboardShortcuts.actions";
7import { DEFAULT_TIMEOUT } from "../constants";
8import { GUISelectors } from "../selectors/GUI.selectors";
9import { TestUtils } from "../TestUtils";
10
11/**
12 * This file is currently `.skip`'d because the test is consistently failing in CI,
13 * bu consistenly passing locally. Screenshots from CI appear to indicate
14 * that our `GlobalActions.openTestWorkspace` fn isn't actually working, and therefore
15 * our apply button is instead rendering as "Create file" since the file doesn't exist
16 * in our workspace.
17 *
18 * The most recent failing screenshot is here: https://github.com/continuedev/continue/actions/runs/14481877233?pr=5167
19 */
20describe("Apply Test", () => {
21 let view: WebView;
22 let editor: TextEditor;
23 let fileContent = "hello = 'world'";
24
25 before(async function () {
26 this.timeout(DEFAULT_TIMEOUT.XL);
27
28 await GUIActions.moveContinueToSidebar(VSBrowser.instance.driver);
29 await GlobalActions.openTestWorkspace();
30
31 ({ editor } = await GlobalActions.createAndSaveNewFile());
32 });
33
34 beforeEach(async function () {
35 this.timeout(DEFAULT_TIMEOUT.XL);
36
37 await editor.typeTextAt(1, 1, fileContent);
38 await GUIActions.toggleGui();
39
40 ({ view } = await GUIActions.switchToReactIframe());
41 await GUIActions.selectModelFromDropdown(view, "TEST LLM");
42 });
43
44 afterEach(async function () {
45 this.timeout(DEFAULT_TIMEOUT.XL);
46
47 await editor.clearText();
48
49 ({ view } = await GUIActions.switchToReactIframe());
50 const tipTapEditor = await GUISelectors.getMessageInputFieldAtIndex(
51 view,
52 0,
53 );
54 await tipTapEditor.clear();
55 });
56
57 after(async function () {
58 this.timeout(DEFAULT_TIMEOUT.XL);
59 await GlobalActions.deleteFileFromFolder();
60 });
61
62 it("Can reject and apply changes from sidebar", async () => {
63 const newFileContent = fileContent + "!";
64
65 const [messageInput] = await GUISelectors.getMessageInputFields(view);
66
67 await KeyboardShortcutsActions.typeWithNewlines({
68 submit: true,
69 input: messageInput,
70 lines: [
71 "```py " + GlobalActions.defaultNewFilename,
72 newFileContent,
73 "```",
74 "_", // To avoid extra lines getting included in the block
75 ],
76 });
77
78 await ApplyActions.performAction(view, "apply");
79 await ApplyActions.performAction(view, "reject");
80 await view.switchBack();
81
82 let editorText = await editor.getText();
83
84 await TestUtils.waitForSuccess(async () => editorText === fileContent);
85
86 ({ view } = await GUIActions.switchToReactIframe());
87
88 await ApplyActions.performAction(view, "apply");
89 await ApplyActions.performAction(view, "accept");
90 await view.switchBack();
91
92 // Note that the editor after accpeting contains additional text
93 // from the default output of the test LLM, so instead of checking
94 // for an exact text match on the new content we just do a `.includes()`
95 editorText = await editor.getText();
96 await TestUtils.waitForSuccess(async () =>
97 editorText.includes(newFileContent),
98 );
99 }).timeout(DEFAULT_TIMEOUT.XL);
100});