refactor(tui): extract shared frontend helpers (#37868)

This commit is contained in:
Simon Klee 2026-07-20 10:43:02 +02:00 committed by GitHub
commit 0eb71d0fc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 1655 additions and 1614 deletions

View file

@ -272,3 +272,27 @@ test("selects a repopulated option after removing the only option", async () =>
select.app.renderer.destroy()
}
})
test("keeps the cursor index while options are temporarily empty", async () => {
await using tmp = await tmpdir()
const options = ["first", "second", "third"].map((value) => ({ title: value, value }))
const select = await mountSelect(tmp.path, options)
try {
select.app.mockInput.pressArrow("down")
await select.app.waitFor(() => select.moved.at(-1) === "second")
select.app.mockInput.pressArrow("down")
await select.app.waitFor(() => select.moved.at(-1) === "third")
select.replaceOptions([])
await select.app.waitForFrame((frame) => frame.includes("No items available"))
select.replaceOptions(options)
await select.app.waitForFrame((frame) => frame.includes("third"))
select.app.mockInput.pressEnter()
await select.app.waitFor(() => select.selected.length === 1)
expect(select.selected).toEqual(["third"])
} finally {
select.app.renderer.destroy()
}
})