Battlepass fix

This commit is contained in:
gamer147
2026-05-28 00:54:46 -04:00
parent 0f44a3482c
commit 39b38e3c80
2 changed files with 31 additions and 1 deletions

View File

@@ -105,6 +105,33 @@ public class BattlePassControllerInfoTests
Assert.That(premiumReward.GetProperty("is_received").GetBoolean(), Is.False);
}
[Test]
public async Task Info_can_purchase_is_false_when_viewer_already_premium()
{
using var factory = new SVSimTestFactory();
long viewerId = await factory.SeedViewerAsync();
await SeedSeason23WithRewards(factory);
using (var scope = factory.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
db.ViewerBattlePassProgress.Add(new ViewerBattlePassProgressEntry
{
ViewerId = viewerId, SeasonId = 23, CurrentPoint = 0, IsPremium = true,
});
await db.SaveChangesAsync();
}
using var client = factory.CreateAuthenticatedClient(viewerId);
var response = await client.PostAsync("/battle_pass/info", JsonBody(EmptyAuthBody));
var body = await response.Content.ReadAsStringAsync();
using var doc = JsonDocument.Parse(body);
Assert.That(doc.RootElement.GetProperty("season_info").GetProperty("can_purchase").GetBoolean(),
Is.False,
"premium owners must see can_purchase=false (client uses it as the sole hide-buy-button signal)");
}
[Test]
public async Task Info_returns_empty_payload_outside_any_season_window()
{