/** @jsxImportSource @opentui/solid */ import { testRender } from "@opentui/solid" import { expect, test } from "bun:test" import { mkdir } from "node:fs/promises" import path from "node:path" import { TuiPathsProvider } from "../../src/context/runtime" import { PromptHistoryProvider, usePromptHistory } from "../../src/prompt/history" import { tmpdir } from "../fixture/fixture" test("down rejects at the newest history item with an empty prompt", async () => { await using tmp = await tmpdir() const state = path.join(tmp.path, "state") await mkdir(state, { recursive: true }) let history: ReturnType function Consumer() { history = usePromptHistory() return } const app = await testRender(() => ( )) try { await app.renderOnce() history!.append({ text: "previous", files: [], agents: [], pasted: [] }) expect(history!.move(1, "")).toBeUndefined() expect(history!.move(-1, "")?.text).toBe("previous") expect(history!.move(1, "previous")?.text).toBe("") } finally { app.renderer.destroy() } })