import { expect, test } from "@playwright/test"; import { axNode } from "../testing/ax.ts"; const item = (page: import("@playwright/test").Page, label: string) => page.locator("nib-tree-item").filter({ hasText: new RegExp(`^${label.replace(/[.]/g, "\\.")}$`) }); test("the tree exposes its role, label, and item states to assistive tech", async ({ page }) => { await page.goto("/tree.html"); await expect.poll(() => axNode(page, "tree", "Fixture")).toBeTruthy(); await expect.poll(() => axNode(page, "treeitem", "src")).toMatchObject({ level: 1, expanded: false }); await item(page, "src").click(); await expect.poll(() => axNode(page, "treeitem", "src")).toMatchObject({ expanded: true }); }); test("keyboard moves, folds, and activates leaves", async ({ page }) => { await page.goto("/tree.html"); await item(page, "src").focus(); await page.keyboard.press("ArrowRight"); await page.keyboard.press("ArrowRight"); await expect(item(page, "lib")).toBeFocused(); await page.keyboard.press("End"); await expect(item(page, "README.md")).toBeFocused(); await page.keyboard.press("Enter"); await expect(page.locator("#log")).toHaveText("README.md"); });