Add SwarmUI settings management and portrait generation enhancements
- Introduced new API endpoints for managing SwarmUI settings, including fetching and saving presets and age rules. - Updated the portrait generation logic to utilize the new settings structure, allowing for dynamic preset selection based on age. - Enhanced UI components to support SwarmUI settings, including localization for new strings and improved styling for settings sections. - Added tests to verify the functionality of new settings endpoints and portrait generation behavior. This commit lays the groundwork for more flexible and user-friendly portrait generation options.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using HSchool.Server.Game;
|
||||
|
||||
namespace HSchool.Server.Tests;
|
||||
|
||||
public class SwarmUiSettingsStoreTests
|
||||
{
|
||||
[Fact]
|
||||
public void Resolve_UsesAgeRulePreset()
|
||||
{
|
||||
var config = SwarmUiConfigFile.CreateDefault();
|
||||
var profile = config.Resolve(8, PortraitKind.Avatar);
|
||||
|
||||
Assert.Equal("child", profile.PresetId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Resolve_FallsBackToActivePresetForAdults()
|
||||
{
|
||||
var config = SwarmUiConfigFile.CreateDefault();
|
||||
var profile = config.Resolve(34, PortraitKind.Full);
|
||||
|
||||
Assert.Equal("default", profile.PresetId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NormalizeAfterLoad_MigratesLegacyFlatFile()
|
||||
{
|
||||
var config = new SwarmUiConfigFile
|
||||
{
|
||||
Model = "legacy.safetensors",
|
||||
Steps = 12,
|
||||
Positive = "legacy prompt",
|
||||
Avatar = new SwarmUiKindPreset { Width = 640, Height = 640 },
|
||||
};
|
||||
|
||||
config.NormalizeAfterLoad();
|
||||
|
||||
Assert.Single(config.Presets);
|
||||
Assert.Equal("default", config.Presets[0].Id);
|
||||
Assert.Equal("legacy.safetensors", config.Presets[0].Model);
|
||||
Assert.Equal(12, config.Presets[0].Steps);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user