using System.Text.Json; namespace UCVL.VPNPlus; internal static class DashboardInteractionSelfTest { internal static int Run() { var checks = new Dictionary(); string? error = null; try { using var form = new MainForm(preview: true, uiOnly: true) { Opacity = 0, ShowInTaskbar = false }; foreach (var check in form.CheckDashboardInteraction()) checks.Add(check.Key, check.Value); foreach (var check in DashboardComboSelfTest.Check()) checks.Add(check.Key, check.Value); } catch (Exception exception) { error = exception.ToString(); } var passed = error is null && checks.Count >= 43 && checks.Values.All(value => value); File.WriteAllText(Path.Combine(AppContext.BaseDirectory, "dashboard-interaction-self-test.json"), JsonSerializer.Serialize(new { passed, checks, error, scope = "owned synthetic WinForms fixture; no physical user-input or production acceptance claim", network_modified = false, installed_client_modified = false, credentials_loaded = false }, new JsonSerializerOptions { WriteIndented = true })); return passed ? 0 : 28; } } internal sealed partial class MainForm { internal Dictionary CheckDashboardInteraction() { var checks = new Dictionary(); var profile = new Profile { DisplayName = "滚动测试", Email = "fixture@example.invalid", Nodes = [new NodeInfo { Slug = "fixture", Name = "测试节点" }], RouteModes = [new RouteModeInfo { Id = "smart", Name = "AI 智能代理" }] }; Show(); ShowDashboard(profile); _refreshTimer.Stop(); Size = MinimumSize; PerformLayout(); LayoutDashboard(); Application.DoEvents(); checks["compact_chrome_has_only_minimize_caption"] = WindowChromeForTest is { LoginMode: false, MinimizeButton.Action: CaptionAction.Minimize } && _brandHeader.Controls.OfType().Count(button => button.Visible) == 1 && !_brandHeader.Controls.OfType