feat(e2e): add support running behind proxy (#5348)
* docs: update maintaining * chore(e2e): add maxFailures to playwright * fix(ci): skip submodule in e2e job We don't need the submodules for the e2e job. This will speed up the checkout step. * feat(ci): add test-e2e-proxy job This adds a new job to CI to run our tests behind Caddy and simulate code-server running against a reverse-proxy. * refactor: make e2e work with reverse proxy This refactors the e2e test in a couple ways: - remove setting cookie in localStorage (instead we pass --auth none) - refactor address() method to account for reverse proxy logic * Update test/e2e/models/CodeServer.ts * Update test/playwright.config.ts * Update test/utils/constants.ts Co-authored-by: Asher <ash@coder.com> * Update test/utils/helpers.ts Co-authored-by: Asher <ash@coder.com> Co-authored-by: Asher <ash@coder.com>
This commit is contained in:
@ -1,23 +1,36 @@
|
||||
import * as path from "path"
|
||||
import { describe, test } from "./baseFixture"
|
||||
import { test as base } from "@playwright/test"
|
||||
import { describe, test, expect } from "./baseFixture"
|
||||
import { getMaybeProxiedCodeServer } from "../utils/helpers"
|
||||
|
||||
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()
|
||||
const address = await getMaybeProxiedCodeServer(codeServerPage)
|
||||
|
||||
await codeServerPage.executeCommandViaMenus("code-server: Get proxy URI")
|
||||
|
||||
await codeServerPage.page.waitForSelector(`text=${address}/proxy/{{port}}`)
|
||||
const text = await codeServerPage.page.locator(".notification-list-item-message").textContent()
|
||||
// Remove end slash in address
|
||||
const normalizedAddress = address.replace(/\/+$/, "")
|
||||
expect(text).toBe(`${normalizedAddress}/proxy/{{port}}`)
|
||||
})
|
||||
}
|
||||
|
||||
const flags = ["--extensions-dir", path.join(__dirname, "./extensions")]
|
||||
|
||||
describe("Extensions", true, flags, {}, () => {
|
||||
describe("Extensions", flags, {}, () => {
|
||||
runTestExtensionTests()
|
||||
})
|
||||
|
||||
describe("Extensions with --cert", true, [...flags, "--cert"], {}, () => {
|
||||
runTestExtensionTests()
|
||||
})
|
||||
if (process.env.USE_PROXY !== "1") {
|
||||
describe("Extensions with --cert", [...flags, "--cert"], {}, () => {
|
||||
runTestExtensionTests()
|
||||
})
|
||||
} else {
|
||||
base.describe("Extensions with --cert", () => {
|
||||
base.skip("skipped because USE_PROXY is set", () => {
|
||||
// Playwright will not show this without a function.
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user