Skip to content

fix(testing): revert change & fix playwright tests #4310

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d1e36dd
fix(testing): revert change & fix playwright tests
jsjoeio Oct 4, 2021
53743af
fix(constants): add type to import statement
jsjoeio Oct 5, 2021
1e64920
refactor(e2e): delete browser test
jsjoeio Oct 6, 2021
35381c0
chore(e2e): use 1 worker for e2e test
jsjoeio Oct 7, 2021
4805186
revert(vscode): add missing route with redirect
jsjoeio Oct 7, 2021
0b080f5
chore(vscode): update to latest fork
jsjoeio Oct 7, 2021
d7e7e43
Touch up compilation step.
GirlBossRush Oct 15, 2021
717bb79
Bump vendor.
GirlBossRush Oct 15, 2021
5a28626
Fix VS Code minification step
code-asher Oct 18, 2021
e22a0e5
Move ClientConfiguration to common
code-asher Oct 13, 2021
036ee86
Ensure lib directory exists before curling
code-asher Oct 13, 2021
1acb0a1
Update incorrect e2e test help output
code-asher Oct 13, 2021
467eaef
Add back extension compilation step
code-asher Oct 19, 2021
fd7f1ec
Include missing resources in release
code-asher Oct 19, 2021
70edeb9
Set quality property in product configuration
code-asher Oct 19, 2021
6208a2b
Update VS Code
code-asher Oct 20, 2021
2d628cc
Bump vscode.
GirlBossRush Oct 21, 2021
891eb61
Bump.
GirlBossRush Oct 21, 2021
e81a37e
Bump.
GirlBossRush Oct 21, 2021
b4bda04
Use CLI directly.
GirlBossRush Oct 21, 2021
353c2a1
Update tests to reflect new upstream behavior.
GirlBossRush Oct 7, 2021
c1b40a5
Move unit tests to after the build
code-asher Oct 21, 2021
fd42387
Upgrade proxy-agent dependencies
code-asher Oct 21, 2021
dd8124f
Symlink VS Code output directory before unit tests
code-asher Oct 21, 2021
6efc7b4
Fix issues surrounding persistent processes between tests.
GirlBossRush Oct 22, 2021
6d777c1
Update VS Code cache directories
code-asher Oct 22, 2021
64b6f71
Move test symlink to script
code-asher Oct 22, 2021
752fe7c
Fix listening on a socket
code-asher Oct 22, 2021
0cfd245
Update VS Code
code-asher Oct 26, 2021
51a48ba
Standardize disposals
code-asher Oct 26, 2021
fc81fc3
Dispose HTTP server
code-asher Oct 26, 2021
070d131
Dispose app on exit
code-asher Oct 26, 2021
a343efe
Fix logging link errors
code-asher Oct 26, 2021
8857e67
Update regex used by e2e to extract address
code-asher Oct 27, 2021
7a52cb8
Log browser console in e2e tests
code-asher Oct 27, 2021
44602cc
Add base back to login page
code-asher Oct 28, 2021
6fbbd83
Remove login page test
code-asher Oct 28, 2021
f4a8c9d
Use path.posix for static base
code-asher Oct 28, 2021
02f4e00
Add test for invalid password
code-asher Oct 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/build/build-code-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ main() {
source ./ci/lib.sh
OS="$(uname | tr '[:upper:]' '[:lower:]')"

mkdir -p ./lib

if ! [ -f ./lib/coder-cloud-agent ]; then
echo "Downloading the cloud agent..."

Expand Down
2 changes: 1 addition & 1 deletion ci/build/build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ EOF
bundle_vscode() {
mkdir -p "$VSCODE_OUT_PATH"
rsync "$VSCODE_SRC_PATH/yarn.lock" "$VSCODE_OUT_PATH"
rsync "$VSCODE_SRC_PATH/out-vscode${MINIFY:+-min}/" "$VSCODE_OUT_PATH/out"
rsync "$VSCODE_SRC_PATH/out-vscode-server${MINIFY:+-min}/" "$VSCODE_OUT_PATH/out"

rsync "$VSCODE_SRC_PATH/.build/extensions/" "$VSCODE_OUT_PATH/extensions"
if [ "$KEEP_MODULES" = 0 ]; then
Expand Down
8 changes: 3 additions & 5 deletions ci/build/build-vscode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ main() {

cd vendor/modules/code-oss-dev

yarn gulp compile-build compile-extensions-build compile-extension-media compile-web

yarn gulp optimize --gulpfile ./coder.js

if [[ $MINIFY ]]; then
yarn gulp minify --gulpfile ./coder.js
yarn compile-server-min
else
yarn compile-server
fi
}

Expand Down
3 changes: 3 additions & 0 deletions ci/build/npm-postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ main() {
esac

OS="$(uname | tr '[:upper:]' '[:lower:]')"

mkdir -p ./lib

if curl -fsSL "https://github.com/cdr/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent; then
chmod +x ./lib/coder-cloud-agent
else
Expand Down
11 changes: 9 additions & 2 deletions ci/dev/test-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail

help() {
echo >&2 " You can build with 'yarn watch' or you can build a release"
echo >&2 " For example: 'yarn build && yarn build:vscode && KEEP_MODULES=1 yarn release'"
echo >&2 " Then 'CODE_SERVER_TEST_ENTRY=./release yarn test:e2e'"
echo >&2 " You can manually run that release with 'node ./release'"
}

main() {
cd "$(dirname "$0")/../.."

Expand All @@ -21,13 +28,13 @@ main() {
# wrong (native modules version issues, incomplete build, etc).
if [[ ! -d $dir/out ]]; then
echo >&2 "No code-server build detected"
echo >&2 "You can build it with 'yarn build' or 'yarn watch'"
help
exit 1
fi

if [[ ! -d $dir/vendor/modules/code-oss-dev/out ]]; then
echo >&2 "No VS Code build detected"
echo >&2 "You can build it with 'yarn build:vscode' or 'yarn watch'"
help
exit 1
fi

Expand Down
9 changes: 9 additions & 0 deletions src/common/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ export class HttpError extends Error {
this.name = this.constructor.name
}
}

/**
* Base options included on every page.
*/
export interface ClientConfiguration {
codeServerVersion: string
base: string
csStaticBase: string
}
4 changes: 3 additions & 1 deletion src/common/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ClientConfiguration } from "./http"

/**
* Split a string up to the delimiter. If the delimiter doesn't exist the first
* item will have all the text and the second item will be an empty string.
Expand Down Expand Up @@ -53,7 +55,7 @@ export const resolveBase = (base?: string): string => {
/**
* Get client-side configuration embedded in the HTML or query params.
*/
export const getClientConfiguration = <T extends CodeServerLib.ClientConfiguration>(): T => {
export const getClientConfiguration = <T extends ClientConfiguration>(): T => {
let config: T
try {
config = JSON.parse(document.getElementById("coder-options")!.getAttribute("data-settings")!)
Expand Down
2 changes: 1 addition & 1 deletion src/node/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from "@coder/logger"
import { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package"
import type { JSONSchemaForNPMPackageJsonFiles } from "@schemastore/package"
import * as os from "os"
import * as path from "path"

Expand Down
6 changes: 3 additions & 3 deletions src/node/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as express from "express"
import * as expressCore from "express-serve-static-core"
import path from "path"
import qs from "qs"
import { HttpCode, HttpError } from "../common/http"
import { ClientConfiguration, HttpCode, HttpError } from "../common/http"
import { normalize } from "../common/util"
import { AuthType, DefaultedArgs } from "./cli"
import { version as codeServerVersion } from "./constants"
Expand All @@ -20,7 +20,7 @@ declare global {
}
}

export const createClientConfiguration = (req: express.Request): CodeServerLib.ClientConfiguration => {
export const createClientConfiguration = (req: express.Request): ClientConfiguration => {
const base = relativeRoot(req)

return {
Expand All @@ -38,7 +38,7 @@ export const replaceTemplates = <T extends object>(
content: string,
extraOpts?: Omit<T, "base" | "csStaticBase" | "logLevel">,
): string => {
const serverOptions: CodeServerLib.ClientConfiguration = {
const serverOptions: ClientConfiguration = {
...createClientConfiguration(req),
...extraOpts,
}
Expand Down
13 changes: 12 additions & 1 deletion src/node/routes/vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Server } from "http"
import path from "path"
import { AuthType, DefaultedArgs } from "../cli"
import { version as codeServerVersion, vsRootPath } from "../constants"
import { ensureAuthenticated } from "../http"
import { ensureAuthenticated, authenticated, redirect } from "../http"
import { loadAMDModule } from "../util"
import { Router as WsRouter, WebsocketRouter } from "../wsRouter"
import { errorHandler } from "./errors"
Expand Down Expand Up @@ -53,6 +53,17 @@ export const createVSServerRouter = async (args: DefaultedArgs): Promise<VSServe
const router = express.Router()
const wsRouter = WsRouter()

router.get("/", async (req, res, next) => {
const isAuthenticated = await authenticated(req)
if (!isAuthenticated) {
return redirect(req, res, "login", {
// req.baseUrl can be blank if already at the root.
to: req.baseUrl && req.baseUrl !== "/" ? req.baseUrl : undefined,
})
}
next()
})

router.all("*", ensureAuthenticated, (req, res, next) => {
req.on("error", (error) => errorHandler(error, req, res, next))

Expand Down
15 changes: 0 additions & 15 deletions test/e2e/browser.test.ts

This file was deleted.

7 changes: 6 additions & 1 deletion test/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { PlaywrightTestConfig } from "@playwright/test"

import path from "path"

// Run tests in three browsers.
// The default configuration runs all tests in three browsers with workers equal
// to half the available threads. See 'yarn test:e2e --help' to customize from
// the command line. For example:
// yarn test:e2e --workers 1 # Run with one worker
// yarn test:e2e --project Chromium # Only run on Chromium
// yarn test:e2e --grep login # Run tests matching "login"
const config: PlaywrightTestConfig = {
testDir: path.join(__dirname, "e2e"), // Search for tests in this directory.
timeout: 60000, // Each test is given 60 seconds.
Expand Down
2 changes: 1 addition & 1 deletion vendor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"postinstall": "./postinstall.sh"
},
"devDependencies": {
"code-oss-dev": "cdr/vscode#65b2462c212d415fbf521489307e58e5b691818b"
"code-oss-dev": "cdr/vscode#c545b85566f30f79afa006edbfc3d50f305966a2"
}
}
4 changes: 2 additions & 2 deletions vendor/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ clone-response@^1.0.2:
dependencies:
mimic-response "^1.0.0"

code-oss-dev@cdr/vscode#65b2462c212d415fbf521489307e58e5b691818b:
code-oss-dev@cdr/vscode#c545b85566f30f79afa006edbfc3d50f305966a2:
version "1.60.2"
resolved "https://codeload.github.com/cdr/vscode/tar.gz/65b2462c212d415fbf521489307e58e5b691818b"
resolved "https://codeload.github.com/cdr/vscode/tar.gz/c545b85566f30f79afa006edbfc3d50f305966a2"
dependencies:
"@microsoft/applicationinsights-web" "^2.6.4"
"@vscode/sqlite3" "4.0.12"
Expand Down