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
14 changes: 12 additions & 2 deletions packages/host/core/browser/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,19 @@ export async function modeGroup(scope: Scope): Promise<Locator> {
await menu.waitFor()
return menu.getByRole('radiogroup', {name: 'Comparison mode'})
}
/** Chooses a comparison mode (in the menu, choosing closes it). */
/**
* Chooses a comparison mode. In the menu, choosing closes it, and this returns once the menu has handed focus on: it
* does so only as it unmounts, after its exit animation, so a control the test focused before then would lose its
* focus, and the keys pressed next would miss it.
*/
export async function chooseMode(scope: Scope, name: string) {
await (await modeGroup(scope)).getByRole('radio', {name, exact: true}).click()
const group = await modeGroup(scope)
const inMenu = (await group.locator('xpath=ancestor::*[@role="dialog"]').count()) > 0
await group.getByRole('radio', {name, exact: true}).click()
if (!inMenu) return
await settled(scope)
// The popover's focus scope hands focus on in a timer it starts as it unmounts; one started now runs after it.
await pageOf(scope).evaluate(() => new Promise(resolve => setTimeout(resolve, 0)))
}
/** Asserts the checked mode, closing the menu again if it had to be opened. */
export async function expectMode(scope: Scope, name: string) {
Expand Down