Backport relation tracking fixes and get references from recursive (nested/block) properties (#15593)
* Include automatic relation type aliases from factory and fix SQL parameter overflow (#15141)
* Include automatic relation type aliases from factory
* Remove unnessecary distinct and fix SQL parameter overflow issue
* Fixed assertions and test distinct aliases
* Simplified collection assertions
* Improve logging of invalid reference relations (#15160)
* Include automatic relation type aliases from factory
* Remove unnessecary distinct and fix SQL parameter overflow issue
* Fixed assertions and test distinct aliases
* Simplified collection assertions
* Improve logging of invalid reference relations
* Always get all automatic relation type aliases
* Do not set relation type alias for unknown entity types
* Get references from recursive (nested/block) properties
(cherry picked from commit 5198e7c52d)
This commit is contained in:
committed by
Bjarke Berg
parent
a70c606c27
commit
ce22315520
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@@ -15,6 +14,7 @@ public class DataValueEditorReuseTests
|
||||
{
|
||||
private Mock<IDataValueEditorFactory> _dataValueEditorFactoryMock;
|
||||
private PropertyEditorCollection _propertyEditorCollection;
|
||||
private DataValueReferenceFactoryCollection _dataValueReferenceFactories;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
@@ -31,6 +31,7 @@ public class DataValueEditorReuseTests
|
||||
Mock.Of<IIOHelper>()));
|
||||
|
||||
_propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>));
|
||||
_dataValueReferenceFactories = new DataValueReferenceFactoryCollection(Enumerable.Empty<IDataValueReferenceFactory>);
|
||||
|
||||
_dataValueEditorFactoryMock
|
||||
.Setup(m =>
|
||||
@@ -38,6 +39,7 @@ public class DataValueEditorReuseTests
|
||||
.Returns(() => new BlockListPropertyEditorBase.BlockListEditorPropertyValueEditor(
|
||||
new DataEditorAttribute("a", "b", "c"),
|
||||
_propertyEditorCollection,
|
||||
_dataValueReferenceFactories,
|
||||
Mock.Of<IDataTypeService>(),
|
||||
Mock.Of<IContentTypeService>(),
|
||||
Mock.Of<ILocalizedTextService>(),
|
||||
@@ -93,7 +95,7 @@ public class DataValueEditorReuseTests
|
||||
{
|
||||
var blockListPropertyEditor = new BlockListPropertyEditor(
|
||||
_dataValueEditorFactoryMock.Object,
|
||||
new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>)),
|
||||
_propertyEditorCollection,
|
||||
Mock.Of<IIOHelper>(),
|
||||
Mock.Of<IEditorConfigurationParser>(),
|
||||
Mock.Of<IBlockValuePropertyIndexValueFactory>());
|
||||
@@ -114,7 +116,7 @@ public class DataValueEditorReuseTests
|
||||
{
|
||||
var blockListPropertyEditor = new BlockListPropertyEditor(
|
||||
_dataValueEditorFactoryMock.Object,
|
||||
new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>)),
|
||||
_propertyEditorCollection,
|
||||
Mock.Of<IIOHelper>(),
|
||||
Mock.Of<IEditorConfigurationParser>(),
|
||||
Mock.Of<IBlockValuePropertyIndexValueFactory>());
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core;
|
||||
@@ -173,6 +171,33 @@ public class DataValueReferenceFactoryCollectionTests
|
||||
Assert.AreEqual(trackedUdi4, result.ElementAt(1).Udi.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAutomaticRelationTypesAliases_ContainsDefault()
|
||||
{
|
||||
var collection = new DataValueReferenceFactoryCollection(Enumerable.Empty<IDataValueReferenceFactory>);
|
||||
var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<IDataEditor>));
|
||||
|
||||
var result = collection.GetAllAutomaticRelationTypesAliases(propertyEditors).ToArray();
|
||||
|
||||
var expected = Constants.Conventions.RelationTypes.AutomaticRelationTypes;
|
||||
CollectionAssert.AreEquivalent(expected, result, "Result does not contain the expected relation type aliases.");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAutomaticRelationTypesAliases_ContainsCustom()
|
||||
{
|
||||
var collection = new DataValueReferenceFactoryCollection(() => new TestDataValueReferenceFactory().Yield());
|
||||
|
||||
var labelPropertyEditor = new LabelPropertyEditor(DataValueEditorFactory, IOHelper, EditorConfigurationParser);
|
||||
var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(() => labelPropertyEditor.Yield()));
|
||||
var serializer = new ConfigurationEditorJsonSerializer();
|
||||
|
||||
var result = collection.GetAllAutomaticRelationTypesAliases(propertyEditors).ToArray();
|
||||
|
||||
var expected = Constants.Conventions.RelationTypes.AutomaticRelationTypes.Append("umbTest");
|
||||
CollectionAssert.AreEquivalent(expected, result, "Result does not contain the expected relation type aliases.");
|
||||
}
|
||||
|
||||
private class TestDataValueReferenceFactory : IDataValueReferenceFactory
|
||||
{
|
||||
public IDataValueReference GetDataValueReference() => new TestMediaDataValueReference();
|
||||
@@ -196,6 +221,12 @@ public class DataValueReferenceFactoryCollectionTests
|
||||
yield return new UmbracoEntityReference(udi);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAutomaticRelationTypesAliases() => new[]
|
||||
{
|
||||
"umbTest",
|
||||
"umbTest", // Duplicate on purpose to test distinct aliases
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user