mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
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
79 lines
2.8 KiB
TypeScript
79 lines
2.8 KiB
TypeScript
import { expect, test, type Page } from "@playwright/test"
|
|
import { fixture, installStressSessionTabs } from "../utils/session-fixture"
|
|
import { sessionHref } from "../utils/app"
|
|
import { openWithDirection } from "../utils/direction"
|
|
import { mockOpenCodeServer } from "../utils/mock-server"
|
|
|
|
for (const { width, direction } of [
|
|
{ width: 390, direction: "ltr" },
|
|
{ width: 390, direction: "rtl" },
|
|
{ width: 1280, direction: "ltr" },
|
|
] as const) {
|
|
test(`submitting a prompt ${width < 768 ? "unfocuses" : "keeps focus on"} the composer at ${width}px in ${direction}`, async ({
|
|
page,
|
|
}) => {
|
|
await openSubmitSession(page, width, direction)
|
|
|
|
const editor = page.getByRole("textbox", { name: "Prompt", exact: true })
|
|
await expect(editor).toBeEditable()
|
|
await editor.fill("Please check focus after sending.")
|
|
await expect(editor).toBeFocused()
|
|
|
|
const admitted = page.waitForResponse(
|
|
(response) =>
|
|
response.request().method() === "POST" &&
|
|
new URL(response.url()).pathname === `/api/session/${fixture.targetID}/prompt`,
|
|
)
|
|
|
|
await editor.press("Enter")
|
|
expect((await admitted).ok()).toBe(true)
|
|
await expect(editor).toBeEmpty()
|
|
|
|
if (width < 768) {
|
|
await expect(editor).not.toBeFocused()
|
|
|
|
return
|
|
}
|
|
|
|
await expect(editor).toBeFocused()
|
|
})
|
|
}
|
|
|
|
test.describe("touch submission", () => {
|
|
test.use({ viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true })
|
|
|
|
test("tapping Send unfocuses the composer", async ({ page }) => {
|
|
await openSubmitSession(page, 390, "ltr")
|
|
const editor = page.getByRole("textbox", { name: "Prompt", exact: true })
|
|
await expect(editor).toBeEditable()
|
|
await editor.fill("Please dismiss the keyboard after sending.")
|
|
await expect(editor).toBeFocused()
|
|
|
|
const admitted = page.waitForResponse(
|
|
(response) =>
|
|
response.request().method() === "POST" &&
|
|
new URL(response.url()).pathname === `/api/session/${fixture.targetID}/prompt`,
|
|
)
|
|
|
|
await page.getByRole("button", { name: "Send", exact: true }).tap()
|
|
expect((await admitted).ok()).toBe(true)
|
|
await expect(editor).toBeEmpty()
|
|
await expect(editor).not.toBeFocused()
|
|
})
|
|
})
|
|
|
|
async function openSubmitSession(page: Page, width: number, direction: "ltr" | "rtl") {
|
|
await page.setViewportSize({ width, height: 844 })
|
|
await mockOpenCodeServer(page, {
|
|
directory: fixture.directory,
|
|
project: fixture.project,
|
|
sessions: fixture.sessions,
|
|
provider: fixture.provider,
|
|
pageMessages: () => ({ items: [] }),
|
|
})
|
|
await installStressSessionTabs(page)
|
|
await page.addInitScript(() => {
|
|
localStorage.setItem("settings.v3", JSON.stringify({ general: { mobileTitlebarPosition: "bottom" } }))
|
|
})
|
|
await openWithDirection(page, sessionHref(fixture.targetID), direction)
|
|
}
|