fix(guild): /guild/update response — flat detail under guild (matches GuildUpdateTask.Parse)

GuildUpdateTask.Parse() reads data[guild] as GuildDetailInfo directly; the previous
GuildDetailSubTree wrapper (data[guild][detail]) caused json[guild_id].ToInt() to
crash on the client. Split GuildUpdateResponse (flat) from GuildUpdateEmblemResponse
(nested, correct for GuildEmblemUpdateTask.Parse). Also surfaces guild_name from the
request through UpdateGuildRequest.Name -> service -> repo so the client rename is honoured.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-27 12:54:15 -04:00
parent c0e1c10192
commit 09104f4e73
7 changed files with 78 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
using NUnit.Framework;
using System.Text.Json;
using SVSim.EmulatedEntrypoint.Models.Dtos.Common.Guild;
using SVSim.EmulatedEntrypoint.Models.Dtos.Guild;
namespace SVSim.UnitTests.Wire;
@@ -35,6 +36,55 @@ public class GuildWireShape
Assert.That(first.GetProperty("emblem_id").GetString(), Is.EqualTo("100000001"));
}
private static GuildDetailDto SampleDetail => new()
{
GuildId = 100_000_001,
GuildName = "X",
LeaderName = "L",
LeaderViewerId = 7,
Activity = 1,
JoinCondition = 1,
MemberNum = 1,
GuildEmblemId = 100_000_000L,
Description = "",
};
[Test]
public void GuildUpdate_response_serializes_with_flat_guild_detail()
{
// GuildUpdateTask.Parse() reads data["guild"] as GuildDetailInfo directly — no "detail" wrapper.
var resp = new GuildUpdateResponse { Guild = SampleDetail };
var json = JsonSerializer.Serialize(resp, Opts);
using var doc = JsonDocument.Parse(json);
var guild = doc.RootElement.GetProperty("guild");
// guild_id must be DIRECTLY under "guild"
Assert.That(guild.TryGetProperty("guild_id", out var gid), Is.True, "guild_id must be directly under guild");
Assert.That(gid.GetString(), Is.EqualTo("100000001"));
// No nested "detail" wrapper
Assert.That(guild.TryGetProperty("detail", out _), Is.False, "no detail wrapper for /guild/update");
}
[Test]
public void GuildUpdateEmblem_response_serializes_with_nested_detail()
{
// GuildEmblemUpdateTask.Parse() reads data["guild"]["detail"] — wrapper is required.
var resp = new GuildUpdateEmblemResponse
{
Guild = new GuildDetailSubTree { Detail = SampleDetail }
};
var json = JsonSerializer.Serialize(resp, Opts);
using var doc = JsonDocument.Parse(json);
var guildNode = doc.RootElement.GetProperty("guild");
Assert.That(guildNode.TryGetProperty("detail", out var detail), Is.True, "detail wrapper must exist for /guild/update_emblem");
Assert.That(detail.GetProperty("guild_id").GetString(), Is.EqualTo("100000001"));
// guild_id must NOT be directly under "guild"
Assert.That(guildNode.TryGetProperty("guild_id", out _), Is.False, "guild_id must be inside detail, not at guild level");
}
[Test]
public void GuildInfo_non_joined_serializes_to_prod_shape()
{