Elffuss BraidHub

kikocis/continue public

main · 2.4 KiBRawPermalink
1import { expect } from "chai";
2import {
3 EditorView,
4 InputBox,
5 Key,
6 TextEditor,
7 Workbench,
8} from "vscode-extension-tester";
9
10import { GlobalActions } from "../actions/Global.actions";
11import { DEFAULT_TIMEOUT } from "../constants";
12
13describe("Prompt file", () => {
14 let editor: TextEditor;
15
16 before(async function () {
17 this.timeout(DEFAULT_TIMEOUT.MD);
18 await GlobalActions.disableNextEdit();
19 });
20
21 beforeEach(async function () {
22 this.timeout(DEFAULT_TIMEOUT.XL);
23
24 await GlobalActions.openTestWorkspace();
25 await new Workbench().executeCommand("File: New Untitled Text File");
26 await new Workbench().executeCommand("Change Language Mode");
27 const inputBox = await new InputBox();
28 await inputBox.setText("Prompt Language");
29 await inputBox.confirm();
30 editor = (await new EditorView().openEditor("Untitled-1")) as TextEditor;
31 });
32
33 afterEach(async function () {
34 this.timeout(DEFAULT_TIMEOUT.XL);
35 await editor.clearText();
36 await new EditorView().closeAllEditors();
37 });
38
39 it("Should display intellisense for default context providers and preamble", async () => {
40 // Check that "@" dropdown in body works
41 const providers = [
42 "currentFile",
43 "open",
44 "os",
45 "problems",
46 "repo-map",
47 "terminal",
48 "tree",
49 ];
50
51 for (const provider of providers) {
52 // Type the @ symbol to trigger completion
53 await editor.typeText("@");
54
55 // Wait a moment for the completion to appear
56 await new Promise((resolve) => setTimeout(resolve, 500));
57
58 // Type the first few characters
59 await editor.typeText(provider.slice(0, 2));
60
61 // Wait for completion popup to update
62 await new Promise((resolve) => setTimeout(resolve, 300));
63
64 // Use Tab to accept completion instead of Enter
65 await editor.typeText(Key.TAB);
66
67 const text = await editor.getText();
68 expect(text).to.include("@" + provider);
69 await editor.clearText();
70 }
71
72 // Check that dropdown for properties in preamble works
73 // await editor.typeText(Key.ENTER);
74 // await editor.typeText(Key.ENTER);
75 // await editor.typeText("---");
76 // await editor.typeText(Key.UP);
77 // await editor.typeText(Key.UP);
78 // await editor.typeText(Key.SPACE);
79 // await editor.typeText(Key.BACK_SPACE);
80 // await editor.typeText(Key.ENTER);
81 // const text = await editor.getText();
82 // expect(text).equals("description: \n\n---");
83 }).timeout(DEFAULT_TIMEOUT.XL);
84});