package builder import ( "bytes" "gitea-mail-templates/tools/upstream" "path/filepath" "strings" "testing" ) func TestParagraphRolesPreserveOfficialActions(t *testing.T) { source := `

{{.locale.Tr "mail.hi_user_x" .Username}}

{{.locale.Tr "mail.register_notify.text_2"}}

{{printf "

not static

"}}

Kept

` result, err := paragraphRoles([]byte(source), "register_notify") if err != nil { t.Fatal(err) } want := strings.Replace(source, `

`, `

`, 1) want = strings.Replace(want, `

`, `

`, 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") } }