diff --git a/SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs b/SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs index 43b33fc..9817310 100644 --- a/SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs +++ b/SVSim.UnitTests/Infrastructure/SVSimTestFactory.cs @@ -562,6 +562,36 @@ internal sealed class SVSimTestFactory : WebApplicationFactory await db.SaveChangesAsync(); } + /// + /// Seed the five tutorial ViewerPresent rows for a test viewer. RegisterViewer (admin/social + /// path) does NOT auto-seed; only the production /tool/signup -> RegisterAnonymousViewer flow + /// does. Tests opt in by calling this helper after SeedViewerAsync when they want a tutorial- + /// shaped inbox state. + /// + public async Task SeedTutorialPresentsAsync(long viewerId) + { + using var scope = Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var createdAt = DateTime.UtcNow; + foreach (var spec in SVSim.Database.SeedData.TutorialPresents.All) + { + db.ViewerPresents.Add(new ViewerPresent + { + ViewerId = viewerId, + PresentId = spec.PresentId, + Status = PresentStatus.Unclaimed, + RewardType = spec.RewardType, + RewardDetailId = spec.RewardDetailId, + RewardCount = spec.RewardCount, + ItemType = spec.ItemType, + Message = spec.Message, + CreatedAt = createdAt, + Source = "tutorial", + }); + } + await db.SaveChangesAsync(); + } + /// /// Reads the viewer's current owned count for . Returns 0 if no /// row exists. Tests use this to assert ticket consumption after /tutorial/pack_open.