From c2c6a951706cb1771e03f18ac987df782aaf9e4b Mon Sep 17 00:00:00 2001 From: gamer147 Date: Thu, 28 May 2026 19:56:06 -0400 Subject: [PATCH] @ fix(tests): SeedViewerAsync tutorialState param is no longer sentinel-overloaded The previous `if (tutorialState != 0)` block silently dropped overrides for state 0, so `SeedViewerAsync(tutorialState: 0)` returned whatever BuildDefaultViewer set (state 1), not state 0. Tests that wanted a fresh-signup viewer were getting one by accident, and the stale comment claimed the default was 0. Always override. Co-Authored-By: Claude Opus 4.7 @ --- SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs b/SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs index 1eef314..13cf1b5 100644 --- a/SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs +++ b/SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs @@ -174,13 +174,14 @@ internal sealed class SVSimTestFactory : WebApplicationFactory await db.SaveChangesAsync(); } - // Third scope: override TutorialState to the requested value when non-zero. - // BuildDefaultViewer now starts viewers at 0 (PRE_TUTORIAL_STEP). Tests that want - // a pre-completed-tutorial viewer (the common case for existing tests) pass the - // default tutorialState=100 here. - if (tutorialState != 0) + // Third scope: write the requested TutorialState. The parameter defaults to 100 — + // the post-tutorial baseline that ~30 existing tests rely on — so callers that don't + // care about the tutorial step keep working unchanged. Pass tutorialState: 1 to seed + // a fresh-signup viewer, or any other value to land mid-tutorial. RegisterViewer's + // own default (set in BuildDefaultViewer) is irrelevant here because this override + // always runs. + using (var scope = Services.CreateScope()) { - using var scope = Services.CreateScope(); var db = scope.ServiceProvider.GetRequiredService(); var viewer = await db.Viewers.Include(v => v.MissionData).FirstAsync(v => v.Id == viewerId); viewer.MissionData.TutorialState = tutorialState;