Attempt to fix Firefox e2e test with context menus

This commit is contained in:
Asher 2024-09-18 16:11:07 -08:00
parent 150942dc10
commit df09d5f607
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 15 additions and 8 deletions

View File

@ -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 codeServerPage.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 codeServerPage.openContextMenu("text=unique-file.txt")
expect(await codeServerPage.page.isVisible("text=Download...")).toBe(false)
})

View File

@ -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.
*/