package tasks // A designed HTML email is the shape issue #393 reports: a document with its // own , a class-based stylesheet, a table layout and an Outlook // conditional comment. Every part of the send path that touches a body has to // survive it. import ( "strings" "testing" "github.com/warmbly/warmbly/internal/pkg/mailhtml" ) // A designed HTML email through the parts of the send path that touch the // body: plain-text derivation, signature, footer, pixel and CSS inlining. func TestDesignedEmailThroughTheSendPath(t *testing.T) { body := `

Hi Ana

Book a demo

` plain := ExtractPlainTextFromHTML(body) if strings.Contains(plain, "{") || strings.Contains(plain, "margin") { t.Errorf("the stylesheet reached the text part:\n%s", plain) } if !strings.Contains(plain, "Hi Ana") || !strings.Contains(plain, "https://x.test/demo") { t.Errorf("the text part lost the message:\n%s", plain) } withSig := AddSignature(body, `

Ana Perez

`, true) // Inside the laid-out container, not after it: appended at the end of the // document it would render flush against the left edge of the window, in // the page background, styled by nothing (issue #462). if !strings.Contains(withSig, "Ana Perez

") { t.Errorf("signature did not land inside the email container:\n%s", withSig) } // The conditional comment carries its own . Reading that one as the // document's put the signature inside a comment, where Outlook showed it // and every other client did not (issue #393). if !strings.Contains(withSig, "") { t.Errorf("signature landed inside the conditional comment:\n%s", withSig) } final := mailhtml.InlineCSS(withSig) if !strings.Contains(final, `width: 600px`) { t.Errorf("the class rule was not inlined onto the table:\n%s", final) } if !strings.Contains(final, "@media") { t.Errorf("the media query was dropped:\n%s", final) } if !strings.Contains(final, "") { t.Errorf("the Outlook conditional comment was lost:\n%s", final) } }