Test a merge card answer end to end in Equipo's real shapes
Paul's Merge on a live merge card seemed to do nothing. This pins down Base's half with Equipo's real shapes (options merge and wait; the 200 answer has the answered card and an empty message and turn): Base relays the answer with its revision and key, answers the panel with the card as answered, and its stream passes the answered card on. It passes, as the panel's own TestAskCardsPolish does, so the live failure is not yet reproduced.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+48
−0
internal/webtest/ask_test.go+48 −0
diff --git a/internal/webtest/ask_test.go b/internal/webtest/ask_test.go| index 711b2fd..ce380c6 100644 |
| --- a/internal/webtest/ask_test.go |
| +++ b/internal/webtest/ask_test.go |
| @@ -686,3 +686,51 @@ func TestAskMergeAndPublishCards(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// A merge card answered from the panel, in Equipo's real shapes (options |
| +// merge and wait; the 200 answer carries the answered card and an empty |
| +// message and turn): Base relays the click, answers with the card as |
| +// answered, and its stream passes the answered card on. |
| +func TestAskMergeAnswerRoundTrip(t *testing.T) { |
| + a, f := newAskApp(t) |
| + a.connectEquipo(f) |
| + var st struct{ Cursor int64 } |
| + merge := f.AskMerge("Swipe from the edge to go back doesn't work") |
| + if r := a.get("/ask/state"); json.Unmarshal([]byte(r.Body), &st) != nil { |
| + t.Fatalf("state: %s", r.Body) |
| + } |
| + req, _ := http.NewRequest(http.MethodPost, a.base+"/ask/cards/"+merge+"/answer", |
| + strings.NewReader(url.Values{"choice": {"merge"}, "revision": {"1"}, "key": {"k-merge"}}.Encode())) |
| + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + req.Header.Set("Origin", a.origin) |
| + req.Header.Set("Accept", "application/json") |
| + res := a.do(req) |
| + var out struct { |
| + Card struct{ ID, Kind, State, Choice string } |
| + Message struct{ ID string } |
| + Turn struct{ ID string } |
| + } |
| + if res.Code != 200 || json.Unmarshal([]byte(res.Body), &out) != nil || out.Card.ID != merge || out.Card.State != "answered" || |
| + out.Card.Choice != "merge" || out.Message.ID != "" || out.Turn.ID != "" { |
| + t.Fatalf("answer: %d %s", res.Code, res.Body) |
| + } |
| + if c := f.Calls("/api/v1/cards/" + merge + "/answer"); len(c) != 1 || strings.TrimSpace(c[0].Body) != `{"choice":"merge","revision":1}` || |
| + c[0].Header.Get("Idempotency-Key") != "k-merge" { |
| + t.Fatalf("relayed: %+v", c) |
| + } |
| + ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) |
| + defer cancel() |
| + sreq, _ := http.NewRequestWithContext(ctx, http.MethodGet, a.base+"/ask/events?after="+strconv64(st.Cursor), nil) |
| + sres, err := a.client.Do(sreq) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer sres.Body.Close() |
| + sc := bufio.NewScanner(sres.Body) |
| + for sc.Scan() { |
| + if line := sc.Text(); strings.HasPrefix(line, "data: ") && strings.Contains(line, `"state":"answered"`) && strings.Contains(line, `"choice":"merge"`) { |
| + return |
| + } |
| + } |
| + t.Fatal("the stream never passed the answered merge card on") |
| +} |