test: stop About default-state tests racing the startup network check#845
Merged
Conversation
AboutViewModel's constructor fires InitializeAsync(InitAsync), a fire-and-forget network call that populates UpdateStatus / LatestNotes / LatestVersionLabel / LatestPublishedLabel / UpdateAvailable. Five tests asserting those default values raced that call and failed intermittently on slow CI (e.g. LatestNotes_DefaultsEmpty failed once in PR #843's pipeline). Added an internal AboutViewModel(updates, reportService, autoCheck) constructor; both public constructors pass autoCheck: true so production behavior is unchanged (the startup check still runs). The five default-state tests now construct with autoCheck: false via a NewVmNoAutoCheck helper, asserting the constructor's real defaults deterministically with no network and no race. No release (test:); production behavior byte-identical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes a pre-existing flaky test in the suite:
AboutViewModelTests.LatestNotes_DefaultsEmpty(and four siblings) failed intermittently on slow CI — it tripped once in PR #843's pipeline run, passed on re-run.Root cause
AboutViewModel's constructor firesInitializeAsync(InitAsync)— a fire-and-forget network call (CheckForUpdatesAsync→ GitHub) that populatesUpdateStatus,LatestNotes,LatestVersionLabel,LatestPublishedLabel, andUpdateAvailable. Five tests assert those default (empty) values right after construction, racing that async fetch. When the network call won the race, the assert saw populated values and failed.Fix
Added an
internal AboutViewModel(updates, reportService, bool autoCheck)constructor. Both public constructors passautoCheck: true, so production behavior is byte-identical — the startup check still runs in the app. The five default-state tests now construct withautoCheck: false(via aNewVmNoAutoCheckhelper), asserting the constructor's real defaults deterministically with no network and no race.InternalsVisibleTo("SysManager.Tests")is already declared, so the internal ctor is visible to the test project.Verification
Notes
test:only — no release. The production change is a single additive internal constructor used solely as a test seam; no app behavior changes.