Skip to content

fix(tests): isolate the test host's prefs and real-install side effects - #518

Merged
tieubao merged 1 commit into
developfrom
fix/test-prefs-domain
Nov 16, 2026
Merged

tieubao merged 1 commit into
developfrom
fix/test-prefs-domain

Conversation

@tieubao

@tieubao tieubao commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

What

Test hosts launch with the shipping bundle id, so UserDefaults.standard was the user's real com.dwarvesv.minimalbar domain. This routes all preferences through AppDefaults.store: the dedicated suite com.dwarvesv.minimalbar.tests (wiped at first use) under XCTest, .standard otherwise.

A test host also skips Sparkle (updater not started, its key kept in the suite), the Move to Applications and App Store migration offers, the macOS 27 notice, and status item autosave names (macOS persists those in the real domain). Login items and the second-copy quit were already skipped. Opt back in with AppDefaults.sideEffectsOptIn or HIDDEN_BAR_TEST_HOST_SIDE_EFFECTS=1. Shipping behavior is unchanged.

Test

HiddenTests/PrefsIsolationTests.swift writes prefs and asserts the real domain (read via CFPreferences, never written) is identical before and after, plus the store, wipe and side-effect policy.

Run in the mac-ui VM with scripts/test.sh: Direct 659 passed, App Store 437 passed, 0 failed. Negative control (store forced to .standard): 2 isolation tests fail, including the real-domain delta.

A test host launches with the shipping bundle id, so UserDefaults.standard was the
user's real domain, and Debug/test runs answered the Move to Applications alert and
registered login items. Preferences and every default-arg store now go through
AppDefaults.store: a dedicated suite wiped at first use under XCTest, standard
otherwise. A test host also skips Sparkle, the move and migration offers, the macOS
27 notice and status item autosave. Opt back in with AppDefaults.sideEffectsOptIn or
HIDDEN_BAR_TEST_HOST_SIDE_EFFECTS=1.
@tieubao
tieubao merged commit 0cf0d6b into develop Nov 16, 2026
3 checks passed
@tieubao
tieubao deleted the fix/test-prefs-domain branch November 16, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant