Archived
1
0

fix: wrap socket in proxy before passing to vscode (#4840)

* chore: add ipc hook to e2e script

* refactor: allow codeServerArgs in e2e tests

* feat: add --cert e2e extension test

* fix: wrap websocket in proxy

* fixup: remvoe ignoreHTTPSErrors

* fixup: make codeServerArgs readonly

* fixup! add back ignoreHTTPSErrors
This commit is contained in:
Joe Previte
2022-02-15 14:51:42 -07:00
committed by GitHub
parent b26cce589f
commit e3e9f052c4
11 changed files with 34 additions and 13 deletions

View File

@ -9,10 +9,15 @@ import { CodeServer, CodeServerPage } from "./models/CodeServer"
*
* If `includeCredentials` is `true` page requests will be authenticated.
*/
export const describe = (name: string, includeCredentials: boolean, fn: (codeServer: CodeServer) => void) => {
export const describe = (
name: string,
includeCredentials: boolean,
codeServerArgs: string[],
fn: (codeServer: CodeServer) => void,
) => {
test.describe(name, () => {
// This will spawn on demand so nothing is necessary on before.
const codeServer = new CodeServer(name)
const codeServer = new CodeServer(name, codeServerArgs)
// Kill code-server after the suite has ended. This may happen even without
// doing it explicitly but it seems prudent to be sure.
@ -36,6 +41,9 @@ export const describe = (name: string, includeCredentials: boolean, fn: (codeSer
authenticated: includeCredentials,
// This provides a cookie that authenticates with code-server.
storageState: includeCredentials ? storageState : {},
// NOTE@jsjoeio some tests use --cert which uses a self-signed certificate
// without this option, those tests will fail.
ignoreHTTPSErrors: true,
})
fn(codeServer)

View File

@ -1,6 +1,6 @@
import { describe, test, expect } from "./baseFixture"
describe("CodeServer", true, () => {
describe("CodeServer", true, [], () => {
test("should navigate to home page", async ({ codeServerPage }) => {
// We navigate codeServer before each test
// and we start the test with a storage state

View File

@ -1,6 +1,6 @@
import { describe, test } from "./baseFixture"
describe("Extensions", true, () => {
function runTestExtensionTests() {
// This will only work if the test extension is loaded into code-server.
test("should have access to VSCODE_PROXY_URI", async ({ codeServerPage }) => {
const address = await codeServerPage.address()
@ -9,4 +9,12 @@ describe("Extensions", true, () => {
await codeServerPage.page.waitForSelector(`text=${address}/proxy/{{port}}`)
})
}
describe("Extensions", true, [], () => {
runTestExtensionTests()
})
describe("Extensions with --cert", true, ["--cert"], () => {
runTestExtensionTests()
})

View File

@ -2,7 +2,7 @@ import { describe, test, expect } from "./baseFixture"
// This test is to make sure the globalSetup works as expected
// meaning globalSetup ran and stored the storageState
describe("globalSetup", true, () => {
describe("globalSetup", true, [], () => {
test("should keep us logged in using the storageState", async ({ codeServerPage }) => {
// Make sure the editor actually loaded
expect(await codeServerPage.isEditorVisible()).toBe(true)

View File

@ -1,7 +1,7 @@
import { PASSWORD } from "../utils/constants"
import { describe, test, expect } from "./baseFixture"
describe("login", false, () => {
describe("login", false, [], () => {
test("should see the login page", async ({ codeServerPage }) => {
// It should send us to the login page
expect(await codeServerPage.page.title()).toBe("code-server login")

View File

@ -1,7 +1,7 @@
// NOTE@jsjoeio commenting out until we can figure out what's wrong
// import { describe, test, expect } from "./baseFixture"
// describe("logout", true, () => {
// describe("logout", true, [], () => {
// test("should be able logout", async ({ codeServerPage }) => {
// // Recommended by Playwright for async navigation
// // https://github.com/microsoft/playwright/issues/1987#issuecomment-620182151

View File

@ -31,7 +31,7 @@ export class CodeServer {
public readonly logger: Logger
private closed = false
constructor(name: string) {
constructor(name: string, private readonly codeServerArgs: string[]) {
this.logger = logger.named(name)
}
@ -78,6 +78,7 @@ export class CodeServer {
"node",
[
process.env.CODE_SERVER_TEST_ENTRY || ".",
...this.codeServerArgs,
// Using port zero will spawn on a random port.
"--bind-addr",
"127.0.0.1:0",

View File

@ -1,6 +1,6 @@
import { describe, test, expect } from "./baseFixture"
describe("Open Help > About", true, () => {
describe("Open Help > About", true, [], () => {
test("should see code-server version in about dialog", async ({ codeServerPage }) => {
// Open using the menu.
await codeServerPage.navigateMenus(["Help", "About"])

View File

@ -4,7 +4,7 @@ import util from "util"
import { clean, tmpdir } from "../utils/helpers"
import { describe, expect, test } from "./baseFixture"
describe("Integrated Terminal", true, () => {
describe("Integrated Terminal", true, [], () => {
const testName = "integrated-terminal"
test.beforeAll(async () => {
await clean(testName)