package handlers

// Regression tests for the template-tier → language-fallback mapping
// (t-paliad-276). The editor surfaces a "Fallback: universelles
// Skelett" notice when the requested draft language has no per-firm
// language-matched template — these tests pin which tier counts as a
// fallback for each language so the UI signal stays stable.

import "testing"

func TestLanguageFallback(t *testing.T) {
	t.Parallel()
	cases := []struct {
		name string
		lang string
		tier submissionTemplateTier
		want bool
	}{
		// DE drafts: every non-letterhead tier is a first-class match.
		{"de_per_code_lang", "de", tplTierPerCodeLang, false},
		{"de_per_code", "de", tplTierPerCode, false},
		{"de_skeleton_lang", "de", tplTierSkeletonLang, false},
		{"de_skeleton", "de", tplTierSkeleton, false},
		{"de_letterhead", "de", tplTierLetterhead, true},

		// EN drafts: per_code (DE-baked) and skeleton (DE-baked) both
		// surface the fallback notice so the lawyer knows the rendered
		// body lacks EN prose.
		{"en_per_code_lang", "en", tplTierPerCodeLang, false},
		{"en_per_code", "en", tplTierPerCode, true},
		{"en_skeleton_lang", "en", tplTierSkeletonLang, false},
		{"en_skeleton", "en", tplTierSkeleton, true},
		{"en_letterhead", "en", tplTierLetterhead, true},
	}
	for _, c := range cases {
		t.Run(c.name, func(t *testing.T) {
			t.Parallel()
			if got := languageFallback(c.lang, c.tier); got != c.want {
				t.Errorf("languageFallback(%q, %q) = %v, want %v", c.lang, c.tier, got, c.want)
			}
		})
	}
}
