diff --git a/client/ui/autostart_default_test.go b/client/ui/autostart_default_test.go index be84ac09e..b7bdf9f2a 100644 --- a/client/ui/autostart_default_test.go +++ b/client/ui/autostart_default_test.go @@ -12,10 +12,9 @@ import ( func TestShouldEnableAutostartDefault(t *testing.T) { allPass := autostartDefaultState{ - supported: true, - mdmDisabled: false, - postUpdateRelaunch: false, - breadcrumbPresent: true, + supported: true, + mdmDisabled: false, + priorInstall: false, } tests := []struct { @@ -40,32 +39,26 @@ func TestShouldEnableAutostartDefault(t *testing.T) { wantReason: "autostart disabled by MDM policy", }, { - name: "post-update relaunch skips", - mutate: func(s *autostartDefaultState) { s.postUpdateRelaunch = true }, - wantReason: "post-update relaunch", - }, - { - name: "missing breadcrumb (upgrade or portable build) skips", - mutate: func(s *autostartDefaultState) { s.breadcrumbPresent = false }, - wantReason: "no fresh-install breadcrumb", + name: "existing installation (upgrade) skips", + mutate: func(s *autostartDefaultState) { s.priorInstall = true }, + wantReason: "existing NetBird installation", }, { name: "unsupported wins over every other guard", mutate: func(s *autostartDefaultState) { s.supported = false s.mdmDisabled = true - s.postUpdateRelaunch = true - s.breadcrumbPresent = false + s.priorInstall = true }, wantReason: "autostart not supported on this platform", }, { - name: "breadcrumb present but relaunched after update skips", + name: "MDM disable wins over prior install", mutate: func(s *autostartDefaultState) { - s.postUpdateRelaunch = true - s.breadcrumbPresent = true + s.mdmDisabled = true + s.priorInstall = true }, - wantReason: "post-update relaunch", + wantReason: "autostart disabled by MDM policy", }, } diff --git a/client/ui/preferences/store_test.go b/client/ui/preferences/store_test.go index 71c52038f..6384fddb8 100644 --- a/client/ui/preferences/store_test.go +++ b/client/ui/preferences/store_test.go @@ -238,6 +238,23 @@ func TestStore_SetAutostartInitializedPersistsAcrossReload(t *testing.T) { assert.True(t, reloaded.Get().AutostartInitialized, "marker must survive a reload from disk") } +func TestStore_ExistedAtLoad(t *testing.T) { + withTempConfigDir(t) + + // Brand-new OS user: no preferences file on disk yet. + fresh, err := NewStore(nil, nil) + require.NoError(t, err) + assert.False(t, fresh.ExistedAtLoad(), "ExistedAtLoad must be false when no file is on disk") + + // Persisting a value writes the file to disk. + require.NoError(t, fresh.SetLanguage("en")) + + // A subsequent GUI launch reopens the now-present file. + reopened, err := NewStore(nil, nil) + require.NoError(t, err) + assert.True(t, reopened.ExistedAtLoad(), "ExistedAtLoad must be true after the store has persisted and is reopened") +} + func TestStore_ErrUnsupportedSentinel(t *testing.T) { // Verifies callers can match on the sentinel error rather than parsing // strings — protects against accidental %v -> %w changes that would