Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions apps/desktop/e2e/browser-page-dialogs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,
?.getURL() ?? null,
site
)
const focusedContentsUrl = () =>
shellApp.evaluate(({ webContents }) => webContents.getFocusedWebContents()?.getURL())
/** Trusted input into the page, the way the user's own mouse and keys arrive. */
const userInput = (selector: string, text = '') =>
shellApp.evaluate(
Expand Down Expand Up @@ -436,6 +438,9 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,

await check('Escape keeps the draft and returns typing to the page', async () => {
await userInput('#draft')
// The click is queued input: reloading before the page takes focus lets that focus land
// after the modal's, leaving the Sim window without keyboard focus.
await expect.poll(focusedContentsUrl).toBe(`${site}/form`)
await panelAction({ action: 'reload' })
await expect(shell.getByRole('button', { name: 'Stay', exact: true })).toBeFocused()
await shell.getByRole('dialog').screenshot({
Expand All @@ -451,11 +456,7 @@ createRoot(document.getElementById('root')).render(createElement(Fixture));`,
message: `dialog ${shown?.requestId} was showing when Escape was pressed`,
})
.toBeNull()
await expect
.poll(() =>
shellApp.evaluate(({ webContents }) => webContents.getFocusedWebContents()?.getURL())
)
.toBe(`${site}/form`)
await expect.poll(focusedContentsUrl).toBe(`${site}/form`)
await shellApp.evaluate(({ webContents }) => {
const contents = webContents.getFocusedWebContents()
if (!contents) throw new Error('Missing focused page')
Expand Down
Loading