Skip to content

Commit 3fa30c8

Browse files
committed
Add test extension
This will let us test extension-related features (like the proxy URI). I removed the environment variables in the script because they override the ones you set yourself. We still set defaults in constants.ts.
1 parent f04fcf2 commit 3fa30c8

File tree

11 files changed

+103
-7
lines changed

11 files changed

+103
-7
lines changed

ci/dev/postinstall.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@ set -euo pipefail
33

44
main() {
55
cd "$(dirname "$0")/../.."
6+
source ./ci/lib.sh
67

7-
echo "Installing code-server test dependencies..."
8+
pushd test
9+
echo "Installing dependencies for $PWD"
10+
yarn install
11+
popd
812

913
local args=(install)
1014
if [[ ${CI-} ]]; then
1115
args+=(--frozen-lockfile)
1216
fi
1317

14-
cd test
18+
pushd test
19+
echo "Installing dependencies for $PWD"
1520
yarn "${args[@]}"
16-
cd ..
21+
popd
1722

18-
cd vendor
19-
echo "Installing vendor dependencies..."
23+
pushd test/e2e/extensions/test-extension
24+
echo "Installing dependencies for $PWD"
25+
yarn "${args[@]}"
26+
popd
27+
28+
pushd vendor
29+
echo "Installing dependencies for $PWD"
2030

2131
# We install in 'modules' instead of 'node_modules' because VS Code's
2232
# extensions use a webpack config which cannot differentiate between its own
@@ -33,6 +43,8 @@ main() {
3343

3444
# Finally, run the vendor `postinstall`
3545
yarn run postinstall
46+
47+
popd
3648
}
3749

3850
main "$@"

ci/dev/test-e2e.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ main() {
1313

1414
source ./ci/lib.sh
1515

16+
pushd test/e2e/extensions/test-extension
17+
echo "Building test extension"
18+
yarn build
19+
popd
20+
1621
local dir="$PWD"
1722
if [[ ! ${CODE_SERVER_TEST_ENTRY-} ]]; then
1823
echo "Set CODE_SERVER_TEST_ENTRY to test another build of code-server"

ci/dev/test-unit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ main() {
66

77
source ./ci/lib.sh
88

9+
echo "Building test plugin"
910
pushd test/unit/node/test-plugin
1011
make -s out/index.js
1112
popd

test/e2e/extensions.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { describe, test } from "./baseFixture"
2+
3+
describe("Extensions", true, () => {
4+
// This will only work if the test extension is loaded into code-server.
5+
test("should have access to VSCODE_PROXY_URI", async ({ codeServerPage }) => {
6+
const address = await codeServerPage.address()
7+
8+
await codeServerPage.executeCommandViaMenus("code-server: Get proxy URI")
9+
10+
await codeServerPage.page.waitForSelector(`text=${address}/proxy/{{port}}`)
11+
})
12+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/extension.js
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as vscode from "vscode"
2+
3+
export function activate(context: vscode.ExtensionContext) {
4+
context.subscriptions.push(
5+
vscode.commands.registerCommand("codeServerTest.proxyUri", () => {
6+
if (process.env.VSCODE_PROXY_URI) {
7+
vscode.window.showInformationMessage(process.env.VSCODE_PROXY_URI)
8+
} else {
9+
vscode.window.showErrorMessage("No proxy URI was set")
10+
}
11+
}),
12+
)
13+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "code-server-extension",
3+
"description": "code-server test extension",
4+
"version": "0.0.1",
5+
"publisher": "cdr",
6+
"activationEvents": [
7+
"onCommand:codeServerTest.proxyUri"
8+
],
9+
"engines": {
10+
"vscode": "^1.56.0"
11+
},
12+
"main": "./extension.js",
13+
"contributes": {
14+
"commands": [
15+
{
16+
"command": "codeServerTest.proxyUri",
17+
"title": "Get proxy URI",
18+
"category": "code-server"
19+
}
20+
]
21+
},
22+
"devDependencies": {
23+
"@types/vscode": "^1.56.0",
24+
"typescript": "^4.0.5"
25+
},
26+
"scripts": {
27+
"build": "tsc extension.ts"
28+
}
29+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2020",
4+
"module": "commonjs",
5+
"outDir": ".",
6+
"strict": true,
7+
"baseUrl": "./"
8+
},
9+
"include": ["./extension.ts"]
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"@types/vscode@^1.56.0":
6+
version "1.57.0"
7+
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.57.0.tgz#cc648e0573b92f725cd1baf2621f8da9f8bc689f"
8+
integrity sha512-FeznBFtIDCWRluojTsi9c3LLcCHOXP5etQfBK42+ixo1CoEAchkw39tuui9zomjZuKfUVL33KZUDIwHZ/xvOkQ==
9+
10+
typescript@^4.0.5:
11+
version "4.3.2"
12+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"
13+
integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==

test/e2e/models/CodeServer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export class CodeServer {
8888
path.join(dir, "config.yaml"),
8989
"--user-data-dir",
9090
dir,
91+
"--extensions-dir",
92+
path.join(__dirname, "../extensions"),
9193
// The last argument is the workspace to open.
9294
dir,
9395
],

test/playwright.config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ const config: PlaywrightTestConfig = {
2525
name: "Chromium",
2626
use: { browserName: "chromium" },
2727
},
28-
2928
{
3029
name: "Firefox",
3130
use: { browserName: "firefox" },
3231
},
33-
3432
{
3533
name: "WebKit",
3634
use: { browserName: "webkit" },

0 commit comments

Comments
 (0)