MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestMagicRejectPOSTWithReason

Function TestMagicRejectPOSTWithReason

internal/agent/hitl_magic_api_test.go:305–331  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

303}
304
305func TestMagicRejectPOSTWithReason(t *testing.T) {
306 server, store, signer, smtpDone := setupMagicLinkAPI(t)
307 a, userID := prepareHITLAgent(t, store, "post-reject")
308 msg := issuePending(t, store, a.ID)
309
310 tok, _ := signer.Sign(msg.ID, approvaltoken.ActionReject, time.Now().Add(1*time.Hour))
311 resp := postForm(t, server.URL+"/v1/reject", map[string]string{
312 "t": tok,
313 "reason": "not the right tone",
314 })
315 defer resp.Body.Close()
316 if resp.StatusCode != http.StatusOK {
317 t.Fatalf("POST reject: status = %d", resp.StatusCode)
318 }
319
320 if msgs := smtpDone(); len(msgs) != 0 {
321 t.Errorf("reject should not call SMTP, got %d", len(msgs))
322 }
323
324 got, _ := store.GetOutboundMessageForUser(context.Background(), msg.ID, userID)
325 if got.Status != identity.MessageStatusReviewRejected {
326 t.Errorf("status = %q, want rejected", got.Status)
327 }
328 if got.RejectionReason != "not the right tone" {
329 t.Errorf("rejection_reason = %q, want 'not the right tone'", got.RejectionReason)
330 }
331}
332
333func TestMagicRejectPOSTWithoutReasonUsesDefault(t *testing.T) {
334 server, store, signer, _ := setupMagicLinkAPI(t)

Callers

nothing calls this directly

Calls 7

setupMagicLinkAPIFunction · 0.85
prepareHITLAgentFunction · 0.85
issuePendingFunction · 0.85
postFormFunction · 0.85
SignMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected