MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestQueueStoresPromptMidTurn

Function TestQueueStoresPromptMidTurn

internal/tui/queue_test.go:20–44  ·  view source on GitHub ↗

TestQueueStoresPromptMidTurn: Enter while a turn is running stashes the typed prompt in the queue slot and clears the textarea, instead of the old silent drop. The turn keeps running (phase unchanged) and nothing is submitted yet.

(t *testing.T)

Source from the content-addressed store, hash-verified

18// prompt in the queue slot and clears the textarea, instead of the old silent
19// drop. The turn keeps running (phase unchanged) and nothing is submitted yet.
20func TestQueueStoresPromptMidTurn(t *testing.T) {
21 m := newTestModel(t, func(http.ResponseWriter, *http.Request) {})
22 m.phase = phaseThinking
23 m.ta.SetValue("run the tests next")
24 before := len(m.history)
25
26 out, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
27 om := out.(Model)
28
29 if om.queued == nil || om.queued.send != "run the tests next" {
30 t.Fatalf("mid-turn Enter must queue the prompt, got %+v", om.queued)
31 }
32 if om.ta.Value() != "" {
33 t.Fatalf("textarea must be cleared after queuing, got %q", om.ta.Value())
34 }
35 if om.phase != phaseThinking {
36 t.Fatalf("queuing must not change the running phase, got %v", om.phase)
37 }
38 if len(om.history) != before {
39 t.Fatalf("queuing must not submit (history grew by %d)", len(om.history)-before)
40 }
41 if cmd != nil {
42 t.Fatal("queuing must not start a turn (nil Cmd)")
43 }
44}
45
46// TestQueueEmptyMidTurnIsNoOp: Enter on a blank prompt mid turn stays silent, so
47// a reflexive Enter while watching the agent doesn't queue an empty slot.

Callers

nothing calls this directly

Calls 4

newTestModelFunction · 0.85
SetValueMethod · 0.80
ValueMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected