Skip to content

Keep appearance tests out of the user's real defaults - #94

Merged
oNaiPs merged 1 commit into
mainfrom
test/isolate-user-defaults
Oct 17, 2026
Merged

oNaiPs merged 1 commit into
mainfrom
test/isolate-user-defaults

Conversation

@oNaiPs

@oNaiPs oNaiPs commented Oct 17, 2026

Copy link
Copy Markdown
Owner

AppearanceManager hardcoded UserDefaults.standard, so AppearanceManagerTests, AppearanceSettingsModelTests and ResultsViewTests saved and restored the developer's real appearance settings around every test. When test runs overlapped (e.g. several worktrees at once) this caused intermittent failures such as testColorsRoundTripThroughUserDefaults and could leave stray values behind.

  • AppearanceManager now takes its defaults in init(defaults:); appDefaults is .standard in the app and a throwaway suite (dmenu-mac.tests.appearance, wiped at startup) under XCTest — the same pattern as UsageStore, AliasSettings and SearchShortcutSettings.
  • Tests that wrote UserDefaults.standard directly now use AppearanceManager.appDefaults.
  • New testTestsNeverWriteTheRealDefaults checks a write through AppearanceManager.shared never reaches the real defaults.

Testing: full suite passed 3 runs in a row (374 tests), swiftlint --strict clean, and the real appearance.* keys were unchanged afterwards.

🤖 Generated with Claude Code

AppearanceManager hardcoded UserDefaults.standard, so its tests saved and
restored the user's real appearance settings around each test and could
fail or leave stray values when test runs overlapped. Under XCTest it now
uses a throwaway suite, like UsageStore, AliasSettings and
SearchShortcutSettings already do.
@oNaiPs
oNaiPs merged commit 484b9a9 into main Oct 17, 2026
3 checks passed
@oNaiPs
oNaiPs deleted the test/isolate-user-defaults branch October 17, 2026 14:10
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