2022-04-13 19:39:05 +03:00
|
|
|
import { promises as fs } from "fs"
|
2022-04-26 19:35:40 +03:00
|
|
|
import * as path from "path"
|
2022-04-13 19:39:05 +03:00
|
|
|
import { clean } from "../utils/helpers"
|
|
|
|
import { describe, test, expect } from "./baseFixture"
|
|
|
|
|
2022-10-13 22:57:04 +03:00
|
|
|
describe("Downloads (enabled)", ["--disable-workspace-trust"], {}, async () => {
|
2022-04-13 19:39:05 +03:00
|
|
|
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)
|
|
|
|
})
|
2023-12-08 00:10:22 +03:00
|
|
|
|
|
|
|
test("should see the 'Show Local' button on Save As", async ({ codeServerPage }) => {
|
|
|
|
// Setup
|
|
|
|
const workspaceDir = await codeServerPage.workspaceDir
|
|
|
|
const fileName = "unique-file-save-as.txt"
|
|
|
|
const tmpFilePath = path.join(workspaceDir, fileName)
|
|
|
|
await fs.writeFile(tmpFilePath, "Hello World")
|
|
|
|
|
|
|
|
// Action
|
|
|
|
await codeServerPage.page.waitForSelector(`text=${fileName}`)
|
|
|
|
|
|
|
|
await codeServerPage.openFile(fileName)
|
|
|
|
await codeServerPage.page.click(".tab")
|
|
|
|
await codeServerPage.navigateMenus(["File", "Auto Save"])
|
|
|
|
await codeServerPage.page.keyboard.type("Making some edits.")
|
|
|
|
await codeServerPage.navigateMenus(["File", "Save As..."])
|
|
|
|
await codeServerPage.page.waitForSelector(".quick-input-widget")
|
|
|
|
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should see the 'Show Local' button on Save File", async ({ codeServerPage }) => {
|
|
|
|
// Action
|
|
|
|
await codeServerPage.navigateMenus(["File", "New Text File"])
|
|
|
|
await codeServerPage.waitForTab("Untitled-1")
|
|
|
|
await codeServerPage.navigateMenus(["File", "Save"])
|
|
|
|
await codeServerPage.page.waitForSelector(".quick-input-widget")
|
|
|
|
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should see the 'Show Local' button on Save Workspace As", async ({ codeServerPage }) => {
|
|
|
|
// Action
|
|
|
|
await codeServerPage.navigateMenus(["File", "Save Workspace As..."])
|
|
|
|
await codeServerPage.page.waitForSelector(".quick-input-widget")
|
|
|
|
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(true)
|
|
|
|
})
|
2022-04-13 19:39:05 +03:00
|
|
|
})
|
|
|
|
|
2022-10-13 22:57:04 +03:00
|
|
|
describe("Downloads (disabled)", ["--disable-workspace-trust", "--disable-file-downloads"], {}, async () => {
|
2022-04-13 19:39:05 +03:00
|
|
|
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")
|
2023-12-08 00:10:22 +03:00
|
|
|
await fs.writeFile(tmpFilePath, "Hello World")
|
2022-04-13 19:39:05 +03:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
})
|
2023-12-08 00:10:22 +03:00
|
|
|
|
|
|
|
test("should not see the 'Show Local' button on Save as", async ({ codeServerPage }) => {
|
|
|
|
// Setup
|
|
|
|
const workspaceDir = await codeServerPage.workspaceDir
|
|
|
|
const fileName = "unique-file-save-as.txt"
|
|
|
|
const tmpFilePath = path.join(workspaceDir, fileName)
|
|
|
|
await fs.writeFile(tmpFilePath, "Hello World")
|
|
|
|
|
|
|
|
// Action
|
|
|
|
await codeServerPage.page.waitForSelector(`text=${fileName}`)
|
|
|
|
await codeServerPage.openFile(fileName)
|
|
|
|
await codeServerPage.page.click(".tab")
|
|
|
|
await codeServerPage.navigateMenus(["File", "Save As..."])
|
|
|
|
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should not see the 'Show Local' button on Save File", async ({ codeServerPage }) => {
|
|
|
|
// Action
|
|
|
|
await codeServerPage.navigateMenus(["File", "New Text File"])
|
|
|
|
await codeServerPage.waitForTab("Untitled-1")
|
|
|
|
await codeServerPage.navigateMenus(["File", "Save"])
|
|
|
|
await codeServerPage.page.waitForSelector(".quick-input-widget")
|
|
|
|
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should not see the 'Show Local' button on Save Workspace As", async ({ codeServerPage }) => {
|
|
|
|
// Action
|
|
|
|
await codeServerPage.navigateMenus(["File", "Save Workspace As..."])
|
|
|
|
await codeServerPage.page.waitForSelector(".quick-input-widget")
|
|
|
|
expect(await codeServerPage.page.isVisible("text=Show Local")).toBe(false)
|
|
|
|
})
|
2022-04-13 19:39:05 +03:00
|
|
|
})
|