feat(home-dialog): seed file + importer + bootstrap hookup
Mirrors banners pattern: clear-and-rewrite from per-table JSON seed. Ships one entry pointing at parent_gacha_id 80032 to match the 2026-06-03 prod capture. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -157,6 +157,53 @@ public class MyPageGlobalsImporterTests
|
||||
"SealedSeason singleton must remain a single row on re-run");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Imports_home_dialogs_from_seed_file()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
|
||||
var importer = new MyPageGlobalsImporter();
|
||||
await importer.ImportHomeDialogsAsync(db, SeedDir);
|
||||
|
||||
var rows = await db.HomeDialogEntries.OrderBy(e => e.Id).ToListAsync();
|
||||
Assert.That(rows.Count, Is.GreaterThan(0), "seed must contain at least one home dialog");
|
||||
|
||||
var first = rows[0];
|
||||
Assert.That(first.TitleTextId, Is.Not.Empty);
|
||||
Assert.That(first.Image, Is.Not.Empty);
|
||||
Assert.That(first.ButtonListJson, Does.StartWith("["),
|
||||
"button_list must round-trip as a JSON array string");
|
||||
Assert.That(first.EndTime, Is.GreaterThan(first.BeginTime));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Home_dialogs_are_clear_and_rewrite()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
|
||||
db.HomeDialogEntries.Add(new HomeDialogEntry
|
||||
{
|
||||
Id = 999,
|
||||
TitleTextId = "legacy",
|
||||
Image = "legacy_image",
|
||||
ButtonListJson = "[]",
|
||||
BeginTime = DateTime.UtcNow.AddYears(-1),
|
||||
EndTime = DateTime.UtcNow.AddYears(-1).AddDays(1),
|
||||
});
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
var importer = new MyPageGlobalsImporter();
|
||||
await importer.ImportHomeDialogsAsync(db, SeedDir);
|
||||
|
||||
var stale = await db.HomeDialogEntries.FindAsync(999);
|
||||
Assert.That(stale, Is.Null,
|
||||
"ImportHomeDialogsAsync must clear-and-rewrite — pre-existing legacy rows must be removed");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Master_point_ranking_period_leaves_existing_rows_untouched()
|
||||
{
|
||||
|
||||
@@ -276,6 +276,7 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
|
||||
await mypage.ImportSealedAsync(ctx, seedDir);
|
||||
await mypage.ImportMasterPointRankingPeriodAsync(ctx, seedDir);
|
||||
await mypage.ImportSpecialDeckFormatsAsync(ctx, seedDir);
|
||||
await mypage.ImportHomeDialogsAsync(ctx, seedDir);
|
||||
|
||||
await new DefaultDeckImporter().ImportAsync(ctx, seedDir);
|
||||
await new PackImporter().ImportAsync(ctx, seedDir);
|
||||
|
||||
Reference in New Issue
Block a user