|
| 1 | +import { test, expect } from "./fixture.mjs"; |
| 2 | + |
| 3 | +const parent = "11111111-1111-4111-8111-111111111111"; |
| 4 | +test.use({ |
| 5 | + sessionChannels: ["alpha"], |
| 6 | + sessionParents: { alpha: parent }, |
| 7 | + historyCounts: { alpha: 5, beta: 5 }, |
| 8 | +}); |
| 9 | + |
| 10 | +// Native details toggle events and hidden descendants need real browser coverage. |
| 11 | +test("global search opens a child session without changing collapsed sidebar levels", async ({ |
| 12 | + page, |
| 13 | + app, |
| 14 | +}) => { |
| 15 | + await page.goto(app.origin); |
| 16 | + await page |
| 17 | + .getByRole("button", { name: "Messages", exact: true }) |
| 18 | + .first() |
| 19 | + .click(); |
| 20 | + const sidebar = page.getByRole("navigation", { name: "Subscribed channels" }); |
| 21 | + const parentRow = page.locator(`button[data-channel-id="${parent}"]`); |
| 22 | + const child = sidebar.locator('button[data-channel-id="alpha"]'); |
| 23 | + const section = sidebar.locator("details").filter({ has: parentRow }); |
| 24 | + await expect(child).toBeVisible(); |
| 25 | + await sidebar |
| 26 | + .getByRole("button", { name: `Collapse sessions in ${parent}` }) |
| 27 | + .click(); |
| 28 | + await expect(child).toBeHidden(); |
| 29 | + await section.locator("summary").click(); |
| 30 | + await expect(section).not.toHaveAttribute("open"); |
| 31 | + |
| 32 | + await page.getByRole("button", { name: "Search Buzz", exact: true }).click(); |
| 33 | + const dialog = page.getByRole("dialog", { name: "Search Buzz" }); |
| 34 | + const search = dialog.getByRole("combobox", { name: "Search Buzz" }); |
| 35 | + await search.fill("Alpha"); |
| 36 | + const result = dialog |
| 37 | + .locator("[data-search-result]") |
| 38 | + .filter({ hasText: "Alpha" }) |
| 39 | + .first(); |
| 40 | + await expect(result).toBeVisible(); |
| 41 | + await search.press("ArrowDown"); |
| 42 | + await expect(search).toBeFocused(); |
| 43 | + await expect(result).toHaveAttribute("aria-selected", "true"); |
| 44 | + await expect(search).toHaveAttribute( |
| 45 | + "aria-activedescendant", |
| 46 | + await result.getAttribute("id"), |
| 47 | + ); |
| 48 | + await page.keyboard.press("Enter"); |
| 49 | + await expect(dialog).toHaveCount(0); |
| 50 | + await expect(child).toBeHidden(); |
| 51 | + await expect( |
| 52 | + page.getByRole("textbox", { name: "Message this session", exact: true }), |
| 53 | + ).toBeVisible(); |
| 54 | + |
| 55 | + // Remount so accidental onToggle persistence cannot be hidden by local state. |
| 56 | + await page.getByRole("button", { name: "Home", exact: true }).first().click(); |
| 57 | + await page |
| 58 | + .getByRole("button", { name: "Messages", exact: true }) |
| 59 | + .first() |
| 60 | + .click(); |
| 61 | + await expect(section).not.toHaveAttribute("open"); |
| 62 | + await section.locator("summary").focus(); |
| 63 | + await page.keyboard.press("Enter"); |
| 64 | + await expect( |
| 65 | + sidebar.getByRole("button", { name: `Expand sessions in ${parent}` }), |
| 66 | + ).toBeVisible(); |
| 67 | + await expect(child).toBeHidden(); |
| 68 | + await page.keyboard.press("Space"); |
| 69 | + await expect(section).not.toHaveAttribute("open"); |
| 70 | +}); |
0 commit comments