mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-09 22:25:02 +03:00
47 lines
2.1 KiB
TypeScript
47 lines
2.1 KiB
TypeScript
import { expect, test } from "@playwright/test"
|
|
import { setupTimeline } from "../utils/timeline"
|
|
|
|
for (const reducedMotion of [false, true]) {
|
|
test(`suppresses the scrollbar from toggle press until timeline interaction (reduced motion: ${reducedMotion})`, async ({
|
|
page,
|
|
}) => {
|
|
await setupTimeline(page, { seedHistory: true, reducedMotion })
|
|
const chat = page.locator('[data-slot="session-chat-panel"]')
|
|
const scroll = page.locator('[data-slot="session-timeline-scroll"]')
|
|
const viewport = scroll.locator(".scroll-view__viewport")
|
|
const thumb = page.locator('[data-slot="session-timeline-visible"] .scroll-view__thumb')
|
|
const toggle = page.getByRole("button", { name: "Toggle review", exact: true })
|
|
await expect(thumb).toHaveCount(1)
|
|
await scroll.hover()
|
|
await expect(thumb).toHaveAttribute("data-visible", "true")
|
|
await expect(thumb).toHaveCSS("visibility", "visible")
|
|
|
|
for (const opened of [true, false]) {
|
|
await toggle.hover()
|
|
await page.mouse.down()
|
|
await expect(thumb).toHaveCSS("visibility", "hidden")
|
|
await page.mouse.up()
|
|
await expect(toggle).toHaveAttribute("aria-expanded", String(opened))
|
|
const presence = page.locator('[data-slot="session-side-panel-presence"]')
|
|
|
|
if (opened) await expect(presence).toHaveCSS("transform", "none")
|
|
|
|
// A settled close keeps the side region mounted and skips its contents.
|
|
if (!opened) await expect(presence).toHaveCSS("content-visibility", "hidden")
|
|
await expect(thumb).toHaveCSS("visibility", "hidden")
|
|
// Late scroll anchoring must not bring the thumb back after the panel has settled.
|
|
await viewport.evaluate(
|
|
(element) =>
|
|
new Promise<void>((resolve) => {
|
|
element.addEventListener("scroll", () => resolve(), { once: true })
|
|
element.scrollTop += element.scrollTop > 0 ? -1 : 1
|
|
}),
|
|
)
|
|
await expect(thumb).toHaveCSS("visibility", "hidden")
|
|
await scroll.hover()
|
|
await expect(thumb).toHaveAttribute("data-visible", "true")
|
|
await expect(thumb).toHaveCSS("visibility", "visible")
|
|
}
|
|
})
|
|
}
|