Add /refocus and /ontask routes and carry allowed classes
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -158,3 +158,34 @@ func TestCoachRouteUnavailableDegrades(t *testing.T) {
|
||||
t.Fatalf("want error status, got %+v", cv)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRefocusAndOnTaskOutsideActiveIs400(t *testing.T) {
|
||||
s := newTestServer(t)
|
||||
r := s.Router()
|
||||
if w := post(t, r, "/refocus", ""); w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("refocus outside Active: want 400, got %d", w.Code)
|
||||
}
|
||||
if w := post(t, r, "/ontask", ""); w.Code != http.StatusBadRequest {
|
||||
t.Fatalf("ontask outside Active: want 400, got %d", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommitmentCarriesAllowedClassesAndRoutesWork(t *testing.T) {
|
||||
s := newTestServer(t)
|
||||
r := s.Router()
|
||||
_ = post(t, r, "/planning", "")
|
||||
body := `{"next_action":"a","success_condition":"b","timebox_secs":1500,"allowed_window_classes":["code"]}`
|
||||
if w := post(t, r, "/commitment", body); w.Code != http.StatusOK {
|
||||
t.Fatalf("commitment: want 200, got %d (%s)", w.Code, w.Body.String())
|
||||
}
|
||||
if got := s.ctrl.AllowedClassesForTest(); len(got) != 1 || got[0] != "code" {
|
||||
t.Fatalf("commitment did not carry allowed classes: %#v", got)
|
||||
}
|
||||
// Now Active: overrides succeed.
|
||||
if w := post(t, r, "/ontask", ""); w.Code != http.StatusOK {
|
||||
t.Fatalf("ontask while Active: want 200, got %d", w.Code)
|
||||
}
|
||||
if w := post(t, r, "/refocus", ""); w.Code != http.StatusOK {
|
||||
t.Fatalf("refocus while Active: want 200, got %d", w.Code)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user