import { expect, test } from "@playwright/test"; test("M7-13 keeps menu, modal Escape and focus return consistent", async ({ page }) => { await page.goto("/"); await expect(page.getByTestId("engine-status")).toContainText("ready, open a .blend file", { timeout: 20_000 }); const searchTrigger = page.getByRole("button", { name: "操作搜索" }); const fileMenu = page.getByRole("button", { name: "文件", exact: true }); await page.keyboard.press("Tab"); await expect(fileMenu).toBeFocused(); await searchTrigger.focus(); await page.keyboard.press("F3"); const dialog = page.getByRole("dialog", { name: "Operator Search" }); await expect(dialog).toBeVisible(); await expect(page.getByRole("textbox", { name: "搜索操作" })).toBeFocused(); await page.keyboard.press("Tab"); await page.keyboard.press("Shift+Tab"); await expect(page.getByRole("textbox", { name: "搜索操作" })).toBeFocused(); await page.keyboard.press("Escape"); await expect(dialog).toHaveCount(0); await expect(searchTrigger).toBeFocused(); await fileMenu.click(); const menu = page.getByRole("menu", { name: "文件" }); await expect(menu).toBeVisible(); await expect(page.getByRole("menuitem", { name: "打开" })).toBeFocused(); await page.keyboard.press("ArrowDown"); await expect(page.getByRole("menuitem", { name: "保存" })).toBeFocused(); await page.keyboard.press("End"); await expect(page.getByRole("menuitem", { name: "关闭" })).toBeFocused(); await page.keyboard.press("Home"); await expect(page.getByRole("menuitem", { name: "打开" })).toBeFocused(); await page.keyboard.press("Escape"); await expect(menu).toHaveCount(0); await expect(fileMenu).toBeFocused(); await fileMenu.click(); await page.keyboard.press("Tab"); await expect(menu).toHaveCount(0); await expect(fileMenu).toBeFocused(); await fileMenu.click(); await page.getByRole("button", { name: "操作搜索" }).click(); await expect(page.getByRole("menu", { name: "文件" })).toHaveCount(0); await expect(dialog).toBeVisible(); await page.keyboard.press("Escape"); await expect(searchTrigger).toBeFocused(); });