Archived
1
0

refactor: move test-plugin to integration suite

This seems more appropriate given this tests how a plugin might work
within code-server.
This commit is contained in:
Joe Previte 2022-09-17 10:33:03 -07:00
parent a0944006e7
commit bc02005dc0
No known key found for this signature in database
GPG Key ID: 2C91590C6B742C24
13 changed files with 22 additions and 19 deletions

View File

@ -24,6 +24,13 @@ main() {
path="$CODE_SERVER_PATH" path="$CODE_SERVER_PATH"
fi fi
# TODO@jsjoeio - skip if already built
# TODO@jsjoeio - move to integration test suite too
echo "Building test plugin"
pushd test/integration/test-plugin
make -s out/index.js
popd
echo "Running tests with code-server binary: '$path'" echo "Running tests with code-server binary: '$path'"
if [[ ! -f $path ]]; then if [[ ! -f $path ]]; then
@ -33,7 +40,7 @@ main() {
exit 1 exit 1
fi fi
CODE_SERVER_PATH="$path" CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --coverage=false --testRegex "./test/integration" --testPathIgnorePatterns "./test/integration/fixtures" CODE_SERVER_PATH="$path" CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --coverage=false --testRegex "./test/integration" --testPathIgnorePatterns "./test/integration/fixtures" --testPathIgnorePatterns "./test/integration/test-plugin"
} }
main "$@" main "$@"

View File

@ -6,13 +6,6 @@ main() {
source ./ci/lib.sh source ./ci/lib.sh
# TODO@jsjoeio - skip if already built
# TODO@jsjoeio - move to integration test suite too
echo "Building test plugin"
pushd test/unit/node/test-plugin
make -s out/index.js
popd
# Our code imports from `out` in order to work during development but if you # Our code imports from `out` in order to work during development but if you
# have only built for production you will have not have this directory. In # have only built for production you will have not have this directory. In
# that case symlink `out` to a production build directory. # that case symlink `out` to a production build directory.

View File

@ -2,11 +2,11 @@ import { logger } from "@coder/logger"
import * as express from "express" import * as express from "express"
import * as fs from "fs" import * as fs from "fs"
import * as path from "path" import * as path from "path"
import { HttpCode } from "../../../src/common/http" import { HttpCode } from "../../src/common/http"
import { AuthType } from "../../../src/node/cli" import { AuthType } from "../../src/node/cli"
import { codeServer, PluginAPI } from "../../../src/node/plugin" import { codeServer, PluginAPI } from "../../src/node/plugin"
import * as apps from "../../../src/node/routes/apps" import * as apps from "../../src/node/routes/apps"
import * as httpserver from "../../utils/httpserver" import * as httpserver from "../utils/httpserver"
const fsp = fs.promises const fsp = fs.promises
// Jest overrides `require` so our usual override doesn't work. // Jest overrides `require` so our usual override doesn't work.

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,22 +1,26 @@
// TODO@jsjoeio - how do I fix this?
// @ts-ignore - we know code-server exists
import * as cs from "code-server" import * as cs from "code-server"
import * as fspath from "path" import * as fspath from "path"
type FixMeLater = any
export const plugin: cs.Plugin = { export const plugin: cs.Plugin = {
displayName: "Test Plugin", displayName: "Test Plugin",
routerPath: "/test-plugin", routerPath: "/test-plugin",
homepageURL: "https://example.com", homepageURL: "https://example.com",
description: "Plugin used in code-server tests.", description: "Plugin used in code-server tests.",
init(config) { init(config: FixMeLater) {
config.logger.debug("test-plugin loaded!") config.logger.debug("test-plugin loaded!")
}, },
router() { router() {
const r = cs.express.Router() const r = cs.express.Router()
r.get("/test-app", (_, res) => { r.get("/test-app", (_: FixMeLater, res: FixMeLater) => {
res.sendFile(fspath.resolve(__dirname, "../public/index.html")) res.sendFile(fspath.resolve(__dirname, "../public/index.html"))
}) })
r.get("/goland/icon.svg", (_, res) => { r.get("/goland/icon.svg", (_: FixMeLater, res: FixMeLater) => {
res.sendFile(fspath.resolve(__dirname, "../public/icon.svg")) res.sendFile(fspath.resolve(__dirname, "../public/icon.svg"))
}) })
r.get("/error", () => { r.get("/error", () => {
@ -27,8 +31,8 @@ export const plugin: cs.Plugin = {
wsRouter() { wsRouter() {
const wr = cs.WsRouter() const wr = cs.WsRouter()
wr.ws("/test-app", (req) => { wr.ws("/test-app", (req: FixMeLater) => {
cs.wss.handleUpgrade(req, req.ws, req.head, (ws) => { cs.wss.handleUpgrade(req, req.ws, req.head, (ws: FixMeLater) => {
req.ws.resume() req.ws.resume()
ws.send("hello") ws.send("hello")
}) })

View File

@ -1,5 +1,4 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"include": ["./**/*.ts"], "include": ["./**/*.ts"],
"exclude": ["./unit/node/test-plugin"]
} }