- Notifications
You must be signed in to change notification settings - Fork24
Add package scripts and cli library, enable integration testing#536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
7e1bce9
c693a46
240b649
0e58a31
872b7e8
01c2d80
8ddbf26
9b74df4
adec211
d9b543a
a7afdd6
3097d8f
a2d2bc8
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vitest.config.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -18,7 +18,7 @@ jobs: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "22" | ||
- run: yarn | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from "@vscode/test-cli"; | ||
export default defineConfig({ | ||
files: "out/test/**/*.test.js", | ||
extensionDevelopmentPath: ".", | ||
extensionTestsPath: "./out/test", | ||
launchArgs: ["--enable-proposed-api", "coder.coder-remote"], | ||
mocha: { | ||
ui: "tdd", | ||
timeout: 20000, | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -12,4 +12,4 @@ node_modules/** | ||
**/.editorconfig | ||
**/*.map | ||
**/*.ts | ||
*.gif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -21,25 +21,31 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> { | ||
// | ||
// Cursor and VSCode are covered by ms remote, and the only other is windsurf for now | ||
// Means that vscodium is not supported by this for now | ||
const remoteSSHExtension = | ||
vscode.extensions.getExtension("jeanp413.open-remote-ssh") || | ||
vscode.extensions.getExtension("codeium.windsurf-remote-openssh") || | ||
vscode.extensions.getExtension("anysphere.remote-ssh") || | ||
vscode.extensions.getExtension("ms-vscode-remote.remote-ssh"); | ||
let vscodeProposed: typeof vscode = vscode; | ||
if (!remoteSSHExtension) { | ||
vscode.window.showErrorMessage( | ||
"Remote SSH extension not found, this may not work as expected.\n" + | ||
// NB should we link to documentation or marketplace? | ||
jaggederest marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
"Please install your choice of Remote SSH extension from the VS Code Marketplace.", | ||
); | ||
} else { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
vscodeProposed = (module as any)._load( | ||
"vscode", | ||
{ | ||
filename: remoteSSHExtension.extensionPath, | ||
}, | ||
false, | ||
); | ||
Comment on lines +40 to 47 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Using 'module as any' bypasses type safety; consider a more type-safe approach or adding documentation to justify this workaround. Copilot uses AI. Check for mistakes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yeah I get it buddy I don't like it either but we're polymorphic on the SSH extensions. | ||
} | ||
const output = vscode.window.createOutputChannel("Coder"); | ||
const storage = new Storage( | ||
@@ -278,7 +284,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> { | ||
// Since the "onResolveRemoteAuthority:ssh-remote" activation event exists | ||
// in package.json we're able to perform actions before the authority is | ||
// resolved by the remote SSH extension. | ||
// | ||
// In addition, if we don't have a remote SSH extension, we skip this | ||
// activation event. This may allow the user to install the extension | ||
// after the Coder extension is installed, instead of throwing a fatal error | ||
// (this would require the user to uninstall the Coder extension and | ||
// reinstall after installing the remote SSH extension, which is annoying) | ||
Comment on lines +291 to +292 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 🎉 | ||
if (remoteSSHExtension && vscodeProposed.env.remoteAuthority) { | ||
const remote = new Remote( | ||
vscodeProposed, | ||
storage, | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as assert from "assert"; | ||
import * as vscode from "vscode"; | ||
suite("Extension Test Suite", () => { | ||
jaggederest marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
vscode.window.showInformationMessage("Start all tests."); | ||
test("Extension should be present", () => { | ||
assert.ok(vscode.extensions.getExtension("coder.coder-remote")); | ||
}); | ||
test("Extension should activate", async () => { | ||
const extension = vscode.extensions.getExtension("coder.coder-remote"); | ||
assert.ok(extension); | ||
if (!extension.isActive) { | ||
await extension.activate(); | ||
} | ||
assert.ok(extension.isActive); | ||
}); | ||
test("Extension should export activate function", async () => { | ||
const extension = vscode.extensions.getExtension("coder.coder-remote"); | ||
assert.ok(extension); | ||
await extension.activate(); | ||
// The extension doesn't export anything, which is fine | ||
// The test was expecting exports.activate but the extension | ||
// itself is the activate function | ||
assert.ok(extension.isActive); | ||
}); | ||
test("Commands should be registered", async () => { | ||
const extension = vscode.extensions.getExtension("coder.coder-remote"); | ||
assert.ok(extension); | ||
if (!extension.isActive) { | ||
await extension.activate(); | ||
} | ||
// Give a small delay for commands to register | ||
await new Promise((resolve) => setTimeout(resolve, 100)); | ||
const commands = await vscode.commands.getCommands(true); | ||
const coderCommands = commands.filter((cmd) => cmd.startsWith("coder.")); | ||
assert.ok( | ||
coderCommands.length > 0, | ||
"Should have registered Coder commands", | ||
); | ||
assert.ok( | ||
coderCommands.includes("coder.login"), | ||
"Should have coder.login command", | ||
); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "ES2022", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Do we know whether our minimum version of VS Code (1.73.0) supported es2022? Looks like it was Electron 19.0.17 based on Node 16.14.2 but I am not sure how to find the compatibility. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I will check on that, thank you for pointing that out. | ||
"moduleResolution": "node", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I was reading that This is a change from the default, right? Supposedly | ||
"outDir": "out", | ||
// "dom" is required for importing the API from coder/coder. | ||
"lib": ["ES2022", "dom"], | ||
"sourceMap": true, | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This loosens some type checking, right? Do we need to disable it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I don't believe we do, I'll revert that. | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"exclude": ["node_modules", "vitest.config.ts"], | ||
"include": ["src/**/*"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defineConfig } from "vitest/config"; | ||
export default defineConfig({ | ||
test: { | ||
include: ["src/**/*.test.ts"], | ||
exclude: [ | ||
"**/node_modules/**", | ||
"**/dist/**", | ||
"**/build/**", | ||
"**/out/**", | ||
"**/src/test/**", | ||
"src/test/**", | ||
"./src/test/**", | ||
], | ||
environment: "node", | ||
}, | ||
}); |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.