Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 12 additions & 5 deletions frontend/e2e/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,23 @@ export const pickOption = async (page: Page, field: Locator, name: string) => {
// The menu of the previous dropdown can still be fading out, and the newest one is last in the page
const list = page.getByRole('listbox').last()
await expect(list).toBeVisible()
// Scroll with the mouse wheel over the list, as a user would, until the option is rendered or the end of the list is reached.
// A frame is awaited after each step so the list can render its new rows
// The menu can still be sliding into place (or be re-rendered) when it first appears, and another field can sit under it for a moment,
// so the hover is retried until the list is stable and on top
// Scroll the list until the option is rendered or the end of the list is reached. The scroll position is set directly because mouse
// wheel events are unreliable (smooth scrolling) in headless Firefox. A frame is awaited after each step so the list can render its new rows
await expect(async () => {
await list.hover({ timeout: 2_000 })
}).toPass({ timeout: 10_000 })
for (let step = 0; step < 300 && (await option.count()) === 0; step++) {
await page.mouse.wheel(0, 300)
const atEnd = await list.evaluate((el) => {
const before = el.scrollTop
el.scrollTop += 300
return el.scrollTop === before
})
await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))))
if (atEnd && (await option.count()) === 0) break
}
// A multi-select menu stays open after a pick, so only a single-select one is expected to close
const multiple = (await list.getAttribute('aria-multiselectable')) === 'true'
await option.click()
// Wait for the menu to close so it cannot cover the next field (which may also still be disabled until this pick settles)
if (!multiple) await expect(list).toBeHidden()
}
Loading
Loading