acdream/tests/AcDream.App.Tests/Configuration/RuntimeOptionsSessionConfigTests.cs
Erik 6e1c0967cb fix(app): Campaign LA gate round 2 — session-config launches force the retail UI on
A launcher-spawned client showed the world with NO interface at all -
character screen included. RetailUi rode ACDREAM_RETAIL_UI (the dev-era
opt-in), FromSessionConfig inherited the env parse, and the launcher
strips ACDREAM_* from children by design, so every product launch got
the dev default. A session-config launch IS a product launch: RetailUi
is now forced true on that path; the env flag remains the dev-launch
opt-in. Pinned by the session-config options test with a null env.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-15 08:42:33 +02:00

153 lines
5.3 KiB
C#

using AcDream.App;
using AcDream.App.Configuration;
using AcDream.Runtime.Session;
namespace AcDream.App.Tests.Configuration;
/// <summary>
/// Campaign LA slice LA1: round-trip tests for
/// <see cref="RuntimeOptions.FromSessionConfig"/> — the overlay that turns a
/// parsed <see cref="SessionConfiguration"/>/<see cref="SessionDescriptor"/>
/// into the same typed bundle the env-var dev flow produces.
/// </summary>
public sealed class RuntimeOptionsSessionConfigTests
{
[Fact]
public void SessionConfigOverridesLiveSettingsAndCarriesAllFiveNewFields()
{
var config = new SessionConfiguration { Version = 1 };
var session = new SessionDescriptor
{
Id = "gui-session",
Endpoint = new SessionEndpointDescriptor
{
Host = "192.168.1.50",
Port = 9123,
},
Account = "guiaccount",
Character = new SessionCharacterSelectorDescriptor { Name = "GuiToon" },
Credential = new SessionCredentialDescriptor
{
Provider = SessionCredentialProviderKind.Environment,
Reference = "IGNORED",
},
Plugins = ["PluginA", "PluginB"],
LoginCommands = ["/tell x, hi"],
LoginCommandDelayMs = 900,
StatusFile = "status.jsonl",
};
RuntimeOptions options = RuntimeOptions.FromSessionConfig(
"D:\\dat",
_ => null,
"session.json",
config,
session,
"resolved-password");
Assert.True(options.LiveMode);
Assert.Equal("192.168.1.50", options.LiveHost);
Assert.Equal(9123, options.LivePort);
Assert.Equal("guiaccount", options.LiveUser);
Assert.Equal("resolved-password", options.LivePass);
Assert.Equal("session.json", options.SessionConfigPath);
Assert.Equal("gui-session", options.SessionId);
Assert.Equal(
new LiveSessionCharacterSelector(null, null, "GuiToon"),
options.LiveCharacterSelector);
Assert.Equal("status.jsonl", options.StatusFilePath);
Assert.Equal(["PluginA", "PluginB"], options.Plugins);
Assert.Equal(["/tell x, hi"], options.LoginCommands);
Assert.Equal(900, options.LoginCommandDelayMs);
// Gate round 2: a session-config launch is a product launch — the
// retail UI must be ON even though the env func above returns null
// for everything (the launcher strips ACDREAM_* from children, so
// env inheritance here shipped a client with no interface at all).
Assert.True(options.RetailUi);
}
[Fact]
public void AbsentCharacterSelectorRemainsNullForGraphicalSelectionFlow()
{
var config = new SessionConfiguration { Version = 1 };
var session = new SessionDescriptor
{
Id = "no-selector",
Endpoint = new SessionEndpointDescriptor { Host = "127.0.0.1", Port = 9000 },
Account = "account",
Credential = new SessionCredentialDescriptor
{
Provider = SessionCredentialProviderKind.Environment,
Reference = "X",
},
};
RuntimeOptions options = RuntimeOptions.FromSessionConfig(
"D:\\dat",
_ => null,
"session.json",
config,
session,
"password");
Assert.Null(options.LiveCharacterSelector);
Assert.Null(options.Plugins);
Assert.Empty(options.LoginCommands);
Assert.Equal(500, options.LoginCommandDelayMs);
Assert.Null(options.StatusFilePath);
}
[Fact]
public void ProcessContentOverridesDatDirectoryAndPreparedAssetPath()
{
var config = new SessionConfiguration
{
Version = 1,
Process = new SessionProcessSettings
{
Content = new SessionContentDescriptor
{
DatDirectory = "D:\\configured-dats",
PreparedAssetPath = "D:\\configured-dats\\acdream.pak",
},
},
};
var session = new SessionDescriptor
{
Id = "content-session",
Endpoint = new SessionEndpointDescriptor { Host = "127.0.0.1", Port = 9000 },
Account = "account",
Credential = new SessionCredentialDescriptor
{
Provider = SessionCredentialProviderKind.Environment,
Reference = "X",
},
};
RuntimeOptions options = RuntimeOptions.FromSessionConfig(
"D:\\configured-dats",
_ => null,
"session.json",
config,
session,
"password");
Assert.Equal(
"D:\\configured-dats\\acdream.pak",
options.PreparedAssetPath);
}
[Fact]
public void EnvironmentFlowLeavesEveryNewFieldAtItsNothingConfiguredDefault()
{
RuntimeOptions options = RuntimeOptions.Parse("D:\\dat", _ => null);
Assert.Null(options.SessionConfigPath);
Assert.Null(options.SessionId);
Assert.Null(options.LiveCharacterSelector);
Assert.Null(options.StatusFilePath);
Assert.Null(options.Plugins);
Assert.Empty(options.LoginCommands);
Assert.Equal(500, options.LoginCommandDelayMs);
}
}