0.2.72 - Magic button, Next up fixes
This commit is contained in:
@@ -30,6 +30,34 @@ func TestNormalizePreferencesDropsUnknownKeys(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizePreferencesBoundsAndNormalisesProfileInitials(t *testing.T) {
|
||||
if got := normalizePreferences(map[string]any{"profileInitials": " mc "})["profileInitials"]; got != "MC" {
|
||||
t.Errorf("profileInitials = %v, want MC", got)
|
||||
}
|
||||
for _, value := range []any{"MAT", "M\nC", 12} {
|
||||
if got := normalizePreferences(map[string]any{"profileInitials": value})["profileInitials"]; got != "" {
|
||||
t.Errorf("profileInitials for %v = %v, want automatic fallback", value, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDevicePreferenceWritePreservesAdminInitials(t *testing.T) {
|
||||
stored, err := json.Marshal(normalizePreferences(map[string]any{"profileInitials": "MC"}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
merged := preserveAdminPreferences(map[string]any{
|
||||
"profileInitials": "XX", "showTitleLogo": false,
|
||||
}, stored)
|
||||
normalised := normalizePreferences(merged)
|
||||
if normalised["profileInitials"] != "MC" {
|
||||
t.Errorf("profileInitials = %v, want preserved MC", normalised["profileInitials"])
|
||||
}
|
||||
if normalised["showTitleLogo"] != false {
|
||||
t.Errorf("showTitleLogo = %v, want device change false", normalised["showTitleLogo"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizePreferencesRejectsIllegalValues(t *testing.T) {
|
||||
result := normalizePreferences(map[string]any{
|
||||
"homeCardDensity": "enormous",
|
||||
|
||||
Reference in New Issue
Block a user