Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Unsaved Changes Edge Case #11601

Merged
merged 2 commits into from
Apr 13, 2021
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
3 changes: 3 additions & 0 deletions src/DynamoCore/Graph/Workspaces/WorkspaceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,9 @@ internal void RemoveAndDisposeNode(NodeModel model, bool dispose = true)
}

OnNodeRemoved(model);
// Force this change to address the edge case that user deleting the right edge
// node and do not see unsaved changes, e.g. the watch node at end of the graph
HasUnsavedChanges = true;

if (dispose)
{
Expand Down
17 changes: 17 additions & 0 deletions test/DynamoCoreTests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,23 @@ public void UndoMoveDoesNotForceExecution()
Assert.IsFalse(sumNode.IsModified);
}

/// <summary>
/// This test is added to test if the HasUnsavedChanges can be set
/// correctly after node removal using an edge case
/// </summary>
[Test]
public void TestHasUnsavedChangesOnNodeRemovalEdgeCase()
{
string openPath = Path.Combine(TestDirectory, @"core\logic\comparison\testToleranceEquals_defaultTolerance.dyn");
OpenModel(openPath);
// Default state after graph open
Assert.AreEqual(false, CurrentDynamoModel.CurrentWorkspace.HasUnsavedChanges);
CurrentDynamoModel.CurrentWorkspace.RecordAndDeleteModels(
CurrentDynamoModel.CurrentWorkspace.Nodes.Where(x=>x.GUID.Equals(new Guid("c2f69bf434be47fa8f0a4a0ceca5910b"))).ToList<ModelBase>());
// Assert HasUnsavedChanges is true after a downstream node removal
Assert.AreEqual(true, CurrentDynamoModel.CurrentWorkspace.HasUnsavedChanges);
}

[Test]
public void TestFileDirtyOnLacingChange()
{
Expand Down