mirror of
https://github.com/coder/code-server.git
synced 2024-11-30 01:36:01 +03:00
18ff99693b
* refactor(heart): extract logic into heartbeatTimer fn To make it easier to test, I extract heartbeatTimer into it's own function. * feat(testing): add tests for heart.ts * fixup * fixup!: remove unneeded heart call * Update src/node/heart.ts Co-authored-by: Asher <ash@coder.com> * fixup!: use mockResolvedValue everywhere * fixup!: add stat test for timestamp check Co-authored-by: Asher <ash@coder.com>
49 lines
1.5 KiB
TypeScript
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)", true, [], {}, 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)", true, ["--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)
|
|
})
|
|
})
|