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

Function TestMessageViewParsedHTML

internal/httpapi/messages_parsed_test.go:46–65  ·  view source on GitHub ↗

parsed.html carries the decoded text/html part for display; text-only messages omit it.

(t *testing.T)

Source from the content-addressed store, hash-verified

44// parsed.html carries the decoded text/html part for display; text-only
45// messages omit it.
46func TestMessageViewParsedHTML(t *testing.T) {
47 htmlRaw := []byte("From: a@x.com\r\nContent-Type: multipart/alternative; boundary=B\r\n\r\n" +
48 "--B\r\nContent-Type: text/plain\r\n\r\nplain body\r\n" +
49 "--B\r\nContent-Type: text/html\r\n\r\n<div>rich <b>body</b></div>\r\n--B--\r\n")
50 v := messageViewFromIdentity(&identity.Message{
51 ID: "msg_h", Direction: "inbound", Sender: "a@x.com", RawMessage: htmlRaw,
52 })
53 if v.Parsed == nil || v.Parsed.HTML != "<div>rich <b>body</b></div>" {
54 t.Fatalf("parsed.html = %+v, want decoded HTML part", v.Parsed)
55 }
56
57 // Text-only message: html omitted (empty).
58 textOnly := messageViewFromIdentity(&identity.Message{
59 ID: "msg_t", Direction: "inbound", Sender: "a@x.com",
60 RawMessage: []byte("From: a@x.com\r\nContent-Type: text/plain\r\n\r\njust text"),
61 })
62 if textOnly.Parsed == nil || textOnly.Parsed.HTML != "" {
63 t.Fatalf("text-only parsed.html should be empty, got %+v", textOnly.Parsed)
64 }
65}
66
67// Fix #1: MessageView (detail) is a superset of MessageSummaryView (list) — it
68// must carry webhook_status, webhook_error and size_bytes for both directions.

Callers

nothing calls this directly

Calls 1

messageViewFromIdentityFunction · 0.85

Tested by

no test coverage detected