2022-08-09 20:24:37 +02:00
|
|
|
import { test as base } from "@playwright/test"
|
2022-08-15 21:27:50 +02:00
|
|
|
import * as path from "path"
|
2022-08-09 20:24:37 +02:00
|
|
|
import { getMaybeProxiedCodeServer } from "../utils/helpers"
|
2022-08-15 21:27:50 +02:00
|
|
|
import { describe, test, expect } from "./baseFixture"
|
2022-01-04 22:02:25 +01:00
|
|
|
|
2022-02-15 22:51:42 +01:00
|
|
|
function runTestExtensionTests() {
|
2022-01-04 22:02:25 +01: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-09 20:24:37 +02:00
|
|
|
const address = await getMaybeProxiedCodeServer(codeServerPage)
|
2022-01-04 22:02:25 +01:00
|
|
|
|
2022-08-22 21:47:36 +02:00
|
|
|
await codeServerPage.waitForTestExtensionLoaded()
|
2022-01-04 22:02:25 +01:00
|
|
|
await codeServerPage.executeCommandViaMenus("code-server: Get proxy URI")
|
|
|
|
|
2022-08-22 21:47:36 +02:00
|
|
|
await codeServerPage.page.waitForSelector("text=proxyUri", { timeout: 3000 })
|
|
|
|
const text = await codeServerPage.page.locator("text=proxyUri").first().textContent()
|
2022-08-09 20:24:37 +02:00
|
|
|
// Remove end slash in address
|
|
|
|
const normalizedAddress = address.replace(/\/+$/, "")
|
2022-08-22 21:47:36 +02:00
|
|
|
expect(text).toBe(`Info: proxyUri: ${normalizedAddress}/proxy/{{port}}`)
|
2022-01-04 22:02:25 +01:00
|
|
|
})
|
2022-02-15 22:51:42 +01:00
|
|
|
}
|
|
|
|
|
2022-03-02 21:02:51 +01:00
|
|
|
const flags = ["--extensions-dir", path.join(__dirname, "./extensions")]
|
|
|
|
|
2022-08-09 20:24:37 +02:00
|
|
|
describe("Extensions", flags, {}, () => {
|
2022-02-15 22:51:42 +01:00
|
|
|
runTestExtensionTests()
|
|
|
|
})
|
|
|
|
|
2022-08-09 20:24:37 +02: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.
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|