parsed.html carries the decoded text/html part for display; text-only messages omit it.
(t *testing.T)
| 44 | // parsed.html carries the decoded text/html part for display; text-only |
| 45 | // messages omit it. |
| 46 | func 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. |
nothing calls this directly
no test coverage detected