Split campaign log summary from detail

This commit is contained in:
2026-04-02 00:19:44 +02:00
parent e42c0fb9ba
commit ddb57cde8f
22 changed files with 406 additions and 110 deletions

View File

@@ -96,12 +96,17 @@ public sealed class ServiceSkillRollTests
rollIds.Add(ServiceTestSupport.GetValue(service.RollSkill(ownerSession, skill.Id, "public")).RollId);
var initialPage = ServiceTestSupport.GetValue(service.GetCampaignLogPage(gmSession, campaign.Id, limit: 3));
Assert.Equal(3, initialPage.Entries.Count);
Assert.Equal(3, initialPage.Entries.Length);
Assert.Equal(rollIds[2], initialPage.Entries[0].RollId);
Assert.Equal(rollIds[^1], initialPage.Entries[^1].RollId);
Assert.Equal(rollIds[^1], initialPage.Cursor);
Assert.True(initialPage.HasMore);
Assert.False(initialPage.ResetRequired);
Assert.All(initialPage.Entries, entry =>
{
Assert.False(string.IsNullOrWhiteSpace(entry.SummaryText));
Assert.False(string.IsNullOrWhiteSpace(entry.RollerLabel));
});
var latestRoll = ServiceTestSupport.GetValue(service.RollSkill(ownerSession, skill.Id, "public"));
var incrementalPage = ServiceTestSupport.GetValue(service.GetCampaignLogPage(gmSession, campaign.Id, initialPage.Cursor, 3));
@@ -137,9 +142,49 @@ public sealed class ServiceSkillRollTests
Assert.True(gapPage.ResetRequired);
Assert.True(gapPage.HasMore);
Assert.Equal(3, gapPage.Entries.Count);
Assert.Equal(3, gapPage.Entries.Length);
Assert.Equal(rollIds[3], gapPage.Entries[0].RollId);
Assert.Equal(rollIds[^1], gapPage.Entries[^1].RollId);
Assert.Equal(rollIds[^1], gapPage.Cursor);
}
[Fact]
public void RollDetail_ReturnsVisibleDetailAndHidesPrivateRoll()
{
using var harness = ServiceTestSupport.CreateHarness(6, 5, 4, 3, 2, 6);
var service = harness.Service;
service.Register("gm-detail", "Password123", "GM");
service.Register("owner-detail", "Password123", "Owner");
service.Register("observer-detail", "Password123", "Observer");
service.Register("outsider-detail", "Password123", "Outsider");
var gmSession = ServiceTestSupport.GetValue(service.Login("gm-detail", "Password123")).SessionToken;
var ownerSession = ServiceTestSupport.GetValue(service.Login("owner-detail", "Password123")).SessionToken;
var observerSession = ServiceTestSupport.GetValue(service.Login("observer-detail", "Password123")).SessionToken;
var outsiderSession = ServiceTestSupport.GetValue(service.Login("outsider-detail", "Password123")).SessionToken;
var campaign = ServiceTestSupport.GetValue(service.CreateCampaign(gmSession, "Detail", "d6"));
var ownerCharacter = ServiceTestSupport.GetValue(service.CreateCharacter(ownerSession, "Hero", campaign.Id));
_ = ServiceTestSupport.GetValue(service.CreateCharacter(observerSession, "Watcher", campaign.Id));
var skill = ServiceTestSupport.GetValue(service.CreateSkill(ownerSession, ownerCharacter.Id, "Stealth", "2D+1", 1, true));
var privateRoll = ServiceTestSupport.GetValue(service.RollSkill(ownerSession, skill.Id, "private"));
var publicRoll = ServiceTestSupport.GetValue(service.RollSkill(ownerSession, skill.Id, "public"));
var gmDetail = ServiceTestSupport.GetValue(service.GetRollDetail(gmSession, privateRoll.RollId));
var ownerDetail = ServiceTestSupport.GetValue(service.GetRollDetail(ownerSession, privateRoll.RollId));
var observerPublicDetail = ServiceTestSupport.GetValue(service.GetRollDetail(observerSession, publicRoll.RollId));
var observerPrivateDetail = service.GetRollDetail(observerSession, privateRoll.RollId);
var outsiderPublicDetail = service.GetRollDetail(outsiderSession, publicRoll.RollId);
Assert.NotEmpty(gmDetail.Dice);
Assert.Equal(privateRoll.RollId, gmDetail.RollId);
Assert.Equal(privateRoll.Breakdown, ownerDetail.Breakdown);
Assert.Equal(publicRoll.RollId, observerPublicDetail.RollId);
Assert.False(observerPrivateDetail.Succeeded);
Assert.Equal("roll_not_found", observerPrivateDetail.Error!.Code);
Assert.False(outsiderPublicDetail.Succeeded);
Assert.Equal("roll_not_found", outsiderPublicDetail.Error!.Code);
}
}