using Windows.System; using XFEWorkflow.Abstractions; using XFEWorkflow.Core.Runtime; using XFEWorkflow.Infrastructure.Storage; using XFEWorkflow.Services; using XFEWorkflow.ViewModels; namespace XFEWorkflow.Views; public sealed partial class MainPage { internal async Task SmokeBasicNodesAsync(string output) { await ready.Task; var workflow = ViewModel.SelectedWorkflow!; var root = (FrameworkElement)App.MainWindow.Content; var theme = root.RequestedTheme; var size = App.MainWindow.AppWindow.Size; async Task Wait(Func condition) { using var deadline = new CancellationTokenSource(TimeSpan.FromSeconds(15)); while (!condition()) await Task.Delay(25, deadline.Token); } try { var area = Microsoft.UI.Windowing.DisplayArea.GetFromWindowId(App.MainWindow.AppWindow.Id, Microsoft.UI.Windowing.DisplayAreaFallback.Nearest).WorkArea; var scale = root.XamlRoot.RasterizationScale; App.MainWindow.AppWindow.Resize(new((int)Math.Min(2000 * scale, area.Width - 32), (int)Math.Min(1180 * scale, area.Height - 32))); await Wait(() => IsLoaded && CanvasEditor.IsLoaded && CanvasEditor.ActualWidth > 0); await Task.Delay(200); ViewModel.RefreshPalette(""); var expected = new[] { "文本操作", "数学运算", "比较与布尔", "数组与集合", "对象与 JSON", "类型判断", "日期与时间", "编码与标识", "路径操作" }; if (expected.Any(category => ViewModel.PaletteGroups.All(g => g.Name != category))) throw new InvalidOperationException("基础节点分类不完整"); var counts = ViewModel.PaletteGroups.Select(g => new { category = g.Name, count = g.Count }).ToArray(); foreach (var query in new[] { "string concat", "Enumerable.Where", "Math.Round", "do while", "break", "typeof" }) { PaletteSearch.Text = query; ViewModel.RefreshPalette(query); if (!ViewModel.PaletteRows.OfType().Any()) throw new InvalidOperationException("C# 关键词无法找到对应节点:" + query); } PaletteSearch.Text = "文本拼接"; ViewModel.RefreshPalette("文本拼接"); var item = ViewModel.PaletteRows.OfType().Single(); if (item.Descriptor.Id != "core.text.concat" || item.SourceLabel != "内置节点" || !item.ToolTip.Contains("分隔符")) throw new InvalidOperationException("文本拼接节点库信息不完整"); CanvasEditor.AddNode(CoreCapabilities.Catalog()["core.while"]); var loop = workflow.Graph.Nodes.Single(n => n.CapabilityId == "core.while"); if (loop.Children.ContainsKey("condition") || !loop.Children.ContainsKey("body")) throw new InvalidOperationException("条件循环错误地自动创建了判断子图"); ShowProperties(loop); await UiSmokeTest.InvokeButtonAsync(PropertyPanel.Children.OfType