code-server/test/e2e/extensions.test.ts
Joe Previte 031e903979
feat: enable forwarded ports using built-in proxy (#5673)
* feat: enable ports panel in proxy-uri patch

This makes the forwarded ports panel enabled by default.

* feat: add tunnelProvider in proxy-uri patch

This adds a `tunnelProvider` along with a `tunnelFactory` so that ports
are forwarded and use code-server's built-in proxy.

* fixup!: update import

* fix: skip uri modification if authority host match

This adds a check in our `resolveExternalUri` patch to skip modifying if
the `authority` and the `location.host` match to prevent
`localhost:<port>/proxy/<port>` from being modified.

* fixup!: refresh patch

* fixup!: move authority check up

* fixup!: remove comment

* fixup!: add trailing slash
2022-10-24 18:11:44 +00:00

39 lines
1.4 KiB
TypeScript

import { test as base } from "@playwright/test"
import * as path from "path"
import { getMaybeProxiedCodeServer } from "../utils/helpers"
import { describe, test, expect } from "./baseFixture"
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 getMaybeProxiedCodeServer(codeServerPage)
await codeServerPage.waitForTestExtensionLoaded()
await codeServerPage.executeCommandViaMenus("code-server: Get proxy URI")
await codeServerPage.page.waitForSelector("text=proxyUri", { timeout: 3000 })
const text = await codeServerPage.page.locator("text=proxyUri").first().textContent()
// Remove end slash in address
const normalizedAddress = address.replace(/\/+$/, "")
expect(text).toBe(`Info: proxyUri: ${normalizedAddress}/proxy/{{port}}/`)
})
}
const flags = ["--disable-workspace-trust", "--extensions-dir", path.join(__dirname, "./extensions")]
describe("Extensions", flags, {}, () => {
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.
})
})
}