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
13 changed files with 22 additions and 19 deletions

View File

@ -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.

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 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) {
init(config: FixMeLater) {
config.logger.debug("test-plugin loaded!")
},
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"))
})
r.get("/goland/icon.svg", (_, res) => {
r.get("/goland/icon.svg", (_: FixMeLater, res: FixMeLater) => {
res.sendFile(fspath.resolve(__dirname, "../public/icon.svg"))
})
r.get("/error", () => {
@ -27,8 +31,8 @@ export const plugin: cs.Plugin = {
wsRouter() {
const wr = cs.WsRouter()
wr.ws("/test-app", (req) => {
cs.wss.handleUpgrade(req, req.ws, req.head, (ws) => {
wr.ws("/test-app", (req: FixMeLater) => {
cs.wss.handleUpgrade(req, req.ws, req.head, (ws: FixMeLater) => {
req.ws.resume()
ws.send("hello")
})

View File

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