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:
@@ -180,7 +180,7 @@ public class ViewerRepository : IViewerRepository
|
||||
viewer.Currency.Crystals = grants.Crystals;
|
||||
viewer.Currency.Rupees = grants.Rupees;
|
||||
viewer.Currency.RedEther = grants.Ether;
|
||||
viewer.MissionData.TutorialState = 100; // finishes tutorial for now
|
||||
viewer.MissionData.TutorialState = 0; // PRE_TUTORIAL_STEP — fresh signups go through the tutorial flow
|
||||
|
||||
// Load classes WITH their LeaderSkins — DefaultLeaderSkin iterates the nav collection
|
||||
// and would otherwise be null (audit §6 #3 latent NRE — this is the one).
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NUnit.Framework;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Repositories.Viewer;
|
||||
using SVSim.UnitTests.Infrastructure;
|
||||
|
||||
namespace SVSim.UnitTests.Repositories;
|
||||
|
||||
public class ViewerRepositoryTutorialDefaultTests
|
||||
{
|
||||
[Test]
|
||||
public async Task RegisterAnonymousViewer_starts_at_tutorial_step_0()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var repo = scope.ServiceProvider.GetRequiredService<IViewerRepository>();
|
||||
|
||||
var viewer = await repo.RegisterAnonymousViewer(Guid.NewGuid());
|
||||
|
||||
Assert.That(viewer.MissionData.TutorialState, Is.EqualTo(0),
|
||||
"Fresh signups must start at PRE_TUTORIAL_STEP=0 so the client triggers the tutorial flow. " +
|
||||
"Tests that want a pre-completed tutorial should use SeedViewerAsync (which defaults to 100).");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user