test(app): add headless ViewModel, CLI and localization tests
ViewModels run on Avalonia.Headless: wizard flows, password and file-lock handling, seed and private-key reveal gating, contacts, settings, sync and send against the fake server. The CLI entry point is invoked in-process end to end. Localization checks cover the 7 languages, placeholders and keys used in sources. Internal seams (UpdateCheck, ProfileOverride) keep the tests offline.
This commit is contained in:
1 parent
54d07f8e92
commit
530b7feaa5
11 files changed
+1023
-4
No files matched your search
@@ -0,0 +1,29 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Headless;
|
||||
using PalladiumWallet.Tests.App;
|
||||
|
||||
// Boots the real Avalonia Application headlessly (no window, no GPU) so ViewModels that use
|
||||
// the dispatcher (DispatcherTimer, UIThread.Post) can be tested. The xunit-v3-only helper
|
||||
// package (Avalonia.Headless.XUnit) is deliberately not used: this suite is on xunit 2.
|
||||
[assembly: AvaloniaTestApplication(typeof(TestAppBuilder))]
|
||||
|
||||
namespace PalladiumWallet.Tests.App;
|
||||
|
||||
public class TestAppBuilder
|
||||
{
|
||||
public static AppBuilder BuildAvaloniaApp() =>
|
||||
AppBuilder.Configure<global::PalladiumWallet.App.App>()
|
||||
.UseHeadless(new AvaloniaHeadlessPlatformOptions());
|
||||
}
|
||||
|
||||
/// <summary>One shared headless Avalonia session; tests run their body on its UI thread.</summary>
|
||||
internal static class UiSession
|
||||
{
|
||||
private static readonly Lazy<HeadlessUnitTestSession> Session =
|
||||
new(() => HeadlessUnitTestSession.StartNew(typeof(TestAppBuilder)));
|
||||
|
||||
public static Task Run(Func<Task> body) => Session.Value.Dispatch(body, CancellationToken.None);
|
||||
|
||||
public static Task Run(Action body) =>
|
||||
Session.Value.Dispatch(() => { body(); return Task.CompletedTask; }, CancellationToken.None);
|
||||
}
|
||||
Reference in new issue
Block a user