Skip to content

Commit 7e2dfb9

Browse files
Merge pull request #3191 from continuedev/tomasz/e2e
Set up e2e tests for gui
2 parents a9a3aa2 + 03839c3 commit 7e2dfb9

9 files changed

+1713
-34
lines changed

.github/workflows/pr_checks.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ jobs:
8888
npx tsc --noEmit
8989
npm run lint
9090
91+
- name: Install Xvfb for Linux and run e2e tests
92+
run: |
93+
sudo apt-get install -y xvfb # Install Xvfb
94+
Xvfb :99 & # Start Xvfb
95+
export DISPLAY=:99 # Export the display number to the environment
96+
cd extensions/vscode
97+
npm run package
98+
npm run e2e:ci
99+
91100
- name: core checks
92101
run: |
93102
cd core

extensions/vscode/.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ gui/**
1616
.devcontainer
1717
.github
1818

19-
continue_rc_schema.json
19+
continue_rc_schema.json
20+
21+
22+
e2e/_output
23+
e2e/.test-extensions
24+
e2e/storage
25+
e2e/vsix

extensions/vscode/e2e/GUI.test.ts

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import {
2+
Workbench,
3+
EditorView,
4+
WebView,
5+
By,
6+
WebElement,
7+
WebDriver,
8+
Key,
9+
} from "vscode-extension-tester";
10+
import { expect } from "chai";
11+
12+
const switchToReactIframe = async (driver: WebDriver) => {
13+
const iframes = await driver.findElements(By.css("iframe"));
14+
let continueIFrame: WebElement | undefined = undefined;
15+
for (let i = 0; i < iframes.length; i++) {
16+
const iframe = iframes[i];
17+
const src = await iframe.getAttribute("src");
18+
if (src.includes("extensionId=Continue.continue")) {
19+
continueIFrame = iframe;
20+
break;
21+
}
22+
}
23+
24+
if (!continueIFrame) {
25+
throw new Error("Could not find continue iframe");
26+
}
27+
28+
await driver.switchTo().frame(continueIFrame);
29+
30+
await new Promise((res) => {
31+
setTimeout(res, 500);
32+
});
33+
34+
const reactIFrame = await driver.findElement(By.css("iframe"));
35+
36+
if (!reactIFrame) {
37+
throw new Error("Could not find React iframe");
38+
}
39+
40+
await driver.switchTo().frame(reactIFrame);
41+
};
42+
43+
describe("GUI Test", () => {
44+
let view: WebView;
45+
let driver: WebDriver;
46+
47+
before(async function () {
48+
this.timeout(10000);
49+
50+
await new Workbench().executeCommand("continue.focusContinueInput");
51+
52+
view = new WebView();
53+
driver = view.getDriver();
54+
55+
await switchToReactIframe(driver);
56+
});
57+
58+
after(async () => {
59+
await view.switchBack();
60+
await new EditorView().closeAllEditors();
61+
});
62+
63+
it("should display correct panel description", async () => {
64+
const description = await view.findWebElement(
65+
By.xpath("//*[contains(text(), 'Quickly')]"),
66+
);
67+
68+
expect(await description.getText()).has.string(
69+
"Quickly get up and running using our API keys.",
70+
);
71+
});
72+
73+
it("should allow typing text in the editor", async () => {
74+
const tiptap = await view.findWebElement(By.className("tiptap"));
75+
76+
await tiptap.sendKeys("Hello world!");
77+
78+
expect(await tiptap.getText()).has.string("Hello world!");
79+
80+
// Just to show that we can
81+
await tiptap.sendKeys(Key.ENTER);
82+
await new Promise((res) => {
83+
setTimeout(res, 5000);
84+
});
85+
}).timeout(6000);
86+
});
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# echo pwd
4+
echo "Current directory: $(pwd)"
5+
6+
# Find the latest VSIX file in the build directory
7+
latest_vsix=$(ls -t ./build/continue-*.vsix | head -n1)
8+
9+
if [ -z "$latest_vsix" ]; then
10+
echo "No VSIX file found in build directory"
11+
exit 1
12+
fi
13+
14+
# Create e2e/vsix directory if it doesn't exist
15+
mkdir -p "./e2e/vsix"
16+
17+
# Copy the file to e2e directory with fixed name
18+
cp "$latest_vsix" "./e2e/vsix/continue.vsix"

extensions/vscode/entitlements.plist

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.disable-library-validation</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-write</key>
8+
<true/>
9+
<key>com.apple.security.files.downloads.read-write</key>
10+
<true/>
11+
<key>com.apple.security.files.documents.read-write</key>
12+
<true/>
13+
<key>com.apple.security.automation.apple-events</key>
14+
<true/>
15+
</dict>
16+
</plist>

0 commit comments

Comments
 (0)