diff --git a/ci/dev/test-integration.sh b/ci/dev/test-integration.sh index fa2adb59a..2d46bb895 100755 --- a/ci/dev/test-integration.sh +++ b/ci/dev/test-integration.sh @@ -24,11 +24,6 @@ main() { path="$CODE_SERVER_PATH" fi - echo "Building test plugin" - pushd test/integration/test-plugin - make -s out/index.js - popd - echo "Running tests with code-server binary: '$path'" if [[ ! -f $path ]]; then @@ -38,7 +33,7 @@ main() { exit 1 fi - 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" + CODE_SERVER_PATH="$path" CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --coverage=false --testRegex "./test/integration" --testPathIgnorePatterns "./test/integration/fixtures" } main "$@" diff --git a/ci/dev/test-unit.sh b/ci/dev/test-unit.sh index fe631335a..07cb4d9ab 100755 --- a/ci/dev/test-unit.sh +++ b/ci/dev/test-unit.sh @@ -6,6 +6,13 @@ main() { 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 # have only built for production you will have not have this directory. In # that case symlink `out` to a production build directory. diff --git a/test/tsconfig.json b/test/tsconfig.json index 5197ce276..3e568e887 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,4 +1,5 @@ { "extends": "../tsconfig.json", - "include": ["./**/*.ts"] + "include": ["./**/*.ts"], + "exclude": ["./unit/node/test-plugin"] } diff --git a/test/integration/plugin.test.ts b/test/unit/node/plugin.test.ts similarity index 92% rename from test/integration/plugin.test.ts rename to test/unit/node/plugin.test.ts index 2df91d0c5..88210fd85 100644 --- a/test/integration/plugin.test.ts +++ b/test/unit/node/plugin.test.ts @@ -2,11 +2,11 @@ import { logger } from "@coder/logger" import * as express from "express" import * as fs from "fs" import * as path from "path" -import { HttpCode } from "../../src/common/http" -import { AuthType } from "../../src/node/cli" -import { codeServer, PluginAPI } from "../../src/node/plugin" -import * as apps from "../../src/node/routes/apps" -import * as httpserver from "../utils/httpserver" +import { HttpCode } from "../../../src/common/http" +import { AuthType } from "../../../src/node/cli" +import { codeServer, PluginAPI } from "../../../src/node/plugin" +import * as apps from "../../../src/node/routes/apps" +import * as httpserver from "../../utils/httpserver" const fsp = fs.promises // Jest overrides `require` so our usual override doesn't work. diff --git a/test/integration/test-plugin/.eslintrc.js b/test/unit/node/test-plugin/.eslintrc.js similarity index 100% rename from test/integration/test-plugin/.eslintrc.js rename to test/unit/node/test-plugin/.eslintrc.js diff --git a/test/integration/test-plugin/.gitignore b/test/unit/node/test-plugin/.gitignore similarity index 100% rename from test/integration/test-plugin/.gitignore rename to test/unit/node/test-plugin/.gitignore diff --git a/test/integration/test-plugin/Makefile b/test/unit/node/test-plugin/Makefile similarity index 100% rename from test/integration/test-plugin/Makefile rename to test/unit/node/test-plugin/Makefile diff --git a/test/integration/test-plugin/package.json b/test/unit/node/test-plugin/package.json similarity index 100% rename from test/integration/test-plugin/package.json rename to test/unit/node/test-plugin/package.json diff --git a/test/integration/test-plugin/public/icon.svg b/test/unit/node/test-plugin/public/icon.svg similarity index 100% rename from test/integration/test-plugin/public/icon.svg rename to test/unit/node/test-plugin/public/icon.svg diff --git a/test/integration/test-plugin/public/index.html b/test/unit/node/test-plugin/public/index.html similarity index 100% rename from test/integration/test-plugin/public/index.html rename to test/unit/node/test-plugin/public/index.html diff --git a/test/integration/test-plugin/src/index.ts b/test/unit/node/test-plugin/src/index.ts similarity index 77% rename from test/integration/test-plugin/src/index.ts rename to test/unit/node/test-plugin/src/index.ts index 3ecbe7219..22ef723ba 100644 --- a/test/integration/test-plugin/src/index.ts +++ b/test/unit/node/test-plugin/src/index.ts @@ -1,24 +1,22 @@ import * as cs from "code-server" import * as fspath from "path" -type FixMeLater = any - export const plugin: cs.Plugin = { displayName: "Test Plugin", routerPath: "/test-plugin", homepageURL: "https://example.com", description: "Plugin used in code-server tests.", - init(config: FixMeLater) { + init(config) { config.logger.debug("test-plugin loaded!") }, router() { const r = cs.express.Router() - r.get("/test-app", (_: FixMeLater, res: FixMeLater) => { + r.get("/test-app", (_, res) => { res.sendFile(fspath.resolve(__dirname, "../public/index.html")) }) - r.get("/goland/icon.svg", (_: FixMeLater, res: FixMeLater) => { + r.get("/goland/icon.svg", (_, res) => { res.sendFile(fspath.resolve(__dirname, "../public/icon.svg")) }) r.get("/error", () => { @@ -29,8 +27,8 @@ export const plugin: cs.Plugin = { wsRouter() { const wr = cs.WsRouter() - wr.ws("/test-app", (req: FixMeLater) => { - cs.wss.handleUpgrade(req, req.ws, req.head, (ws: FixMeLater) => { + wr.ws("/test-app", (req) => { + cs.wss.handleUpgrade(req, req.ws, req.head, (ws) => { req.ws.resume() ws.send("hello") }) diff --git a/test/integration/test-plugin/tsconfig.json b/test/unit/node/test-plugin/tsconfig.json similarity index 100% rename from test/integration/test-plugin/tsconfig.json rename to test/unit/node/test-plugin/tsconfig.json diff --git a/test/integration/test-plugin/yarn.lock b/test/unit/node/test-plugin/yarn.lock similarity index 100% rename from test/integration/test-plugin/yarn.lock rename to test/unit/node/test-plugin/yarn.lock