Skip to content

Commit

Permalink
DYN-7716 Fixing Flaky Tests (#15680)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertGlobant20 authored Nov 22, 2024
1 parent 550354c commit 9fcf24a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
41 changes: 32 additions & 9 deletions test/DynamoCoreWpfTests/NodeAutoCompleteSearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Dynamo;
using Dynamo.Configuration;
using Dynamo.Controls;
using Dynamo.Graph.Nodes;
using Dynamo.Models;
Expand All @@ -18,7 +19,7 @@ namespace DynamoCoreWpfTests
class NodeAutoCompleteSearchTests : DynamoTestUIBase
{

private readonly List<string> expectedNodes = new List<string> { "ByFillet", "ByFilletTangentToCurve", "ByGeometry", "ByMinimumVolume", "ByBlendBetweenCurves", "ByTangency", "ByLineAndPoint", "ByJoinedCurves", "ByThickeningCurveNormal", "ByLoft", "ByLoft", "ByLoftGuides", "BySweep", "ByLoft", "ByLoft", "ByRevolve", "BySweep", "BySweep2Rails", "ByLoft", "ByLoft", "ByPatch", "ByRevolve", "ByRuledLoft", "BySweep", "BySweep2Rails", "BuildFromLines", "BuildPipes", "ByExtrude", "ByPlaneLineAndPoint", "ByRevolve", "BySweep", "DoesIntersect", "IsAlmostEqualTo", "DistanceTo", "Intersect", "IntersectAll", "Project", "Project", "ProjectInputOnto", "ProjectInputOnto", "Split", "Trim", "SerializeAsSAB", "ClosestPointTo", "Join", "ByGroupedCurves", "SweepAsSolid", "ExportToSAT", "SweepAsSurface", "LocateSurfacesByLine", "BridgeEdgesToEdges", "BridgeEdgesToFaces", "BridgeFacesToEdges", "BridgeFacesToFaces", "CreateMatch", "ExtrudeEdgesAlongCurve", "ExtrudeFacesAlongCurve", "PullVertices" };
private readonly List<string> expectedNodes = new List<string> { "ProtoGeometry.Autodesk.DesignScript.Geometry.Arc.ByFillet", "ProtoGeometry.Autodesk.DesignScript.Geometry.Arc.ByFilletTangentToCurve", "ProtoGeometry.Autodesk.DesignScript.Geometry.BoundingBox.ByGeometry", "ProtoGeometry.Autodesk.DesignScript.Geometry.BoundingBox.ByMinimumVolume", "ProtoGeometry.Autodesk.DesignScript.Geometry.Curve.ByBlendBetweenCurves", "ProtoGeometry.Autodesk.DesignScript.Geometry.Line.ByTangency", "ProtoGeometry.Autodesk.DesignScript.Geometry.Mesh.ByGeometry", "ProtoGeometry.Autodesk.DesignScript.Geometry.Plane.ByLineAndPoint", "ProtoGeometry.Autodesk.DesignScript.Geometry.PolyCurve.ByJoinedCurves", "ProtoGeometry.Autodesk.DesignScript.Geometry.PolyCurve.ByThickeningCurveNormal", "ProtoGeometry.Autodesk.DesignScript.Geometry.PolySurface.ByLoft", "ProtoGeometry.Autodesk.DesignScript.Geometry.PolySurface.ByLoft", "ProtoGeometry.Autodesk.DesignScript.Geometry.PolySurface.ByLoftGuides", "ProtoGeometry.Autodesk.DesignScript.Geometry.PolySurface.BySweep", "ProtoGeometry.Autodesk.DesignScript.Geometry.Solid.ByLoft", "ProtoGeometry.Autodesk.DesignScript.Geometry.Solid.ByLoft", "ProtoGeometry.Autodesk.DesignScript.Geometry.Solid.ByRevolve", "ProtoGeometry.Autodesk.DesignScript.Geometry.Solid.BySweep", "ProtoGeometry.Autodesk.DesignScript.Geometry.Solid.BySweep2Rails", "ProtoGeometry.Autodesk.DesignScript.Geometry.Surface.ByLoft", "ProtoGeometry.Autodesk.DesignScript.Geometry.Surface.ByLoft", "ProtoGeometry.Autodesk.DesignScript.Geometry.Surface.ByPatch", "ProtoGeometry.Autodesk.DesignScript.Geometry.Surface.ByRevolve", "ProtoGeometry.Autodesk.DesignScript.Geometry.Surface.ByRuledLoft", "ProtoGeometry.Autodesk.DesignScript.Geometry.Surface.BySweep", "ProtoGeometry.Autodesk.DesignScript.Geometry.Surface.BySweep2Rails", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.BuildFromLines", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.BuildPipes", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.ByExtrude", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.ByPlaneLineAndPoint", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.ByRevolve", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.BySweep", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.DoesIntersect", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.IsAlmostEqualTo", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.DistanceTo", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.Intersect", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.IntersectAll", "ProtoGeometry.Autodesk.DesignScript.Geometry.Curve.Project", "ProtoGeometry.Autodesk.DesignScript.Geometry.Point.Project", "ProtoGeometry.Autodesk.DesignScript.Geometry.Solid.ProjectInputOnto", "ProtoGeometry.Autodesk.DesignScript.Geometry.Surface.ProjectInputOnto", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.Split", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.Trim", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.SerializeAsSAB", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.ClosestPointTo", "ProtoGeometry.Autodesk.DesignScript.Geometry.Curve.Join", "ProtoGeometry.Autodesk.DesignScript.Geometry.PolyCurve.ByGroupedCurves", "ProtoGeometry.Autodesk.DesignScript.Geometry.Curve.SweepAsSolid", "ProtoGeometry.Autodesk.DesignScript.Geometry.Geometry.ExportToSAT", "ProtoGeometry.Autodesk.DesignScript.Geometry.Curve.SweepAsSurface", "ProtoGeometry.Autodesk.DesignScript.Geometry.PolySurface.LocateSurfacesByLine", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.BridgeEdgesToEdges", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.BridgeEdgesToFaces", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.BridgeFacesToEdges", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.BridgeFacesToFaces", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.CreateMatch", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.ExtrudeEdgesAlongCurve", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.ExtrudeFacesAlongCurve", "ProtoGeometry.Autodesk.DesignScript.Geometry.TSpline.TSplineSurface.PullVertices" };

[NodeDescription("This is test node with multiple output ports and types specified.")]
[NodeName("node with multi type outputs")]
Expand Down Expand Up @@ -65,6 +66,28 @@ public override void Start()
Model.AddZeroTouchNodesToSearch(Model.LibraryServices.GetAllFunctionGroups());
}

private void ValidateMissingAddedNodes(List<string> nodeNamesResultList, PreferenceSettings prefSettings)
{
var namespacesToExcludeFromLibraryStr = "\"" + string.Join("\",", prefSettings.NamespacesToExcludeFromLibrary);
var missingNodes = new List<string>();

string nodesMatchingFailText = "Missing nodes";
if (expectedNodes.Count() > nodeNamesResultList.Count())
{
missingNodes = expectedNodes.Except(nodeNamesResultList).ToList();
}
else if (expectedNodes.Count() < nodeNamesResultList.Count())
{
nodesMatchingFailText = "New Added nodes";
missingNodes = nodeNamesResultList.Except(expectedNodes).ToList();
}
Assert.AreEqual(expectedNodes.Count(), nodeNamesResultList.Count(), string.Format("{0}: {1}\nNamespacesToExcludeFromLibrarySpecified: {2}\n NamespacesToExcludeFromLibrary: {3}",
nodesMatchingFailText,
string.Join(", ", missingNodes),
namespacesToExcludeFromLibraryStr,
prefSettings.NamespacesToExcludeFromLibrarySpecified.ToString()));
}

[Test]
public void NodeSuggestions_CanAutoCompleteInCustomNodeWorkspace()
{
Expand Down Expand Up @@ -151,7 +174,6 @@ public void NodeSuggestions_CanAutoCompleteOnCustomNodesOutPort()
}

[Test]
[Category("Failure")]
public void NodeSuggestions_CanAutoCompleteOnCustomNodesOutPort_WithSpaceInPortName()
{
var outputNode = new Dynamo.Graph.Nodes.CustomNodes.Output();
Expand All @@ -169,12 +191,11 @@ public void NodeSuggestions_CanAutoCompleteOnCustomNodesOutPort_WithSpaceInPortN

// Results will be nodes that accept Line as parameter.
searchViewModel.PopulateAutoCompleteCandidates();
var nodeNamesResultList = searchViewModel.FilteredResults.Select(x => x.Name).ToList();
var nodeNamesResultList = searchViewModel.FilteredResults.Select(x => x.FullName).ToList();

Assert.AreEqual(expectedNodes.Count(), nodeNamesResultList.Count(),string.Format("Missing nodes: {0} ", string.Join(", ",expectedNodes.Except(nodeNamesResultList))));
ValidateMissingAddedNodes(nodeNamesResultList, searchViewModel.dynamoViewModel.PreferenceSettings);
}
[Test]
[Category("Failure")]
public void NodeSuggestions_CanAutoCompleteOnCustomNodesOutPort_WithWhiteSpaceStartingPortName()
{
var outputNode = new Dynamo.Graph.Nodes.CustomNodes.Output();
Expand All @@ -192,9 +213,9 @@ public void NodeSuggestions_CanAutoCompleteOnCustomNodesOutPort_WithWhiteSpaceSt

// Results will be nodes that accept Line as parameter.
searchViewModel.PopulateAutoCompleteCandidates();
var nodeNamesResultList = searchViewModel.FilteredResults.Select(x => x.Name).ToList();
var nodeNamesResultList = searchViewModel.FilteredResults.Select(x => x.FullName).ToList();

Assert.AreEqual(expectedNodes.Count(), nodeNamesResultList.Count(), string.Format("Missing nodes: {0} ", string.Join(", ", expectedNodes.Except(nodeNamesResultList))));
ValidateMissingAddedNodes(nodeNamesResultList, searchViewModel.dynamoViewModel.PreferenceSettings);
}

[Test]
Expand Down Expand Up @@ -315,7 +336,6 @@ public void NodeSuggestions_InputPortBuiltInNode_AreCorrect()
}

