test(gift): add SeedTutorialPresentsAsync helper
This commit is contained in:
@@ -562,6 +562,36 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
|
|||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public async Task SeedTutorialPresentsAsync(long viewerId)
|
||||||
|
{
|
||||||
|
using var scope = Services.CreateScope();
|
||||||
|
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads the viewer's current owned count for <paramref name="itemId"/>. Returns 0 if no
|
/// Reads the viewer's current owned count for <paramref name="itemId"/>. Returns 0 if no
|
||||||
/// row exists. Tests use this to assert ticket consumption after /tutorial/pack_open.
|
/// row exists. Tests use this to assert ticket consumption after /tutorial/pack_open.
|
||||||
|
|||||||
Reference in New Issue
Block a user