Skip to content

Commit 42b873f

Browse files
committed
wip: migrate more tests
1 parent c7199fd commit 42b873f

File tree

3 files changed

+19
-44
lines changed

3 files changed

+19
-44
lines changed

test/e2e/routes.test.ts

+14
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ describe("VS Code Routes with code-workspace", ["--disable-workspace-trust", COD
5656
})
5757
})
5858

59+
const CODE_FOLDER_DIR = process.env.CODE_FOLDER_DIR || ""
60+
describe("VS Code Routes with code-workspace", ["--disable-workspace-trust", CODE_FOLDER_DIR], {}, async () => {
61+
const testName = "vscode-routes"
62+
test.beforeAll(async () => {
63+
await clean(testName)
64+
})
65+
66+
test.only("should redirect to the passed in folder using human-readable query", async ({ codeServerPage }) => {
67+
const url = new URL(codeServerPage.page.url())
68+
expect(url.pathname).toBe("/")
69+
expect(url.search).toBe(`?folder=${CODE_FOLDER_DIR}`)
70+
})
71+
})
72+
5973
describe(
6074
"VS Code Routes with ignore-last-opened",
6175
["--disable-workspace-trust", "--ignore-last-opened"],

test/unit/node/routes/vscode.test.ts

-43
Original file line numberDiff line numberDiff line change
@@ -23,49 +23,6 @@ describe.skip("vscode", () => {
2323

2424
const routes = ["/", "/vscode", "/vscode/"]
2525

26-
it("should load all route variations", async () => {
27-
codeServer = await integration.setup(["--auth=none"], "")
28-
29-
for (const route of routes) {
30-
const resp = await codeServer.fetch(route)
31-
expect(resp.status).toBe(200)
32-
const html = await resp.text()
33-
const url = new URL(resp.url) // Check there were no redirections.
34-
expect(url.pathname + url.search).toBe(route)
35-
36-
switch (route) {
37-
case "/":
38-
case "/vscode/":
39-
expect(html).toMatch(/src="\.\/[a-z]+-[0-9a-z]+\/static\//)
40-
break
41-
case "/vscode":
42-
expect(html).toMatch(/src="\.\/vscode\/[a-z]+-[0-9a-z]+\/static\//)
43-
break
44-
}
45-
}
46-
})
47-
48-
it("should redirect to the passed in workspace using human-readable query", async () => {
49-
const workspace = path.join(await tmpdir(testName), "test.code-workspace")
50-
await fs.writeFile(workspace, "")
51-
codeServer = await integration.setup(["--auth=none", workspace], "")
52-
53-
const resp = await codeServer.fetch("/")
54-
const url = new URL(resp.url)
55-
expect(url.pathname).toBe("/")
56-
expect(url.search).toBe(`?workspace=${workspace}`)
57-
})
58-
59-
it("should redirect to the passed in folder using human-readable query", async () => {
60-
const folder = await tmpdir(testName)
61-
codeServer = await integration.setup(["--auth=none", folder], "")
62-
63-
const resp = await codeServer.fetch("/")
64-
const url = new URL(resp.url)
65-
expect(url.pathname).toBe("/")
66-
expect(url.search).toBe(`?folder=${folder}`)
67-
})
68-
6926
it("should redirect to last query folder/workspace", async () => {
7027
codeServer = await integration.setup(["--auth=none"], "")
7128

test/utils/globalE2eSetup.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ export default async function () {
1919
wtfnode.setup()
2020
}
2121

22-
// Create dummy code-workspace
22+
// Create dummy code-workspace for routes.test.ts
2323
const codeWorkspace = path.join(await tmpdir(workspaceDir), "test.code-workspace")
2424
await fs.writeFile(codeWorkspace, "")
2525
process.env.CODE_WORKSPACE_DIR = codeWorkspace
2626

27+
// Create dummy folder for routes.test.ts
28+
const folder = await tmpdir(workspaceDir)
29+
process.env.CODE_FOLDER_DIR = folder
30+
2731
console.log("✅ Global Setup for Playwright End-to-End Tests is now complete.")
2832
}

0 commit comments

Comments
 (0)