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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user