Skip to content

Commit 355bfac

Browse files
committed
Attempt to fix Firefox e2e test with context menus
1 parent 150942d commit 355bfac

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

test/e2e/downloads.test.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ describe("Downloads (enabled)", ["--disable-workspace-trust"], {}, async () => {
1616
await fs.writeFile(tmpFilePath, "hello world")
1717

1818
// Action
19-
const fileInExplorer = await codeServerPage.page.waitForSelector("text=unique-file.txt")
20-
await fileInExplorer.click({
21-
button: "right",
22-
})
19+
await codeServer.openContextMenu("text=unique-file.txt")
2320

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

7572
// Action
76-
const fileInExplorer = await codeServerPage.page.waitForSelector("text=unique-file.txt")
77-
await fileInExplorer.click({
78-
button: "right",
79-
})
73+
await codeServer.openContextMenu("text=unique-file.txt")
8074

8175
expect(await codeServerPage.page.isVisible("text=Download...")).toBe(false)
8276
})

test/e2e/models/CodeServer.ts

+13
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,19 @@ export class CodeServerPage {
555555
})
556556
}
557557

558+
/**
559+
* Open context menu on the specified selector.
560+
*/
561+
async openContextMenu(selector: string): Promise<void> {
562+
// Firefox appears to have an issue with right clicking to show the context
563+
// menu. It seems to be related to VS Code trying to handle the clipboard
564+
// although I am not sure why it presents in the file menu. To work around
565+
// it, left click and open the context menu using Shift+F10 instead.
566+
const el = await this.page.waitForSelector(selector)
567+
await el.click({ button: "left" })
568+
await this.page.keyboard.press("Shift+F10")
569+
}
570+
558571
/**
559572
* Execute a command in the root of the instance's workspace directory.
560573
*/

0 commit comments

Comments
 (0)