mirror of
https://github.com/block/buzz.git
synced 2026-10-28 21:11:48 +00:00
test(desktop): await native block selection before typing
Apply sealed 6492 test-only readiness correction; production is unchanged. Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <loganj@squareup.com>
This commit is contained in:
@@ -307,7 +307,26 @@ for (const format of [
|
||||
await input.pressSequentially("before");
|
||||
await input.press("Shift+Enter");
|
||||
await applyCaretFormat(page, format.label);
|
||||
await input.pressSequentially("inside");
|
||||
// Toolbar focus synchronizes the new caret on a later animation frame.
|
||||
// Locator typing would focus the DOM itself, reviving the old caret.
|
||||
await expect(input).toBeFocused();
|
||||
await expect
|
||||
.poll(() =>
|
||||
input.evaluate((element, selector) => {
|
||||
const block = element.querySelector(`:scope > ${selector}`);
|
||||
const selection = window.getSelection();
|
||||
return (
|
||||
document.activeElement === element &&
|
||||
!!selection?.isCollapsed &&
|
||||
!!selection.anchorNode &&
|
||||
!!selection.focusNode &&
|
||||
!!block?.contains(selection.anchorNode) &&
|
||||
block.contains(selection.focusNode)
|
||||
);
|
||||
}, format.selector),
|
||||
)
|
||||
.toBe(true);
|
||||
await page.keyboard.type("inside");
|
||||
|
||||
await expect(input.locator(":scope > p").first()).toHaveText("before");
|
||||
await expect(input.locator(`:scope > ${format.selector}`)).toHaveText(
|
||||
|
||||
Reference in New Issue
Block a user