Skip to content

Commit

Permalink
Attempt to fix Firefox e2e test with context menus
Browse files Browse the repository at this point in the history
  • Loading branch information
code-asher committed Sep 19, 2024
1 parent 150942d commit 355bfac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 2 additions & 8 deletions test/e2e/downloads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ describe("Downloads (enabled)", ["--disable-workspace-trust"], {}, async () => {
await fs.writeFile(tmpFilePath, "hello world")

// Action
const fileInExplorer = await codeServerPage.page.waitForSelector("text=unique-file.txt")
await fileInExplorer.click({
button: "right",
})
await codeServer.openContextMenu("text=unique-file.txt")

expect(await codeServerPage.page.isVisible("text=Download...")).toBe(true)
})
Expand Down Expand Up @@ -73,10 +70,7 @@ describe("Downloads (disabled)", ["--disable-workspace-trust", "--disable-file-d
await fs.writeFile(tmpFilePath, "Hello World")

// Action
const fileInExplorer = await codeServerPage.page.waitForSelector("text=unique-file.txt")
await fileInExplorer.click({
button: "right",
})
await codeServer.openContextMenu("text=unique-file.txt")

expect(await codeServerPage.page.isVisible("text=Download...")).toBe(false)
})
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/models/CodeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,19 @@ export class CodeServerPage {
})
}

/**
* Open context menu on the specified selector.
*/
async openContextMenu(selector: string): Promise<void> {
// Firefox appears to have an issue with right clicking to show the context
// menu. It seems to be related to VS Code trying to handle the clipboard
// although I am not sure why it presents in the file menu. To work around
// it, left click and open the context menu using Shift+F10 instead.
const el = await this.page.waitForSelector(selector)
await el.click({ button: "left" })
await this.page.keyboard.press("Shift+F10")
}

/**
* Execute a command in the root of the instance's workspace directory.
*/
Expand Down

0 comments on commit 355bfac

Please sign in to comment.