package codex import ( "context" "encoding/json" "sync/atomic" "testing" ) // ProbeTurn reports the latest turn's in-progress state from the App Server. func TestProbeTurnReadsLatestTurn(t *testing.T) { var completed atomic.Bool c := modelTestChat(t, func(method string, _ json.RawMessage) any { if method != "thread/turns/list" { t.Errorf("unexpected method: %s", method) } status := "inProgress" if completed.Load() { status = "completed" } return json.RawMessage(`{"data":[{"id":"turn","status":"` + status + `","items":[]}],"nextCursor":null}`) }) if running, err := c.ProbeTurn(context.Background(), fixtureThread); err != nil || !running { t.Fatalf("in-progress turn: %v %v", running, err) } completed.Store(true) if running, err := c.ProbeTurn(context.Background(), fixtureThread); err != nil || running { t.Fatalf("completed turn: %v %v", running, err) } }