Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ internal IEnumerable<NodeSearchElement> GetMatchingSearchElements()
//first sort by type distance to input port type
elements.Sort(comparer);
//then sort by node library group (create, action, or query node)
//this results in a list of elements with 3 major groups(create,action,query), each group is sub sorted into types.
return elements.OrderBy(x => x.Group);
//this results in a list of elements with 3 major groups(create,action,query), each group is sub sorted into types and then sorted by name.
return elements.OrderBy(x => x.Group).ThenBy(x => x.Name);


}
Expand Down
45 changes: 36 additions & 9 deletions test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected override void GetLibrariesToPreload(List<string> libraries)
libraries.Add("BuiltIn.ds");
libraries.Add("FFITarget.dll");
libraries.Add("ProtoGeometry.dll");
libraries.Add("DSCoreNodes.dll");
}

public override void Open(string path)
Expand Down Expand Up @@ -130,10 +131,7 @@ public void NodeSuggestions_InputPortZeroTouchNodeForProperty_AreCorrect()
"FFITarget.FFITarget.ClassFunctionality.ClassFunctionality",
"FFITarget.FFITarget.ClassFunctionality.Instance" };
var expectedNodes = nodes.OrderBy(s => s);
for (int i = 0; i < 4; i++)
{
Assert.AreEqual(expectedNodes.ElementAt(i), suggestedNodes.ElementAt(i));
}
Assert.IsTrue(expectedNodes.SequenceEqual(suggestedNodes));
}

[Test]
Expand All @@ -152,7 +150,6 @@ public void NodeSuggestions_GeometryNodes_SortedBy_NodeGroup_CreateActionQuery()
Assert.AreEqual(SearchElementGroup.Create, suggestions.FirstOrDefault().Group);
Assert.AreEqual(SearchElementGroup.Action, suggestions.ElementAt(suggestions.Count()/2).Group);
Assert.AreEqual(SearchElementGroup.Query, suggestions.LastOrDefault().Group);

}

[Test]
Expand Down Expand Up @@ -239,7 +236,7 @@ public void NodeSearchElementComparerSortsBasedOnTypeDistance_MultiReturnNodeMod
}

[Test]
public void NodeSuggestions_DefaultSuggestions()
public void NodeSuggestionsAreSortedBasedOnGroupAndAlphabetically()
{
Open(@"UI\builtin_inputport_suggestion.dyn");

Expand All @@ -255,6 +252,38 @@ public void NodeSuggestions_DefaultSuggestions()
var searchViewModel = ViewModel.CurrentSpaceViewModel.NodeAutoCompleteSearchViewModel;
searchViewModel.PortViewModel = inPorts[0];

var suggestions = searchViewModel.GetMatchingSearchElements();
Assert.AreEqual(6, suggestions.Count());

var suggestedNodes = suggestions.Select(s => s.FullName);
var expectedNodes = new[] { "DSCoreNodes.DSCore.Color.Add",
"DSCoreNodes.DSCore.Color.ByARGB",
"DSCoreNodes.DSCore.Color.Divide",
"DSCoreNodes.DSCore.Color.Multiply",
"DSCoreNodes.DSCore.ColorRange.GetColorAtParameter",
"DSCoreNodes.DSCore.IO.Image.Pixels"};

Assert.IsTrue(expectedNodes.SequenceEqual(suggestedNodes));

}

[Test]
public void NodeSuggestions_DefaultSuggestions()
{
Open(@"UI\builtin_inputport_suggestion.dyn");

// Get the node view for a specific node in the graph
NodeView nodeView = NodeViewWithGuid(Guid.Parse("b6cb6ceb21df4c7fb6b186e6ff399afc").ToString());

var inPorts = nodeView.ViewModel.InPorts;
Assert.AreEqual(2, inPorts.Count());
var port = inPorts[0].PortModel;
var type = port.GetInputPortType();
Assert.AreEqual("var[]..[]", type);

var searchViewModel = ViewModel.CurrentSpaceViewModel.NodeAutoCompleteSearchViewModel;
searchViewModel.PortViewModel = inPorts[0];

// Running the default algorithm should return no suggestions
var suggestions = searchViewModel.GetMatchingSearchElements();
Assert.AreEqual(0, suggestions.Count());
Expand Down Expand Up @@ -282,13 +311,11 @@ public void SearchNodeAutocompletionSuggestions()
var searchViewModel = (ViewModel.CurrentSpaceViewModel.NodeAutoCompleteSearchViewModel as NodeAutoCompleteSearchViewModel);
searchViewModel.PortViewModel = inPorts[0];

var suggestions = searchViewModel.GetMatchingSearchElements();

// Get the matching node elements for the specific node port.
searchViewModel.PopulateAutoCompleteCandidates();

// Filter the node elements using the search field.
searchViewModel.SearchAutoCompleteCandidates("der");
searchViewModel.SearchAutoCompleteCandidates("ar");
Assert.AreEqual(2 , searchViewModel.FilteredResults.Count());
}

Expand Down