feat(mypage): /mypage/index reflects persisted bg selection
Wires MyPageController.Index to read Viewer.MyPageBgId/SelectType/BgRotation instead of emitting an empty MyPageBgSetting placeholder; adds Include for MyPageBgRotation in ViewerRepository.GetViewerByShortUdid; adds fresh-viewer zero-defaults test and write→read round-trip test (9/9 controller tests pass). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -165,4 +165,51 @@ public class UserMyPageControllerTests
|
||||
Assert.That(pool, Is.EqualTo(new[] { 1001, 0, 0, 1002 }),
|
||||
"garbage and empty entries are stored as 0; valid entries unaffected");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task MyPageIndex_for_fresh_viewer_returns_zero_defaults()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
long viewerId = await factory.SeedViewerAsync();
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var body = JsonBody("""{"viewer_id":"0","steam_id":0,"steam_session_ticket":""}""");
|
||||
var response = await client.PostAsync("/mypage/index", body);
|
||||
var raw = await response.Content.ReadAsStringAsync();
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK), raw);
|
||||
|
||||
using var doc = JsonDocument.Parse(raw);
|
||||
var setting = doc.RootElement.GetProperty("user_mypage_info").GetProperty("user_mypage_setting");
|
||||
Assert.That(setting.GetProperty("mypage_id").GetString(), Is.EqualTo("0"));
|
||||
Assert.That(setting.GetProperty("select_type").GetString(), Is.EqualTo("0"));
|
||||
Assert.That(setting.GetProperty("mypage_id_list").GetArrayLength(), Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Update_then_MyPageIndex_round_trips_full_state()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
long viewerId = await factory.SeedViewerAsync();
|
||||
using var client = factory.CreateAuthenticatedClient(viewerId);
|
||||
|
||||
var updateBody = JsonBody("""
|
||||
{"select_type":1,"mypage_id":"1213410310","mypage_id_list":["1211410310","1212410310","1213410310","1214410310","1215410310","1216410310","1217410310","1218410310"]}
|
||||
""");
|
||||
var updateResp = await client.PostAsync("/user_mypage/update", updateBody);
|
||||
Assert.That(updateResp.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
|
||||
var indexBody = JsonBody("""{"viewer_id":"0","steam_id":0,"steam_session_ticket":""}""");
|
||||
var indexResp = await client.PostAsync("/mypage/index", indexBody);
|
||||
var raw = await indexResp.Content.ReadAsStringAsync();
|
||||
Assert.That(indexResp.StatusCode, Is.EqualTo(HttpStatusCode.OK), raw);
|
||||
|
||||
using var doc = JsonDocument.Parse(raw);
|
||||
var setting = doc.RootElement.GetProperty("user_mypage_info").GetProperty("user_mypage_setting");
|
||||
Assert.That(setting.GetProperty("mypage_id").GetString(), Is.EqualTo("1213410310"));
|
||||
Assert.That(setting.GetProperty("select_type").GetString(), Is.EqualTo("1"));
|
||||
var list = setting.GetProperty("mypage_id_list");
|
||||
Assert.That(list.GetArrayLength(), Is.EqualTo(8));
|
||||
Assert.That(list[0].GetString(), Is.EqualTo("1211410310"));
|
||||
Assert.That(list[7].GetString(), Is.EqualTo("1218410310"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user