chore: migrate mail themes to shared framework and locked upstream inputs
Release / Validate Templates (push) Canceled after 0s
Release / Package & Release (push) Canceled after 0s
Release / Update Latest Release Documentation (push) Canceled after 0s

This commit is contained in:
KenanZhu committed 2026-10-09 18:34:36 +08:00
1 parent 5c0589f6f6
commit fec3ace600
225 files changed
+4718 -15807

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
package builder
import (
"bytes"
"gitea-mail-templates/tools/upstream"
"path/filepath"
"strings"
"testing"
)
func TestParagraphRolesPreserveOfficialActions(t *testing.T) {
source := `<html><body><p>{{.locale.Tr "mail.hi_user_x" .Username}}</p><p>{{.locale.Tr "mail.register_notify.text_2"}}</p>{{printf "<p>not static</p>"}}<p class="existing">Kept</p></body></html>`
result, err := paragraphRoles([]byte(source), "register_notify")
if err != nil {
t.Fatal(err)
}
want := strings.Replace(source, `<p>`, `<p class="email-heading">`, 1)
want = strings.Replace(want, `<p>`, `<p class="email-subtext">`, 1)
if string(result) != want {
t.Fatalf("unexpected presentation annotation: %s", result)
}
}
func TestSharedAlignmentFailsOnDrift(t *testing.T) {
s, err := upstream.LoadPinned(filepath.Join("..", ".."))
if err != nil {
t.Fatal(err)
}
name := "mail/user/auth/activate.tmpl"
original := bytes.Clone(s.Templates[name])
s.Templates[name] = bytes.Replace(original, []byte(`href="{{$activate_url}}"`), []byte(`href="changed"`), 1)
if _, err := AdaptOfficial(s, name); err == nil {
t.Fatal("unreviewed URL anchor accepted")
}
s.Templates[name] = original
delete(s.Locales["en-US"], "mail.activate_account")
if _, err := AdaptOfficial(s, name); err == nil {
t.Fatal("missing button key accepted")
}
}