@
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 <noreply@anthropic.com> @
This commit is contained in:
@@ -174,13 +174,14 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
|
||||
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<SVSimDbContext>();
|
||||
var viewer = await db.Viewers.Include(v => v.MissionData).FirstAsync(v => v.Id == viewerId);
|
||||
viewer.MissionData.TutorialState = tutorialState;
|
||||
|
||||
Reference in New Issue
Block a user