diff --git a/test/e2e/downloads.test.ts b/test/e2e/downloads.test.ts index 401cc422774b..241531882d66 100644 --- a/test/e2e/downloads.test.ts +++ b/test/e2e/downloads.test.ts @@ -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) }) @@ -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) }) diff --git a/test/e2e/models/CodeServer.ts b/test/e2e/models/CodeServer.ts index 0e503e493719..7148c19325f3 100644 --- a/test/e2e/models/CodeServer.ts +++ b/test/e2e/models/CodeServer.ts @@ -555,6 +555,19 @@ export class CodeServerPage { }) } + /** + * Open context menu on the specified selector. + */ + async openContextMenu(selector: string): Promise { + // 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. */