Skip to content

Commit

Permalink
Enable Node Auto Complete in CustomNodeWorkspace (#11307)
Browse files Browse the repository at this point in the history
* Re bind RequestNodeAutoCompleteSearch when open dyf

* Add unit test
  • Loading branch information
QilongTang authored Dec 2, 2020
1 parent 418a670 commit b3b5c09
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
using Dynamo.Graph.Nodes;
using Dynamo.Graph.Notes;
using Dynamo.Graph.Workspaces;
using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.Search.SearchElements;
using Dynamo.Selection;
using Dynamo.UI;
using Dynamo.UI.Controls;
using Dynamo.Utilities;
using Dynamo.ViewModels;
using Dynamo.Wpf.UI;
Expand Down Expand Up @@ -392,6 +390,7 @@ void OnWorkspaceViewDataContextChanged(object sender, DependencyPropertyChangedE
ViewModel.RequestAddViewToOuterCanvas += vm_RequestAddViewToOuterCanvas;
ViewModel.WorkspacePropertyEditRequested += VmOnWorkspacePropertyEditRequested;
ViewModel.RequestSelectionBoxUpdate += VmOnRequestSelectionBoxUpdate;
ViewModel.RequestNodeAutoCompleteSearch += ShowHideNodeAutoCompleteControl;

ViewModel.Loaded();
}
Expand Down
30 changes: 30 additions & 0 deletions test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,36 @@ public override void Start()
Model.AddZeroTouchNodesToSearch(Model.LibraryServices.GetAllFunctionGroups());
}

[Test]
public void NodeSuggestions_CanAutoCompleteInCustomNodeWorkspace()
{
Open(@"pkgs\EvenOdd2\dyf\EvenOdd.dyf");

// Pick the % node
NodeView nodeView = NodeViewWithGuid(Guid.Parse("1ddf4b4cc39f42acadd578db42bcb6d3").ToString());

var inPorts = nodeView.ViewModel.InPorts;
Assert.AreEqual(2, inPorts.Count());

var port = inPorts[0].PortModel;
var type = port.GetInputPortType();
Assert.AreEqual("var[]..[]", type);

port = inPorts[1].PortModel;
type = port.GetInputPortType();
Assert.AreEqual("var[]..[]", type);

var searchViewModel = ViewModel.CurrentSpaceViewModel.NodeAutoCompleteSearchViewModel;
searchViewModel.PortViewModel = inPorts[1];
var suggestions = searchViewModel.GetMatchingSearchElements();
// No matching search elements should be found
Assert.AreEqual(0, suggestions.Count());

// Show Node AutoCompleteSearchBar in custom node workspace
ViewModel.CurrentSpaceViewModel.OnRequestNodeAutoCompleteSearch(ShowHideFlags.Show);
var currentWs = View.ChildOfType<WorkspaceView>();
Assert.IsTrue(currentWs.NodeAutoCompleteSearchBar.IsOpen);
}

[Test]
public void NodeSuggestions_InputPortZeroTouchNode_AreCorrect()
Expand Down

0 comments on commit b3b5c09

Please sign in to comment.