Skip to content

Commit 23978dd

Browse files
klopez4212Terp
andcommitted
Fix navigation and caret prerequisites in browser journeys
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Signed-off-by: klopez4212 <[email protected]>
1 parent 26f5e08 commit 23978dd

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

‎tests/browser/composer-focus.spec.mjs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,22 @@ test.describe("text field focus appearance", () => {
276276
.getByRole("textbox");
277277
await input.click();
278278
await page.keyboard.type("A draft");
279+
await expect(input).toHaveText("A draft");
280+
const caret = () =>
281+
input.evaluate((element) => {
282+
const selection = document.getSelection();
283+
return selection?.isCollapsed &&
284+
element.contains(selection.anchorNode)
285+
? selection.anchorOffset
286+
: -1;
287+
});
288+
// Observe each native selection move before sending the next key.
289+
await expect.poll(caret).toBe(7);
279290
await expect(input).toHaveCSS("outline-style", "none");
280291
await page.keyboard.press("ArrowLeft");
292+
await expect.poll(caret).toBe(6);
281293
await page.keyboard.press("ArrowRight");
294+
await expect.poll(caret).toBe(7);
282295
await expect(page.locator("html")).toHaveAttribute(
283296
"data-keyboard-navigation",
284297
"",

‎tests/browser/focus-navigation.spec.mjs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { test, expect } from "./fixture.mjs";
22
import {
3+
activityRow,
34
closeSettings,
5+
openPage,
46
settlePanelMotion,
57
settleShellToggle,
68
} from "./navigation.mjs";
@@ -626,10 +628,7 @@ test.extend({
626628
async ({ page, app }) => {
627629
await page.setViewportSize({ width: 1100, height: 900 });
628630
await open(page, app);
629-
await page
630-
.getByRole("navigation", { name: "Apps dock", exact: true })
631-
.getByRole("tab", { name: "Activity", exact: true })
632-
.click();
631+
await activityRow(page).click();
633632
const inbox = page.getByRole("region", { name: "Activity", exact: true });
634633
await expect(inbox.getByText("Checking recent activity…")).toHaveCount(0);
635634
const row = inbox
@@ -665,6 +664,9 @@ test.extend({
665664
),
666665
).toBe(false);
667666
}
667+
// Close from the pane being removed. Surviving navigation controls keep
668+
// their focus, and Shift+Tab can reach different ones in each engine.
669+
await tab.focus();
668670
const handled = await page.evaluate(() => {
669671
const event = new Event("buzz:close-all-tabs", { cancelable: true });
670672
window.dispatchEvent(event);
@@ -802,10 +804,9 @@ test("escaping a restored side panel over the conversation returns focus to the
802804
.click();
803805
const todos = page.getByRole("region", { name: "Todos panel", exact: true });
804806
await expect(todos).toBeVisible();
805-
const dock = page.getByRole("navigation", { name: "Apps dock", exact: true });
806-
await dock.getByRole("tab", { name: "Activity", exact: true }).click();
807+
await activityRow(page).click();
807808
await expect(todos).toHaveCount(0);
808-
await dock.getByRole("tab", { name: "Messages", exact: true }).click();
809+
await openPage(page, "Messages");
809810
await expect(todos).toBeVisible();
810811
await page
811812
.getByRole("textbox", { name: "Message #Alpha", exact: true })

0 commit comments

Comments
 (0)