[Test]
[Category("Failure")]
public void NodeSuggestions_OutputPortBuiltInNode_AreCorrect()
{
Open(@"UI\builtin_outputport_suggestion.dyn");
Expand All @@ -335,7 +355,10 @@ public void NodeSuggestions_OutputPortBuiltInNode_AreCorrect()
var searchViewModel = ViewModel.CurrentSpaceViewModel.NodeAutoCompleteSearchViewModel;
searchViewModel.PortViewModel = outPorts[0];
var suggestions = searchViewModel.GetMatchingSearchElements();
Assert.AreEqual(58, suggestions.Count());

var nodeNamesResultList = suggestions.Select(x => x.FullName).ToList();

ValidateMissingAddedNodes(nodeNamesResultList, searchViewModel.dynamoViewModel.PreferenceSettings);
}

[Test]
Expand Down
7 changes: 3 additions & 4 deletions test/DynamoCoreWpfTests/SearchSideEffects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ public void LuceneSearchNodesOrderingValidation()

//This test will validate that resulting nodes have a specific order when having T-Spline nodes in the nodes list.
[Test]
[Category("Failure")]
public void LuceneSearchTSplineNodesOrderingValidation()
{
Assert.IsAssignableFrom(typeof(HomeWorkspaceModel), ViewModel.Model.CurrentWorkspace);
Expand Down Expand Up @@ -248,11 +247,11 @@ public void LuceneSearchTSplineNodesOrderingValidation()
//Take the first 5 elements, get the ones that belong to the expected category and finally get the index in the list
firstCatExpectedNode = nodesResult.Take(5).ToList().FindIndex(x => x.Class.ToLower().Contains(searchTerms[1]));

//Validate that T-Spline nodes are not found in the results
//Validate that T-Spline nodes are not found in the top 5 results
Assert.That(firstTSpline == -1);

//Validate that the normal node (category Cone) will be at index 0 (first place)
Assert.That(firstCatExpectedNode == 0);
//Validate that the normal node (category Cone) will be at the first top 5 positions
Assert.That(firstCatExpectedNode >= 0 && firstCatExpectedNode < 5); ;

}

Expand Down

0 comments on commit 9fcf24a

Please sign in to comment.