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

Function TestMessageViewParsed

internal/httpapi/messages_parsed_test.go:11–42  ·  view source on GitHub ↗

Any message carrying raw MIME gets a parsed view (quoted reply stripped) — inbound and sent outbound alike. Held drafts (no raw) don't.

(t *testing.T)

Source from the content-addressed store, hash-verified

9// Any message carrying raw MIME gets a parsed view (quoted reply stripped) —
10// inbound and sent outbound alike. Held drafts (no raw) don't.
11func TestMessageViewParsed(t *testing.T) {
12 raw := []byte("From: a@x.com\r\nContent-Type: text/plain\r\n\r\nMy reply.\r\n\r\n" +
13 "On Mon, Bob <b@y.com> wrote:\r\n> quoted original\r\n")
14
15 in := messageViewFromIdentity(&identity.Message{
16 ID: "msg_1", Direction: "inbound", Sender: "a@x.com", RawMessage: raw,
17 })
18 if in.Parsed == nil {
19 t.Fatal("inbound message should have a parsed view")
20 }
21 if in.Parsed.Text != "My reply." {
22 t.Fatalf("parsed.text = %q, want quoted-stripped %q", in.Parsed.Text, "My reply.")
23 }
24
25 // Sent outbound carries raw MIME (draft body columns are scrubbed at send),
26 // so it now gets the same parsed view — fixing the empty-body thread render.
27 out := messageViewFromIdentity(&identity.Message{
28 ID: "msg_2", Direction: "outbound", RawMessage: raw,
29 })
30 if out.Parsed == nil {
31 t.Fatal("sent outbound (with raw MIME) should have a parsed view")
32 }
33 if out.Parsed.Text != "My reply." {
34 t.Fatalf("outbound parsed.text = %q, want %q", out.Parsed.Text, "My reply.")
35 }
36
37 // Messages with no raw → no parsed view (nothing to parse).
38 none := messageViewFromIdentity(&identity.Message{ID: "msg_3", Direction: "inbound"})
39 if none.Parsed != nil {
40 t.Fatal("message with empty raw should have no parsed view")
41 }
42}
43
44// parsed.html carries the decoded text/html part for display; text-only
45// messages omit it.

Callers

nothing calls this directly

Calls 1

messageViewFromIdentityFunction · 0.85

Tested by

no test coverage detected