code-server/test/e2e/downloads.test.ts
Joe Previte f178f0400b
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>
2022-08-09 18:24:37 +00:00

49 lines
1.5 KiB
TypeScript

import { promises as fs } from "fs"
import * as path from "path"
import { clean } from "../utils/helpers"
import { describe, test, expect } from "./baseFixture"
describe("Downloads (enabled)", [], {}, async () => {
const testName = "downloads-enabled"
test.beforeAll(async () => {
await clean(testName)
})
test("should see the 'Download...' option", async ({ codeServerPage }) => {
// Setup
const workspaceDir = await codeServerPage.workspaceDir
const tmpFilePath = path.join(workspaceDir, "unique-file.txt")
await fs.writeFile(tmpFilePath, "hello world")
// Action
const fileInExplorer = await codeServerPage.page.waitForSelector("text=unique-file.txt")
await fileInExplorer.click({
button: "right",
})
expect(await codeServerPage.page.isVisible("text=Download...")).toBe(true)
})
})
describe("Downloads (disabled)", ["--disable-file-downloads"], {}, async () => {
const testName = "downloads-disabled"
test.beforeAll(async () => {
await clean(testName)
})
test("should not see the 'Download...' option", async ({ codeServerPage }) => {
// Setup
const workspaceDir = await codeServerPage.workspaceDir
const tmpFilePath = path.join(workspaceDir, "unique-file.txt")
await fs.writeFile(tmpFilePath, "hello world")
// Action
const fileInExplorer = await codeServerPage.page.waitForSelector("text=unique-file.txt")
await fileInExplorer.click({
button: "right",
})
expect(await codeServerPage.page.isVisible("text=Download...")).toBe(false)
})
})