Battlepass fix
This commit is contained in:
@@ -71,7 +71,10 @@ public sealed class BattlePassService : IBattlePassService
|
||||
MaxLevel = Inv(season.MaxLevel),
|
||||
StartDate = FormatWireDate(season.StartDate),
|
||||
EndDate = FormatWireDate(season.EndDate),
|
||||
CanPurchase = season.CanPurchase,
|
||||
// Client uses can_purchase as the sole "show buy button / use normal-pass icon"
|
||||
// signal on the home BP screen (Wizard/BattlePass.cs:56,84 + BattlePassHeader.cs:51);
|
||||
// it must flip to false once the viewer owns the pass, or the button persists.
|
||||
CanPurchase = season.CanPurchase && !progress.IsPremium,
|
||||
},
|
||||
RewardInfo = new BattlePassRewardInfoDto
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user