mirror of
https://github.com/coder/code-server.git
synced 2026-11-02 22:09:11 +01:00
Update Code to 1.141.0 (#8040)
* Update Code to 1.141.0 * Allow pull_request_target * Add e2e tests for remote storage * Fix Typescript extension not loading * Remove unused imports
This commit is contained in:
@@ -2,7 +2,8 @@ import * as vscode from "vscode"
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.window.showInformationMessage("test extension loaded")
|
||||
// Test extension
|
||||
|
||||
// Prints the current proxy URI into a notification.
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("codeServerTest.proxyUri", () => {
|
||||
if (process.env.VSCODE_PROXY_URI) {
|
||||
@@ -13,7 +14,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}),
|
||||
)
|
||||
|
||||
// asExternalUri extension
|
||||
// Asks for a URI, then runs it through asExternalUri and prints the result
|
||||
// into a notification.
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("codeServerTest.asExternalUri", async () => {
|
||||
const input = await vscode.window.showInputBox({
|
||||
@@ -28,4 +30,29 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
const secretKey = "code-server-test-secret"
|
||||
|
||||
// Asks for a string, then stores it as a secret.
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("codeServerTest.setSecret", async () => {
|
||||
const input = await vscode.window.showInputBox({
|
||||
prompt: "Secret to store",
|
||||
})
|
||||
|
||||
if (input) {
|
||||
await context.secrets.store(secretKey, input)
|
||||
vscode.window.showInformationMessage(`set secret: ${input}`)
|
||||
} else {
|
||||
vscode.window.showErrorMessage(`Failed to run test case. No input provided.`)
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
// Prints the current secret, if any.
|
||||
context.subscriptions.push(
|
||||
vscode.commands.registerCommand("codeServerTest.getSecret", async () => {
|
||||
vscode.window.showInformationMessage(`get secret: ${await context.secrets.get(secretKey)}`)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,16 @@
|
||||
"command": "codeServerTest.asExternalUri",
|
||||
"title": "asExternalUri test",
|
||||
"category": "code-server"
|
||||
},
|
||||
{
|
||||
"command": "codeServerTest.setSecret",
|
||||
"title": "Set test secret",
|
||||
"category": "code-server"
|
||||
},
|
||||
{
|
||||
"command": "codeServerTest.getSecret",
|
||||
"title": "Get test secret",
|
||||
"category": "code-server"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -363,13 +363,14 @@ export class CodeServerPage {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the test extension loaded
|
||||
* Checks if the test extension loaded by waiting for its notification. Once
|
||||
* it appears, dismiss the notification.
|
||||
*/
|
||||
async waitForTestExtensionLoaded(): Promise<void> {
|
||||
const selector = "text=test extension loaded"
|
||||
this.codeServer.logger.debug("Waiting for test extension to load...")
|
||||
|
||||
await this.page.waitForSelector(selector)
|
||||
const locator = this.page.getByRole("dialog", { name: "Info: test extension loaded" })
|
||||
await locator.hover()
|
||||
await locator.getByLabel("Clear Notification (Del)").click()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { promises as fs } from "fs"
|
||||
import * as path from "path"
|
||||
import { clean } from "../utils/helpers"
|
||||
import { describe, test, expect } from "./baseFixture"
|
||||
|
||||
|
||||
61
test/e2e/storage.test.ts
Normal file
61
test/e2e/storage.test.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { promises as fs } from "fs"
|
||||
import * as path from "path"
|
||||
import { describe, test, expect } from "./baseFixture"
|
||||
|
||||
const tests = [
|
||||
{
|
||||
name: "browser storage",
|
||||
args: [],
|
||||
},
|
||||
{
|
||||
name: "remote storage",
|
||||
args: ["--enable-remote-storage"],
|
||||
},
|
||||
]
|
||||
|
||||
for (const tc of tests) {
|
||||
const args = ["--disable-workspace-trust", "--extensions-dir", path.join(__dirname, "./extensions"), ...tc.args]
|
||||
describe(tc.name, args, {}, () => {
|
||||
test("should store workbench state and secrets", async ({ codeServerPage }) => {
|
||||
// Create and open a file.
|
||||
const dir = await codeServerPage.workspaceDir
|
||||
const file = path.join(dir, "foo")
|
||||
await fs.writeFile(file, "bar")
|
||||
await codeServerPage.openFile(file)
|
||||
|
||||
// Store a secret.
|
||||
const secret = "foo-bar-baz"
|
||||
await codeServerPage.waitForTestExtensionLoaded()
|
||||
await codeServerPage.executeCommandViaMenus("code-server: Set test secret")
|
||||
await codeServerPage.page.waitForSelector(".quick-input-widget:focus-within")
|
||||
await codeServerPage.page.keyboard.type(secret)
|
||||
await codeServerPage.page.keyboard.press("Enter")
|
||||
await expect(codeServerPage.page.getByText(`Info: set secret: ${secret}`)).toBeVisible()
|
||||
|
||||
// There should be a workspace storage directory.
|
||||
const userDir = path.join(dir, "User/workspaceStorage")
|
||||
const dirs = await fs.readdir(userDir)
|
||||
expect(dirs.length).toBe(1)
|
||||
|
||||
const storageFile = path.join(userDir, dirs[0], "state.vscdb")
|
||||
if (tc.args.includes("--enable-remote-storage")) {
|
||||
// The sqlite database should exist.
|
||||
fs.stat(storageFile)
|
||||
} else {
|
||||
// But no sqlite database.
|
||||
expect(() => fs.stat(storageFile)).rejects.toThrow("ENOENT")
|
||||
}
|
||||
|
||||
// Reload using a command so it has a chance to flush storage.
|
||||
await codeServerPage.executeCommandViaMenus("Developer: Reload Window")
|
||||
await codeServerPage.waitForTestExtensionLoaded()
|
||||
|
||||
// Should see the same file.
|
||||
await codeServerPage.waitForTab(file)
|
||||
|
||||
// Should be able to retrieve the secret.
|
||||
await codeServerPage.executeCommandViaMenus("code-server: Get test secret")
|
||||
await expect(codeServerPage.page.getByText(`Info: get secret: ${secret}`)).toBeVisible()
|
||||
})
|
||||
})
|
||||
}
|
||||
19
test/e2e/typescript.test.ts
Normal file
19
test/e2e/typescript.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { promises as fs } from "fs"
|
||||
import * as path from "path"
|
||||
import { describe, test, expect } from "./baseFixture"
|
||||
|
||||
const args = ["--disable-workspace-trust"]
|
||||
|
||||
describe("typescript extension", args, {}, () => {
|
||||
test("should load as a workspace extension", async ({ codeServerPage }) => {
|
||||
const dir = await codeServerPage.workspaceDir
|
||||
const file = path.join(dir, "foo.ts")
|
||||
await fs.writeFile(file, 'const n: number = "x"')
|
||||
await codeServerPage.openFile(file)
|
||||
|
||||
await codeServerPage.executeCommandViaMenus("Developer: Show Running Extensions")
|
||||
await expect(
|
||||
codeServerPage.page.getByLabel("typescript-language-features").getByText(/localhost:\d+/),
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user