feat: proxy URI environment variable (#4681)
* 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. * Add changelog entry for VSCODE_PROXY_URI * Add terminal test for VSCODE_PROXY_URI * Update VS Code This adds the VSCODE_PROXY_URI environment variable.
This commit is contained in:
12
test/e2e/extensions.test.ts
Normal file
12
test/e2e/extensions.test.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { describe, test } from "./baseFixture"
|
||||
|
||||
describe("Extensions", true, () => {
|
||||
// This will only work if the test extension is loaded into code-server.
|
||||
test("should have access to VSCODE_PROXY_URI", async ({ codeServerPage }) => {
|
||||
const address = await codeServerPage.address()
|
||||
|
||||
await codeServerPage.executeCommandViaMenus("code-server: Get proxy URI")
|
||||
|
||||
await codeServerPage.page.waitForSelector(`text=${address}/proxy/{{port}}`)
|
||||
})
|
||||
})
|
1
test/e2e/extensions/test-extension/.gitignore
vendored
Normal file
1
test/e2e/extensions/test-extension/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/extension.js
|
13
test/e2e/extensions/test-extension/extension.ts
Normal file
13
test/e2e/extensions/test-extension/extension.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import * as vscode from "vscode"
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("codeServerTest.proxyUri", () => {
|
||||
if (process.env.VSCODE_PROXY_URI) {
|
||||
vscode.window.showInformationMessage(process.env.VSCODE_PROXY_URI)
|
||||
} else {
|
||||
vscode.window.showErrorMessage("No proxy URI was set")
|
||||
}
|
||||
}),
|
||||
)
|
||||
}
|
29
test/e2e/extensions/test-extension/package.json
Normal file
29
test/e2e/extensions/test-extension/package.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "code-server-extension",
|
||||
"description": "code-server test extension",
|
||||
"version": "0.0.1",
|
||||
"publisher": "cdr",
|
||||
"activationEvents": [
|
||||
"onCommand:codeServerTest.proxyUri"
|
||||
],
|
||||
"engines": {
|
||||
"vscode": "^1.56.0"
|
||||
},
|
||||
"main": "./extension.js",
|
||||
"contributes": {
|
||||
"commands": [
|
||||
{
|
||||
"command": "codeServerTest.proxyUri",
|
||||
"title": "Get proxy URI",
|
||||
"category": "code-server"
|
||||
}
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/vscode": "^1.56.0",
|
||||
"typescript": "^4.0.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc extension.ts"
|
||||
}
|
||||
}
|
10
test/e2e/extensions/test-extension/tsconfig.json
Normal file
10
test/e2e/extensions/test-extension/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"module": "commonjs",
|
||||
"outDir": ".",
|
||||
"strict": true,
|
||||
"baseUrl": "./"
|
||||
},
|
||||
"include": ["./extension.ts"]
|
||||
}
|
13
test/e2e/extensions/test-extension/yarn.lock
Normal file
13
test/e2e/extensions/test-extension/yarn.lock
Normal file
@ -0,0 +1,13 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/vscode@^1.56.0":
|
||||
version "1.57.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/vscode/-/vscode-1.57.0.tgz#cc648e0573b92f725cd1baf2621f8da9f8bc689f"
|
||||
integrity sha512-FeznBFtIDCWRluojTsi9c3LLcCHOXP5etQfBK42+ixo1CoEAchkw39tuui9zomjZuKfUVL33KZUDIwHZ/xvOkQ==
|
||||
|
||||
typescript@^4.0.5:
|
||||
version "4.3.2"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"
|
||||
integrity sha512-zZ4hShnmnoVnAHpVHWpTcxdv7dWP60S2FsydQLV8V5PbS3FifjWFFRiHSWpDJahly88PRyV5teTSLoq4eG7mKw==
|
@ -88,6 +88,8 @@ export class CodeServer {
|
||||
path.join(dir, "config.yaml"),
|
||||
"--user-data-dir",
|
||||
dir,
|
||||
"--extensions-dir",
|
||||
path.join(__dirname, "../extensions"),
|
||||
// The last argument is the workspace to open.
|
||||
dir,
|
||||
],
|
||||
|
@ -5,19 +5,14 @@ import { clean, tmpdir } from "../utils/helpers"
|
||||
import { describe, expect, test } from "./baseFixture"
|
||||
|
||||
describe("Integrated Terminal", true, () => {
|
||||
// Create a new context with the saved storage state
|
||||
// so we don't have to logged in
|
||||
const testFileName = "pipe"
|
||||
const testString = "new string test from e2e test"
|
||||
|
||||
const testName = "integrated-terminal"
|
||||
test.beforeAll(async () => {
|
||||
await clean(testName)
|
||||
})
|
||||
|
||||
test("should echo a string to a file", async ({ codeServerPage }) => {
|
||||
test("should have access to VSCODE_PROXY_URI", async ({ codeServerPage }) => {
|
||||
const tmpFolderPath = await tmpdir(testName)
|
||||
const tmpFile = path.join(tmpFolderPath, testFileName)
|
||||
const tmpFile = path.join(tmpFolderPath, "pipe")
|
||||
|
||||
const command = `mkfifo '${tmpFile}' && cat '${tmpFile}'`
|
||||
const exec = util.promisify(cp.exec)
|
||||
@ -27,12 +22,12 @@ describe("Integrated Terminal", true, () => {
|
||||
await codeServerPage.focusTerminal()
|
||||
|
||||
await codeServerPage.page.waitForLoadState("load")
|
||||
await codeServerPage.page.keyboard.type(`echo ${testString} > ${tmpFile}`)
|
||||
await codeServerPage.page.keyboard.type(`printenv VSCODE_PROXY_URI > ${tmpFile}`)
|
||||
await codeServerPage.page.keyboard.press("Enter")
|
||||
// It may take a second to process
|
||||
await codeServerPage.page.waitForTimeout(1000)
|
||||
|
||||
const { stdout } = await output
|
||||
expect(stdout).toMatch(testString)
|
||||
expect(stdout).toMatch(await codeServerPage.address())
|
||||
})
|
||||
})
|
||||
|
@ -25,12 +25,10 @@ const config: PlaywrightTestConfig = {
|
||||
name: "Chromium",
|
||||
use: { browserName: "chromium" },
|
||||
},
|
||||
|
||||
{
|
||||
name: "Firefox",
|
||||
use: { browserName: "firefox" },
|
||||
},
|
||||
|
||||
{
|
||||
name: "WebKit",
|
||||
use: { browserName: "webkit" },
|
||||
|
Reference in New Issue
Block a user