Skip to content

test: stop About default-state tests racing the startup network check#845

Merged
laurentiu021 merged 1 commit into
mainfrom
test/fix-about-flaky-network-race
Jun 11, 2026
Merged

test: stop About default-state tests racing the startup network check#845
laurentiu021 merged 1 commit into
mainfrom
test/fix-about-flaky-network-race

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

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 fires InitializeAsync(InitAsync) — a fire-and-forget network call (CheckForUpdatesAsync → GitHub) that populates UpdateStatus, LatestNotes, LatestVersionLabel, LatestPublishedLabel, and UpdateAvailable. 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 pass autoCheck: true, so production behavior is byte-identical — the startup check still runs in the app. 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.

InternalsVisibleTo("SysManager.Tests") is already declared, so the internal ctor is visible to the test project.

Verification

  • Build: main + unit + integration, 0 errors / 0 warnings (Release).
  • Production paths (both public ctors) still trigger the startup check — confirmed.

Notes

  • test: only — no release. The production change is a single additive internal constructor used solely as a test seam; no app behavior changes.

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.
@laurentiu021 laurentiu021 merged commit 43a63e8 into main Jun 11, 2026
4 checks passed
@laurentiu021 laurentiu021 deleted the test/fix-about-flaky-network-race branch June 11, 2026 09:49
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