@@ -1862,6 +1862,88 @@ test("the Windows titlebar menu pastes through the desktop edit action", async ( |
1862 | 1862 | await expect(page.getByRole("status", { name: "Desktop menu actions" })).toHaveText("edit.paste") |
1863 | 1863 | }) |
1864 | 1864 |
|
| 1865 | +// #63095: hovering down the parent items left every submenu open, stacked on top of each other. Closing each one as |
| 1866 | +// soon as the pointer left it then showed no submenu until the next opened, so the menu blinked on every item. |
| 1867 | +test("the Windows titlebar menu swaps one submenu for the next as the pointer moves down its parent items", async ({ |
| 1868 | + page, |
| 1869 | +}) => { |
| 1870 | + await page.clock.install() |
| 1871 | + await mockWorkspace(page, { name: "WindowsMenu", sessions: [] }) |
| 1872 | + await page.goto(`/e2e/utils/windows-menu.html?${new URLSearchParams({ server: SERVER })}`) |
| 1873 | + await page.getByRole("button", { name: "OpenCode menu", exact: true }).click() |
| 1874 | + const parents = ["File", "Edit", "View"].map((name) => page.getByRole("menuitem", { name, exact: true })) |
| 1875 | + const submenus = page.locator('[role="menu"].desktop-app-menu-sub') |
| 1876 | + |
| 1877 | + for (const [index, parent] of parents.entries()) { |
| 1878 | + const box = (await parent.boundingBox())! |
| 1879 | + // Down and to the left, away from the open submenu, so the pointer isn't heading for it. |
| 1880 | + await page.mouse.move(box.x + box.width / 2 - index * 20, box.y + box.height / 2, { steps: 4 }) |
| 1881 | + await expect(parent).toHaveAttribute("data-highlighted", "") |
| 1882 | + |
| 1883 | + if (index > 0) await expect(parents[index - 1]).toHaveAttribute("aria-expanded", "true") |
| 1884 | + await expect(parent).toHaveAttribute("aria-expanded", "false") |
| 1885 | + // Kobalte's hover delay. |
| 1886 | + await page.clock.runFor(100) |
| 1887 | + await expect(parent).toHaveAttribute("aria-expanded", "true") |
| 1888 | + await expect(submenus).toHaveCount(1) |
| 1889 | + } |
| 1890 | +}) |
| 1891 | + |
| 1892 | +// #59613: crossing the other parent items on the way to a submenu's lower items closed it and opened theirs. |
| 1893 | +test("the Windows titlebar menu keeps a submenu open while the pointer crosses other parent items to reach it", async ({ |
| 1894 | + page, |
| 1895 | +}) => { |
| 1896 | + await page.clock.install() |
| 1897 | + await mockWorkspace(page, { name: "WindowsMenu", sessions: [] }) |
| 1898 | + await page.goto(`/e2e/utils/windows-menu.html?${new URLSearchParams({ server: SERVER })}`) |
| 1899 | + await page.getByRole("button", { name: "OpenCode menu", exact: true }).click() |
| 1900 | + const file = page.getByRole("menuitem", { name: "File", exact: true }) |
| 1901 | + const fileBox = (await file.boundingBox())! |
| 1902 | + const from = { x: fileBox.x + fileBox.width / 2, y: fileBox.y + fileBox.height / 2 } |
| 1903 | + await page.mouse.move(from.x, from.y, { steps: 4 }) |
| 1904 | + await page.clock.runFor(100) |
| 1905 | + const closeWindow = page.getByRole("menuitem", { name: /^Close Window/ }) |
| 1906 | + const target = (await closeWindow.boundingBox())! |
| 1907 | + const to = { x: target.x + 20, y: target.y + target.height / 2 } |
| 1908 | + const steps = Math.ceil(Math.hypot(to.x - from.x, to.y - from.y) / 4) |
| 1909 | + |
| 1910 | + // A slow, straight move at 125px a second: it stays longer than the hover delay on each item it crosses, and the |
| 1911 | + // whole trip takes longer than the 300ms that Kobalte keeps the way to a submenu open. |
| 1912 | + for (let step = 1; step <= steps; step++) { |
| 1913 | + await page.mouse.move(from.x + ((to.x - from.x) * step) / steps, from.y + ((to.y - from.y) * step) / steps) |
| 1914 | + await page.clock.runFor(32) |
| 1915 | + } |
| 1916 | + |
| 1917 | + await expect(closeWindow).toHaveAttribute("data-highlighted", "") |
| 1918 | + await expect(file).toHaveAttribute("aria-expanded", "true") |
| 1919 | + await expect(page.locator('[role="menu"].desktop-app-menu-sub')).toHaveCount(1) |
| 1920 | +}) |
| 1921 | + |
| 1922 | +// Moving down the parent items while drifting right kept the way to the open submenu alive, so the highlight stayed on |
| 1923 | +// the item that opened it while the pointer crossed the next ones. |
| 1924 | +test("the Windows titlebar menu highlights each parent item the pointer drifts down across", async ({ page }) => { |
| 1925 | + await page.clock.install() |
| 1926 | + await mockWorkspace(page, { name: "WindowsMenu", sessions: [] }) |
| 1927 | + await page.goto(`/e2e/utils/windows-menu.html?${new URLSearchParams({ server: SERVER })}`) |
| 1928 | + await page.getByRole("button", { name: "OpenCode menu", exact: true }).click() |
| 1929 | + const view = page.getByRole("menuitem", { name: "View", exact: true }) |
| 1930 | + const box = (await view.boundingBox())! |
| 1931 | + const from = { x: box.x + box.width / 2, y: box.y + box.height / 2 } |
| 1932 | + await page.mouse.move(from.x, from.y, { steps: 4 }) |
| 1933 | + await page.clock.runFor(100) |
| 1934 | + await expect(view).toHaveAttribute("aria-expanded", "true") |
| 1935 | + const go = page.getByRole("menuitem", { name: "Go", exact: true }) |
| 1936 | + const target = (await go.boundingBox())! |
| 1937 | + |
| 1938 | + // 1px right for every 4px down, a frame at a time, until the pointer is a few pixels inside Go. |
| 1939 | + for (let step = 1; from.y + step * 4 < target.y + 8; step++) { |
| 1940 | + await page.mouse.move(from.x + step, from.y + step * 4) |
| 1941 | + await page.clock.runFor(16) |
| 1942 | + } |
| 1943 | + |
| 1944 | + await expect(go).toHaveAttribute("data-highlighted", "") |
| 1945 | +}) |
| 1946 | + |
1865 | 1947 | test("the Windows menu shares the vertical sidebar's icon lane", async ({ page }) => { |
1866 | 1948 | await mockWorkspace(page, { |
1867 | 1949 | name: "WindowsMenu", |
|