|
1 | 1 | import { InfoIcon } from "lucide-react"; |
2 | 2 | import type { ReactNode } from "react"; |
3 | 3 | import { expect, it, vi } from "vite-plus/test"; |
| 4 | +import { page, userEvent } from "vite-plus/test/browser"; |
4 | 5 |
|
5 | 6 | import "~/index.css"; |
6 | 7 |
|
@@ -123,3 +124,28 @@ it("shows the details button while text or nested text is cut, until it fits aga |
123 | 124 | await screen.rerender(<ComposerBanner.Root>{noticeRow("4rem", "Ready")}</ComposerBanner.Root>); |
124 | 125 | await expect.element(details).not.toBeInTheDocument(); |
125 | 126 | }); |
| 127 | + |
| 128 | +it("opens the details of a long notice right above its button", async () => { |
| 129 | + const viewport = { width: window.innerWidth, height: window.innerHeight }; |
| 130 | + await page.viewport(1280, 800); |
| 131 | + await using _viewport = { |
| 132 | + [Symbol.asyncDispose]: () => page.viewport(viewport.width, viewport.height), |
| 133 | + }; |
| 134 | + const script = Array.from({ length: 400 }, (_, line) => `echo "line ${line}"`).join("\n"); |
| 135 | + const container = document.createElement("div"); |
| 136 | + container.style.cssText = "position: fixed; bottom: 4rem; right: 4rem;"; |
| 137 | + await using screen = await render(noticeRow("40rem", script), { container }); |
| 138 | + const details = screen.getByRole("button", { name: "Show details" }); |
| 139 | + await userEvent.hover(details); |
| 140 | + const popup = page.getByLabelText("Notice details"); |
| 141 | + await expect.element(popup).toBeVisible(); |
| 142 | + |
| 143 | + // A positioner sized to the unscrolled text flips beside the button and covers it. |
| 144 | + await vi.waitFor(() => { |
| 145 | + const gap = |
| 146 | + details.element().getBoundingClientRect().top - |
| 147 | + popup.element().getBoundingClientRect().bottom; |
| 148 | + expect(gap).toBeGreaterThanOrEqual(0); |
| 149 | + expect(gap).toBeLessThan(8); |
| 150 | + }); |
| 151 | +}); |
0 commit comments