feat(cabana): mail templates list grouped by template with per-locale status

Gap G-35-1 (supersedes D-05; D-06 reset and D-07 drift per locale):
- the templates list keeps one row per template (the base row, or the
  lowest variant when only variants ship) with a Customized locales
  column (Default, then locale codes, at most three then +N);
- row states and the status filter aggregate over the template's
  locale versions; the locale filter is removed;
- a not-customized locale without a file shows the base row's current
  subject, body and layout; its info partial says so, its file version
  compares with the base file, and Reset returns it to the base file
  (postcard.ResetOverride accepts a fallback-locale code);
- copy: mail.template.customized_locales, mail.info_locale_default,
  mail.info_locale_fallback (en/pl);
- tests: TestMailScreensSmoke/locales_list, templates and drift updated,
  TestMailDrift on the grouped row, TestMailTemplateFilterScopes.
This commit is contained in:
Jakub Zych
2026-11-13 20:39:45 +01:00
parent 52c9c7eb18
commit 67f7164302
14 changed files with 460 additions and 118 deletions

View File

@@ -82,18 +82,20 @@ sample.name = "Ada"
Hi **{{ .name }}**, thanks for joining the Acme blog.
`)}
next := newMailScreensEnvWith(t, mailEnvOptions{files: files, keep: true})
// One list row per template: the drifted en version marks welcome's row.
baseID := next.mailRowID(t, postcard.TemplatesTable, blogWelcome)
list := next.expect(t, http.StatusOK, http.MethodGet, mailTemplatesPath+"?filter[status]=outdated", tok, nil)
rows := listRows(t, list)
if rows[blogWelcomeEn] == nil {
if rows[blogWelcome] == nil || rows[blogWelcome]["customized_locales"] != "en" {
t.Fatalf("outdated filter missing row: %#v", list["data"])
}
if got := fmt.Sprint(rowStates(next.expect(t, http.StatusOK, http.MethodGet, mailTemplatesPath, tok, nil), tmplID)); got != "[customized outdated]" {
if got := fmt.Sprint(rowStates(next.expect(t, http.StatusOK, http.MethodGet, mailTemplatesPath, tok, nil), baseID)); got != "[customized outdated]" {
t.Fatalf("drifted row states = %s", got)
}
next.expect(t, http.StatusOK, http.MethodPut, path, tok, map[string]any{
"subject": "Custom again {{ .name }}", "body": "Custom body for {{ .name }}", "layout": layoutID,
})
if got := fmt.Sprint(rowStates(next.expect(t, http.StatusOK, http.MethodGet, mailTemplatesPath, tok, nil), tmplID)); got != "[customized]" {
if got := fmt.Sprint(rowStates(next.expect(t, http.StatusOK, http.MethodGet, mailTemplatesPath, tok, nil), baseID)); got != "[customized]" {
t.Fatalf("reviewed row states = %s", got)
}
}