2022-08-10 02:24:37 +08:00
|
|
|
import { test as base } from "@playwright/test"
|
2022-08-16 03:27:50 +08:00
|
|
|
import * as path from "path"
|
2022-08-10 02:24:37 +08:00
|
|
|
import { getMaybeProxiedCodeServer } from "../utils/helpers"
|
2022-08-16 03:27:50 +08:00
|
|
|
import { describe, test, expect } from "./baseFixture"
|
2022-01-05 05:02:25 +08:00
|
|
|
|
2022-02-16 05:51:42 +08:00
|
|
|
function runTestExtensionTests() {
|
2022-01-05 05:02:25 +08:00
|
|
|
// This will only work if the test extension is loaded into code-server.
|
|
|
|
test("should have access to VSCODE_PROXY_URI", async ({ codeServerPage }) => {
|
2022-08-10 02:24:37 +08:00
|
|
|
const address = await getMaybeProxiedCodeServer(codeServerPage)
|
2022-01-05 05:02:25 +08:00
|
|
|
|
2022-08-23 03:47:36 +08:00
|
|
|
await codeServerPage.waitForTestExtensionLoaded()
|
2022-01-05 05:02:25 +08:00
|
|
|
await codeServerPage.executeCommandViaMenus("code-server: Get proxy URI")
|
|
|
|
|
2022-08-23 03:47:36 +08:00
|
|
|
await codeServerPage.page.waitForSelector("text=proxyUri", { timeout: 3000 })
|
|
|
|
const text = await codeServerPage.page.locator("text=proxyUri").first().textContent()
|
2022-08-10 02:24:37 +08:00
|
|
|
// Remove end slash in address
|
|
|
|
const normalizedAddress = address.replace(/\/+$/, "")
|
2022-10-25 02:11:44 +08:00
|
|
|
expect(text).toBe(`Info: proxyUri: ${normalizedAddress}/proxy/{{port}}/`)
|
2022-01-05 05:02:25 +08:00
|
|
|
})
|
2022-02-16 05:51:42 +08:00
|
|
|
}
|
|
|
|
|
2022-10-14 03:57:04 +08:00
|
|
|
const flags = ["--disable-workspace-trust", "--extensions-dir", path.join(__dirname, "./extensions")]
|
2022-03-03 04:02:51 +08:00
|
|
|
|
2022-08-10 02:24:37 +08:00
|
|
|
describe("Extensions", flags, {}, () => {
|
2022-02-16 05:51:42 +08:00
|
|
|
runTestExtensionTests()
|
|
|
|
})
|
|
|
|
|
2022-08-10 02:24:37 +08:00
|
|
|
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.
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|