using XFEWorkflow.Abstractions;
using XFEWorkflow.Views;
namespace XFEWorkflow.Services;
internal static partial class UiSmokeTest
{
private static async Task SmokeBasicNodesAsync(string output)
{
var directory = new DirectoryInfo(AppContext.BaseDirectory);
while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "XFEWorkflow.slnx"))) directory = directory.Parent;
var repository = directory?.FullName ?? throw new DirectoryNotFoundException("找不到模板仓库");
var services = AppServices.Current;
var workflow = await services.Workflows.ImportAsync(Path.Combine(repository, "samples/workflows/basic-text-concat.xfeworkflow"));
workflow.Graph.Nodes.Single(n => n.Id == "text-log").Breakpoint = true;
await services.Workflows.SaveAsync(workflow);
var navigation = AppShellPage.Current!.ViewModel.NavigationViewService;
var frame = (Frame)AppShellPage.Current.FindName("navigationFrame");
try
{
navigation.NavigateTo<WorkflowEditorPage>();
await WaitManagementAsync(() => frame.Content is WorkflowEditorPage);
var editor = await WorkflowEditorPage.Current!.OpenAsync(workflow.Id);
await editor.SmokeBasicNodesAsync(output);
}
finally
{
if (services.Runs.IsRunning(workflow.Id)) await services.Runs.StopAsync(workflow.Id);
await WorkflowEditorPage.CloseOpenAsync(workflow.Id); navigation.NavigateTo<MainPage>(); await Task.Delay(250);
}
}
}
using XFEWorkflow.Abstractions;
using XFEWorkflow.Views;
namespace XFEWorkflow.Services;
internal static partial class UiSmokeTest
{
private static async Task SmokeBasicNodesAsync(string output)
{
var directory = new DirectoryInfo(AppContext.BaseDirectory);
while (directory is not null && !File.Exists(Path.Combine(directory.FullName, "XFEWorkflow.slnx"))) directory = directory.Parent;
var repository = directory?.FullName ?? throw new DirectoryNotFoundException("找不到模板仓库");
var services = AppServices.Current;
var workflow = await services.Workflows.ImportAsync(Path.Combine(repository, "samples/workflows/basic-text-concat.xfeworkflow"));
workflow.Graph.Nodes.Single(n => n.Id == "text-log").Breakpoint = true;
await services.Workflows.SaveAsync(workflow);
var navigation = AppShellPage.Current!.ViewModel.NavigationViewService;
var frame = (Frame)AppShellPage.Current.FindName("navigationFrame");
try
{
navigation.NavigateTo<WorkflowEditorPage>();
await WaitManagementAsync(() => frame.Content is WorkflowEditorPage);
var editor = await WorkflowEditorPage.Current!.OpenAsync(workflow.Id);
await editor.SmokeBasicNodesAsync(output);
}
finally
{
if (services.Runs.IsRunning(workflow.Id)) await services.Runs.StopAsync(workflow.Id);
await WorkflowEditorPage.CloseOpenAsync(workflow.Id); navigation.NavigateTo<MainPage>(); await Task.Delay(250);
}
}
}