fix: seed production defaults and harden onboarding
This commit is contained in:
@@ -129,9 +129,33 @@ public sealed class ApiFixture : IAsyncLifetime
|
||||
}
|
||||
|
||||
[Collection(ApiCollection.Name)]
|
||||
public sealed class ApiIntegrationTests(ApiFixture fixture)
|
||||
{
|
||||
[Fact]
|
||||
public sealed class ApiIntegrationTests(ApiFixture fixture)
|
||||
{
|
||||
[Fact]
|
||||
public async Task PublicRuntimeDefaults_AreAvailableForProductionFlows()
|
||||
{
|
||||
using var publicClient = fixture.Factory.CreateClient();
|
||||
var avatars = await publicClient.GetFromJsonAsync<JsonElement>(
|
||||
"/api/public/avatars");
|
||||
var personas = await publicClient.GetFromJsonAsync<JsonElement>(
|
||||
"/api/public/personas");
|
||||
|
||||
Assert.Contains(avatars.EnumerateArray(), item =>
|
||||
item.GetProperty("key").GetString() == "cat");
|
||||
Assert.Contains(personas.EnumerateArray(), item =>
|
||||
item.GetProperty("key").GetString() == "sassy_cat");
|
||||
|
||||
using var user = await fixture.RegisterAsync("runtime_defaults_user");
|
||||
foreach (var type in new[] { "expense", "income" })
|
||||
{
|
||||
var categories = await user.GetFromJsonAsync<JsonElement>(
|
||||
$"/api/categories?type={type}");
|
||||
Assert.Contains(categories.EnumerateArray(), item =>
|
||||
item.GetProperty("name").GetString() == "其他");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DataIsolation_TimeZone_Recycle_Budget_AndExport_WorkTogether()
|
||||
{
|
||||
using var owner = await fixture.RegisterAsync("owner_account");
|
||||
|
||||
@@ -168,9 +168,12 @@ using (var scope = app.Services.CreateScope())
|
||||
await db.Database.MigrateAsync();
|
||||
await AppConfigDefaults.EnsureAsync(db);
|
||||
await scope.ServiceProvider.GetRequiredService<AdminBootstrapService>().EnsureAsync();
|
||||
if (app.Environment.IsDevelopment())
|
||||
await DbSeeder.SeedAsync(db);
|
||||
}
|
||||
// These records are runtime defaults, not development fixtures. Production
|
||||
// databases also need them for onboarding, category fallback and stickers.
|
||||
// DbSeeder only inserts into an empty catalog, so existing admin-managed
|
||||
// records are preserved.
|
||||
await DbSeeder.SeedAsync(db);
|
||||
}
|
||||
if (app.Environment.IsDevelopment())
|
||||
app.MapOpenApi();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user