Files
opencode/packages/tui/test/prompt-cursor.test.tsx
2026-10-30 10:08:54 -04:00

28 lines
1.2 KiB
TypeScript

import { TextareaRenderable } from "@opentui/core"
import { expect, test } from "bun:test"
import { takeDraft } from "../src/component/prompt/draft-stash"
import { createAppFixture } from "./fixture/app"
test("the prompt keeps a cursor style set on its textarea when the theme changes", async () => {
// Other app tests can leave a home draft in the process-wide stash.
takeDraft(undefined)
await using setup = await createAppFixture({
config: { animations: false, keybinds: { "theme.switch_mode": "f6" } },
})
await setup.ready
await setup.waitForFrame((frame) => frame.includes("commands"))
const prompt = setup.renderer.currentFocusedEditor
if (!(prompt instanceof TextareaRenderable)) throw new Error("expected the focused prompt textarea")
const color = prompt.cursorColor
// A plugin such as a modal editing mode restyles the prompt cursor directly.
prompt.cursorStyle = { style: "line", blinking: false }
setup.mockInput.pressKey("F6")
await setup.renderOnce()
await Bun.sleep(10)
await setup.renderOnce()
expect(prompt.cursorColor).not.toEqual(color)
expect(prompt.cursorStyle).toMatchObject({ style: "line", blinking: false })
})