Exclude translations from cookie banner version snapshots

Translation changes are cosmetic, not consent-contract changes,
so they should not trigger a version bump. Translations are now
loaded live from the database at serve time instead of being
frozen in the snapshot.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-02 18:10:18 +04:00
parent 685ff91d74
commit 887453fee2
5 changed files with 58 additions and 64 deletions

View File

@@ -49,14 +49,6 @@ func TestSnapshotsEqual(t *testing.T) {
PostHogConsent: false,
},
},
Translations: map[string]coredata.CookieBannerVersionSnapshotTranslation{
"fr": {
UI: map[string]string{"title": "Cookies"},
Categories: []coredata.CookieBannerVersionSnapshotCategoryTranslation{
{Name: "Analyse", Description: "Cookies d'analyse"},
},
},
},
}
}
@@ -103,19 +95,6 @@ func TestSnapshotsEqual(t *testing.T) {
assert.False(t, snapshotsEqual(a, b))
})
t.Run("differing translation UI is not equal", func(t *testing.T) {
t.Parallel()
a := baseSnapshot()
b := baseSnapshot()
b.Translations["fr"] = coredata.CookieBannerVersionSnapshotTranslation{
UI: map[string]string{"title": "Cookies updated"},
Categories: a.Translations["fr"].Categories,
}
assert.False(t, snapshotsEqual(a, b))
})
t.Run("differing GCMConsentTypes order is not equal", func(t *testing.T) {
t.Parallel()
@@ -214,8 +193,8 @@ func TestBuildSnapshot_RankInvariant(t *testing.T) {
t.Run("snapshot is identical regardless of rank values", func(t *testing.T) {
t.Parallel()
original := buildSnapshot(banner, mkCategories(0, 1, 2, 3), nil, nil)
shuffled := buildSnapshot(banner, mkCategories(99, 50, 25, 10), nil, nil)
original := buildSnapshot(banner, mkCategories(0, 1, 2, 3), nil)
shuffled := buildSnapshot(banner, mkCategories(99, 50, 25, 10), nil)
assert.True(t, snapshotsEqual(original, shuffled), "rank changes must not affect the snapshot")
})
@@ -226,8 +205,8 @@ func TestBuildSnapshot_RankInvariant(t *testing.T) {
ordered := mkCategories(0, 1, 2, 3)
reversed := coredata.CookieCategories{ordered[3], ordered[2], ordered[1], ordered[0]}
a := buildSnapshot(banner, ordered, nil, nil)
b := buildSnapshot(banner, reversed, nil, nil)
a := buildSnapshot(banner, ordered, nil)
b := buildSnapshot(banner, reversed, nil)
assert.True(t, snapshotsEqual(a, b))
})
@@ -235,7 +214,7 @@ func TestBuildSnapshot_RankInvariant(t *testing.T) {
t.Run("Necessary comes first and Uncategorised comes last", func(t *testing.T) {
t.Parallel()
snap := buildSnapshot(banner, mkCategories(0, 1, 2, 3), nil, nil)
snap := buildSnapshot(banner, mkCategories(0, 1, 2, 3), nil)
require.Len(t, snap.Categories, 4)
assert.Equal(t, coredata.CookieCategoryKindNecessary, snap.Categories[0].Kind)