opencode/packages/app/e2e/regression/shell-panel-spacing.spec.ts
Brendan Allan 80c4a6b7c8
Some checks are pending
check / typecheck (push) Waiting to run
deploy-files / deploy (push) Waiting to run
deploy-posts / deploy (push) Waiting to run
deploy-www / deploy (push) Waiting to run
nix-eval / nix-eval (push) Waiting to run
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404, x86_64-linux) (push) Waiting to run
nix-hashes / compute-hash (blacksmith-4vcpu-ubuntu-2404-arm, aarch64-linux) (push) Waiting to run
nix-hashes / compute-hash (macos-latest, aarch64-darwin) (push) Waiting to run
nix-hashes / update-hashes (push) Blocked by required conditions
publish / version (push) Waiting to run
publish / build-cli (push) Blocked by required conditions
publish / sign-cli-macos (push) Blocked by required conditions
publish / build-node-app-archive (push) Blocked by required conditions
publish / build-node-cli (map[bun_install_flags:--cpu=* host:blacksmith-4vcpu-windows-2025 target:windows-arm64]) (push) Blocked by required conditions
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404 target:linux-x64]) (push) Blocked by required conditions
publish / build-node-cli (map[host:blacksmith-4vcpu-ubuntu-2404-arm target:linux-arm64]) (push) Blocked by required conditions
publish / build-node-cli (map[host:blacksmith-4vcpu-windows-2025 target:windows-x64]) (push) Blocked by required conditions
publish / build-node-cli (map[host:macos-26 target:darwin-arm64]) (push) Blocked by required conditions
publish / sign-cli-windows (push) Blocked by required conditions
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=arm64 host:macos-26 platform_flag:--mac --arm64 target:aarch64-apple-darwin]) (push) Blocked by required conditions
publish / build-electron (map[bun_install_flags:--os=darwin --cpu=x64 host:macos-26-intel platform_flag:--mac --x64 target:x86_64-apple-darwin]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404 platform_flag:--linux target:x86_64-unknown-linux-gnu]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-ubuntu-2404-arm platform_flag:--linux --arm64 target:aarch64-unknown-linux-gnu]) (push) Blocked by required conditions
publish / build-electron (map[host:blacksmith-4vcpu-windows-2025 platform_flag:--win target:x86_64-pc-windows-msvc]) (push) Blocked by required conditions
publish / build-electron (map[host:windows-2025 platform_flag:--win --arm64 target:aarch64-pc-windows-msvc]) (push) Blocked by required conditions
publish / publish (push) Blocked by required conditions
publish / notify-discord-v2 (push) Blocked by required conditions
test / affected packages (push) Waiting to run
test / unit (linux) (push) Waiting to run
test / unit (windows) (push) Waiting to run
test / e2e (linux) (push) Blocked by required conditions
test / e2e (windows) (push) Blocked by required conditions
feat(app): polish mobile session navigation and drawers (#53267)
2026-10-06 17:12:44 +08:00

95 lines
3.7 KiB
TypeScript

import { expect, test, type Page } from "@playwright/test"
import { fixture, installStressSessionTabs, mockStressTimeline } from "../utils/session-fixture"
import { sessionHref, draftHref } from "../utils/app"
import { openWithDirection } from "../utils/direction"
for (const direction of ["ltr", "rtl"] as const) {
test(`bottom mobile navigation adds no extra top panel gutter in ${direction}`, async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 })
await mockStressTimeline(page)
await page.addInitScript(() => {
localStorage.setItem("settings.v3", JSON.stringify({ general: { mobileTitlebarPosition: "bottom" } }))
})
await openWithDirection(page, "/", direction)
const panel = page.locator('[data-slot="home-panel"]')
await expect(panel).toHaveCSS("--shell-top-inset", "0px")
await expect
.poll(async () => {
const titlebar = await page.locator('[data-slot="titlebar-v2"]').boundingBox()
const main = await page.getByRole("main").boundingBox()
return titlebar && main && titlebar.y >= main.y + main.height
})
.toBe(true)
await expect
.poll(async () => {
const bounds = await panel.boundingBox()
const main = await page.getByRole("main").boundingBox()
return bounds && main && bounds.y - main.y
})
.toBe(0)
})
for (const screen of [
{ name: "home", href: () => "/", panel: (page: Page) => page.locator('[data-slot="home-panel"]') },
{
name: "new-session",
href: () => draftHref("shell-spacing-draft"),
panel: (page: Page) => page.locator('[data-component="new-session"]'),
},
{
name: "session",
href: () => sessionHref(fixture.targetID),
panel: (page: Page) => page.locator('[data-slot="session-chat-panel"]'),
},
{ name: "settings", href: () => "/settings", panel: (page: Page) => page.getByTestId("settings-screen") },
]) {
test(`${screen.name} keeps an 8px top gutter and only inline border clearance on mobile in ${direction}`, async ({
page,
}) => {
await page.setViewportSize({ width: 390, height: 844 })
await mockStressTimeline(page)
if (screen.name === "new-session") await installStressSessionTabs(page, { draftID: "shell-spacing-draft" })
await openWithDirection(page, screen.href(), direction)
await expect(page.locator("html")).toHaveAttribute("dir", direction)
const panel = screen.panel(page)
await expect(panel).toBeVisible()
await expect(panel).toHaveCSS("--shell-top-inset", "8px")
await expect
.poll(async () => {
const bounds = await panel.boundingBox()
const main = await page.getByRole("main").boundingBox()
return bounds && main && bounds.y - main.y
})
.toBe(8)
await expect
.poll(async () => {
const bounds = await panel.boundingBox()
const main = await page.getByRole("main").boundingBox()
return bounds && main && { x: bounds.x - main.x, width: main.width - bounds.width }
})
.toEqual({ x: 1, width: 2 })
// The existing desktop gutter must return at the responsive breakpoint.
await page.setViewportSize({ width: 768, height: 900 })
await expect(panel).toHaveCSS("--shell-inline-inset", "8px")
await expect(panel).toHaveCSS("--shell-top-inset", "8px")
if (screen.name === "session") return
await expect
.poll(async () => {
const bounds = await panel.boundingBox()
const main = await page.getByRole("main").boundingBox()
return bounds && main && { x: bounds.x - main.x, width: main.width - bounds.width }
})
.toEqual({ x: 8, width: 16 })
})
}
}