diff --git a/main_test.go b/main_test.go index b2c5748..827adc7 100644 --- a/main_test.go +++ b/main_test.go @@ -3524,13 +3524,15 @@ func TestUIGroupToolsDisclosureStatePersists(t *testing.T) { configPath := filepath.Join(t.TempDir(), "ui-prefs.json") - first := newUIWithSession("desktop", &session.Manager{}) - first.uiPreferencesPath = configPath + first := newUIWithSession("desktop", &session.Manager{}, statePaths{ + UIPreferencesPath: configPath, + }) first.groupControlsHidden = true first.saveUIPreferences() - second := newUIWithSession("desktop", &session.Manager{}) - second.uiPreferencesPath = configPath + second := newUIWithSession("desktop", &session.Manager{}, statePaths{ + UIPreferencesPath: configPath, + }) second.groupControlsHidden = false second.loadUIPreferences() @@ -3544,13 +3546,15 @@ func TestUIDenseLayoutPreferencePersists(t *testing.T) { configPath := filepath.Join(t.TempDir(), "ui-prefs.json") - first := newUIWithSession("desktop", &session.Manager{}) - first.uiPreferencesPath = configPath + first := newUIWithSession("desktop", &session.Manager{}, statePaths{ + UIPreferencesPath: configPath, + }) first.denseLayout = true first.saveUIPreferences() - second := newUIWithSession("desktop", &session.Manager{}) - second.uiPreferencesPath = configPath + second := newUIWithSession("desktop", &session.Manager{}, statePaths{ + UIPreferencesPath: configPath, + }) second.denseLayout = false second.loadUIPreferences() @@ -3564,14 +3568,16 @@ func TestUISyncDefaultsPersistInSettings(t *testing.T) { configPath := filepath.Join(t.TempDir(), "settings.json") - first := newUIWithSession("desktop", &session.Manager{}) - first.settingsPath = configPath + first := newUIWithSession("desktop", &session.Manager{}, statePaths{ + SettingsPath: configPath, + }) first.syncDefaultSourceMode = syncSourceRemote first.syncDefaultDirection = syncDirectionPush first.saveSettings() - second := newUIWithSession("desktop", &session.Manager{}) - second.settingsPath = configPath + second := newUIWithSession("desktop", &session.Manager{}, statePaths{ + SettingsPath: configPath, + }) second.syncDefaultSourceMode = syncSourceLocal second.syncDefaultDirection = syncDirectionPull second.loadSettings() @@ -3600,9 +3606,10 @@ func TestUILoadSettingsFallsBackToLegacySyncDefaultsInUIPreferences(t *testing.T t.Fatalf("os.WriteFile() error = %v", err) } - reloaded := newUIWithSession("desktop", &session.Manager{}) - reloaded.uiPreferencesPath = legacyPath - reloaded.settingsPath = filepath.Join(dir, "settings.json") + reloaded := newUIWithSession("desktop", &session.Manager{}, statePaths{ + SettingsPath: filepath.Join(dir, "settings.json"), + UIPreferencesPath: legacyPath, + }) reloaded.syncDefaultSourceMode = syncSourceLocal reloaded.syncDefaultDirection = syncDirectionPull reloaded.loadSettings() @@ -3642,7 +3649,12 @@ func TestUISaveSecuritySettingsPersistsSyncDefaults(t *testing.T) { t.Parallel() manager := &session.Manager{} - u := newUIWithSession("desktop", manager) + dir := t.TempDir() + u := newUIWithSession("desktop", manager, statePaths{ + DefaultSaveAsPath: filepath.Join(dir, "vault.kdbx"), + SettingsPath: filepath.Join(dir, "settings.json"), + UIPreferencesPath: filepath.Join(dir, "ui-prefs.json"), + }) u.masterPassword.SetText("correct horse battery staple") if err := u.createVaultAction(); err != nil { t.Fatalf("createVaultAction() error = %v", err) @@ -3652,15 +3664,14 @@ func TestUISaveSecuritySettingsPersistsSyncDefaults(t *testing.T) { u.loadSettingsDraft() u.settingsDraft.Sync.SourceDefault = syncSourceRemote u.settingsDraft.Sync.DirectionDefault = syncDirectionPush - u.settingsPath = filepath.Join(t.TempDir(), "settings.json") - u.uiPreferencesPath = filepath.Join(t.TempDir(), "ui-prefs.json") if err := u.saveSecuritySettingsAction(); err != nil { t.Fatalf("saveSecuritySettingsAction() error = %v", err) } - reloaded := newUIWithSession("desktop", &session.Manager{}) - reloaded.settingsPath = u.settingsPath + reloaded := newUIWithSession("desktop", &session.Manager{}, statePaths{ + SettingsPath: u.settingsPath, + }) reloaded.loadSettings() if got := reloaded.syncDefaultSourceMode; got != syncSourceRemote { @@ -3676,8 +3687,9 @@ func TestUIAccessibilityPreferencesPersist(t *testing.T) { configPath := filepath.Join(t.TempDir(), "ui-prefs.json") - first := newUIWithSession("desktop", &session.Manager{}) - first.uiPreferencesPath = configPath + first := newUIWithSession("desktop", &session.Manager{}, statePaths{ + UIPreferencesPath: configPath, + }) first.applyAccessibilityPreferences(accessibilityPreferences{ DisplayDensity: displayDensityComfortable, Contrast: contrastHigh, @@ -3686,8 +3698,9 @@ func TestUIAccessibilityPreferencesPersist(t *testing.T) { }) first.saveUIPreferences() - second := newUIWithSession("desktop", &session.Manager{}) - second.uiPreferencesPath = configPath + second := newUIWithSession("desktop", &session.Manager{}, statePaths{ + UIPreferencesPath: configPath, + }) second.loadUIPreferences() if second.denseLayout { @@ -3750,14 +3763,16 @@ func TestUINotificationPreferencesPersist(t *testing.T) { configPath := filepath.Join(t.TempDir(), "ui-prefs.json") - first := newUIWithSession("desktop", &session.Manager{}) - first.uiPreferencesPath = configPath + first := newUIWithSession("desktop", &session.Manager{}, statePaths{ + UIPreferencesPath: configPath, + }) first.statusBannerTTL = statusBannerLong first.autofillNoticePreference = autofillNoticeApprovals first.saveUIPreferences() - second := newUIWithSession("desktop", &session.Manager{}) - second.uiPreferencesPath = configPath + second := newUIWithSession("desktop", &session.Manager{}, statePaths{ + UIPreferencesPath: configPath, + }) second.statusBannerTTL = statusBannerDuration second.autofillNoticePreference = autofillNoticeAll second.loadUIPreferences() @@ -4184,6 +4199,9 @@ func TestDefaultStatePathsUsesProvidedStateDir(t *testing.T) { if got := paths.RecentRemotesPath; got != filepath.Join(base, "recent-remotes.json") { t.Fatalf("RecentRemotesPath = %q, want %q", got, filepath.Join(base, "recent-remotes.json")) } + if got := paths.SettingsPath; got != filepath.Join(base, "settings.json") { + t.Fatalf("SettingsPath = %q, want %q", got, filepath.Join(base, "settings.json")) + } if got := paths.UIPreferencesPath; got != filepath.Join(base, "ui-prefs.json") { t.Fatalf("UIPreferencesPath = %q, want %q", got, filepath.Join(base, "ui-prefs.json")) } @@ -4207,6 +4225,9 @@ func TestDefaultStatePathsUsesEnvironmentStateDirWhenFlagUnset(t *testing.T) { if got := paths.RecentRemotesPath; got != filepath.Join(base, "recent-remotes.json") { t.Fatalf("RecentRemotesPath = %q, want %q", got, filepath.Join(base, "recent-remotes.json")) } + if got := paths.SettingsPath; got != filepath.Join(base, "settings.json") { + t.Fatalf("SettingsPath = %q, want %q", got, filepath.Join(base, "settings.json")) + } if got := paths.UIPreferencesPath; got != filepath.Join(base, "ui-prefs.json") { t.Fatalf("UIPreferencesPath = %q, want %q", got, filepath.Join(base, "ui-prefs.json")) } @@ -4224,6 +4245,7 @@ func TestRunActionSynchronizesAutofillCache(t *testing.T) { DefaultSaveAsPath: filepath.Join(dir, "vault.kdbx"), RecentVaultsPath: filepath.Join(dir, "recent-vaults.json"), RecentRemotesPath: filepath.Join(dir, "recent-remotes.json"), + SettingsPath: filepath.Join(dir, "settings.json"), UIPreferencesPath: filepath.Join(dir, "ui-prefs.json"), AutofillCachePath: cachePath, })