fix(viewer): fresh signups start at tutorial_state=0, not 100

Previously RegisterAnonymousViewer auto-completed the tutorial, which
prevented the client from ever entering the tutorial flow. SeedViewerAsync
gains a tutorialState parameter (default 100) so existing tests keep
their pre-completed-tutorial assumption.
This commit is contained in:
gamer147
2026-05-28 11:27:37 -04:00
parent 36dd25826b
commit f233a8c8d6
3 changed files with 40 additions and 2 deletions

View File

@@ -150,7 +150,8 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
/// </summary>
public async Task<long> SeedViewerAsync(
ulong steamId = 76_561_198_000_000_001UL,
string displayName = "Test Viewer")
string displayName = "Test Viewer",
int tutorialState = 100)
{
long viewerId;
long shortUdid;
@@ -173,6 +174,19 @@ 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)
{
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;
await db.SaveChangesAsync();
}
return viewerId;
}