Skip to content

Commit bc02005

Browse files
committed
refactor: move test-plugin to integration suite
This seems more appropriate given this tests how a plugin might work within code-server.
1 parent a094400 commit bc02005

File tree

13 files changed

+22
-19
lines changed

13 files changed

+22
-19
lines changed

ci/dev/test-integration.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ main() {
2424
path="$CODE_SERVER_PATH"
2525
fi
2626

27+
# TODO@jsjoeio - skip if already built
28+
# TODO@jsjoeio - move to integration test suite too
29+
echo "Building test plugin"
30+
pushd test/integration/test-plugin
31+
make -s out/index.js
32+
popd
33+
2734
echo "Running tests with code-server binary: '$path'"
2835

2936
if [[ ! -f $path ]]; then
@@ -33,7 +40,7 @@ main() {
3340
exit 1
3441
fi
3542

36-
CODE_SERVER_PATH="$path" CS_DISABLE_PLUGINS=true ./test/node_modules/.bin/jest "$@" --coverage=false --testRegex "./test/integration" --testPathIgnorePatterns "./test/integration/fixtures"
43+
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"
3744
}
3845

3946
main "$@"

ci/dev/test-unit.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ main() {
66

77
source ./ci/lib.sh
88

9-
# TODO@jsjoeio - skip if already built
10-
# TODO@jsjoeio - move to integration test suite too
11-
echo "Building test plugin"
12-
pushd test/unit/node/test-plugin
13-
make -s out/index.js
14-
popd
15-
169
# Our code imports from `out` in order to work during development but if you
1710
# have only built for production you will have not have this directory. In
1811
# that case symlink `out` to a production build directory.

test/unit/node/plugin.test.ts renamed to test/integration/plugin.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { logger } from "@coder/logger"
22
import * as express from "express"
33
import * as fs from "fs"
44
import * as path from "path"
5-
import { HttpCode } from "../../../src/common/http"
6-
import { AuthType } from "../../../src/node/cli"
7-
import { codeServer, PluginAPI } from "../../../src/node/plugin"
8-
import * as apps from "../../../src/node/routes/apps"
9-
import * as httpserver from "../../utils/httpserver"
5+
import { HttpCode } from "../../src/common/http"
6+
import { AuthType } from "../../src/node/cli"
7+
import { codeServer, PluginAPI } from "../../src/node/plugin"
8+
import * as apps from "../../src/node/routes/apps"
9+
import * as httpserver from "../utils/httpserver"
1010
const fsp = fs.promises
1111

1212
// Jest overrides `require` so our usual override doesn't work.

test/unit/node/test-plugin/src/index.ts renamed to test/integration/test-plugin/src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
// TODO@jsjoeio - how do I fix this?
2+
// @ts-ignore - we know code-server exists
13
import * as cs from "code-server"
24
import * as fspath from "path"
35

6+
type FixMeLater = any
7+
48
export const plugin: cs.Plugin = {
59
displayName: "Test Plugin",
610
routerPath: "/test-plugin",
711
homepageURL: "https://example.com",
812
description: "Plugin used in code-server tests.",
913

10-
init(config) {
14+
init(config: FixMeLater) {
1115
config.logger.debug("test-plugin loaded!")
1216
},
1317

1418
router() {
1519
const r = cs.express.Router()
16-
r.get("/test-app", (_, res) => {
20+
r.get("/test-app", (_: FixMeLater, res: FixMeLater) => {
1721
res.sendFile(fspath.resolve(__dirname, "../public/index.html"))
1822
})
19-
r.get("/goland/icon.svg", (_, res) => {
23+
r.get("/goland/icon.svg", (_: FixMeLater, res: FixMeLater) => {
2024
res.sendFile(fspath.resolve(__dirname, "../public/icon.svg"))
2125
})
2226
r.get("/error", () => {
@@ -27,8 +31,8 @@ export const plugin: cs.Plugin = {
2731

2832
wsRouter() {
2933
const wr = cs.WsRouter()
30-
wr.ws("/test-app", (req) => {
31-
cs.wss.handleUpgrade(req, req.ws, req.head, (ws) => {
34+
wr.ws("/test-app", (req: FixMeLater) => {
35+
cs.wss.handleUpgrade(req, req.ws, req.head, (ws: FixMeLater) => {
3236
req.ws.resume()
3337
ws.send("hello")
3438
})

test/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"extends": "../tsconfig.json",
33
"include": ["./**/*.ts"],
4-
"exclude": ["./unit/node/test-plugin"]
54
}

0 commit comments

Comments
 (0)