Feat: add persisted account theme settings

This commit is contained in:
MangoPig
2026-07-06 17:02:40 +01:00
parent 715661a4d2
commit dc081ccc5b
14 changed files with 653 additions and 46 deletions
@@ -206,6 +206,13 @@ func TestEnsureBootstrapPOSIXSkeletonInitializesEmptyRoot(t *testing.T) {
if personalSettings["slug"] != "ronald" {
t.Fatalf("expected personal slug ronald, got %#v", personalSettings["slug"])
}
personalTheme, ok := personalSettings["theme"].(map[string]any)
if !ok {
t.Fatalf("expected personal settings to contain theme object, got %#v", personalSettings)
}
if personalTheme["presetId"] != defaultThemePresetID {
t.Fatalf("expected personal theme preset %s, got %#v", defaultThemePresetID, personalTheme["presetId"])
}
personalHome := readStructuredFileForTest[map[string]any](t, filepath.Join(rootPath, "users", "personals", "personal-ronald", posixHomeFileName))
if personalHome["type"] != "personal-home" {
@@ -277,6 +284,39 @@ func TestCreateProjectHierarchyFolderOnDiskCreatesExpectedFolderShape(t *testing
}
}
func TestPersonalSettingsPathForDisplayName(t *testing.T) {
path := personalSettingsPathForDisplayName(" Ronald ")
if path != "users/personals/personal-ronald/settings.cbor" {
t.Fatalf("unexpected personal settings path: %s", path)
}
}
func TestApplyThemePresetToSettingsPreservesExistingFields(t *testing.T) {
settings := map[string]any{
"type": "personal",
"slug": "ronald",
"theme": map[string]any{
"density": "comfortable",
},
}
updated := applyThemePresetToSettings(settings, "moku-default")
if updated["type"] != "personal" {
t.Fatalf("expected type personal, got %#v", updated["type"])
}
theme, ok := updated["theme"].(map[string]any)
if !ok {
t.Fatalf("expected theme object, got %#v", updated["theme"])
}
if theme["presetId"] != "moku-default" {
t.Fatalf("expected presetId moku-default, got %#v", theme["presetId"])
}
if theme["density"] != "comfortable" {
t.Fatalf("expected density to be preserved, got %#v", theme["density"])
}
}
func TestCreateProjectTreeFolderOnDiskCreatesExpectedFolderShape(t *testing.T) {
rootPath := filepath.Join(t.TempDir(), "POSIX")
service := NewService(nil, rootPath)