* Block level variance - initial commit * Remove TODOs * Only convert RTEs with blocks * Fix JSON paths for block level property validation * Rename Properties to Values * Correct the JSON path of block level validation errors * Make it possible to skip content migration + ensure backwards compat for the new block format * Partial culture variance publishing at property level * UDI to key conversion for block editors - draft, WIP, do NOT merge 😄 (#16970) * Convert block UDIs to GUIDs * Fix merge * Fix merge issues * Rework nested layout item key parsing for backwards compatibility * Clean-up * Reverse block layout item key calculation * Review * Use IOptions to skip content migrations * Remove "published" from data editor feature naming, as it can be used in other contexts too * Parallel migration * Don't use deprecated constructor * Ensure that layout follows structure for partial publishing * Block Grid element level variance + tests (incl. refactor of element level variation tests) * Rollback unintended changes to Program.cs * Fix bad casing * Minor formatting * RTE element level variance + tests * Remove obsoleted constructors * Use Umbraco.RichText instead of Umbraco.TinyMCE as layout alias for blocks in the RTE * Fix bad merge * Temporary fix for new cache in integration tests * Add EditorAlias to block level properties * Remove the unintended PropertyEditorAlias output for block values * Add EditorAlias to Datatype Item model * Update OpenApi.json * Introduce "expose" for blocks * Strict (explicit) handling for Expose * Improve handling of document and element level variance changes * Refactor variance alignment for published rendering * Block UDI to Key conversion should also register as a conversion * Convert newly added RTE unit test to new RTE blocks format * Minor review changes * Run memory intensive tests on Linux only * Add tests proving that AllowEditInvariantFromNonDefault has effect for block level variance too * Fix the Platform annotations * Removed Platform annotations for tests. * Fix merge * Obsolete old PublishCulture extension * More fixing bad merge --------- Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: nikolajlauridsen <nikolajlauridsen@protonmail.ch>
69 lines
2.8 KiB
C#
69 lines
2.8 KiB
C#
using Moq;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Models.PublishedContent;
|
|
using Umbraco.Cms.Core.PublishedCache;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.PropertyEditors;
|
|
|
|
public abstract class BlockPropertyValueConverterTestsBase<TPropertyEditorConfig>
|
|
{
|
|
protected abstract string PropertyEditorAlias { get; }
|
|
|
|
protected const string ContentAlias1 = "Test1";
|
|
protected const string ContentAlias2 = "Test2";
|
|
protected const string SettingAlias1 = "Setting1";
|
|
protected const string SettingAlias2 = "Setting2";
|
|
|
|
protected Guid ContentKey1 { get; } = Guid.NewGuid();
|
|
|
|
protected Guid ContentKey2 { get; } = Guid.NewGuid();
|
|
|
|
protected Guid SettingKey1 { get; } = Guid.NewGuid();
|
|
|
|
protected Guid SettingKey2 { get; } = Guid.NewGuid();
|
|
|
|
/// <summary>
|
|
/// Setup mocks for IPublishedSnapshotAccessor
|
|
/// </summary>
|
|
protected IPublishedSnapshotAccessor GetPublishedSnapshotAccessor()
|
|
{
|
|
var test1ContentType = Mock.Of<IPublishedContentType>(x =>
|
|
x.IsElement == true
|
|
&& x.Key == ContentKey1
|
|
&& x.Alias == ContentAlias1);
|
|
var test2ContentType = Mock.Of<IPublishedContentType>(x =>
|
|
x.IsElement == true
|
|
&& x.Key == ContentKey2
|
|
&& x.Alias == ContentAlias2);
|
|
var test3ContentType = Mock.Of<IPublishedContentType>(x =>
|
|
x.IsElement == true
|
|
&& x.Key == SettingKey1
|
|
&& x.Alias == SettingAlias1);
|
|
var test4ContentType = Mock.Of<IPublishedContentType>(x =>
|
|
x.IsElement == true
|
|
&& x.Key == SettingKey2
|
|
&& x.Alias == SettingAlias2);
|
|
var contentCache = new Mock<IPublishedContentCache>();
|
|
contentCache.Setup(x => x.GetContentType(ContentKey1)).Returns(test1ContentType);
|
|
contentCache.Setup(x => x.GetContentType(ContentKey2)).Returns(test2ContentType);
|
|
contentCache.Setup(x => x.GetContentType(SettingKey1)).Returns(test3ContentType);
|
|
contentCache.Setup(x => x.GetContentType(SettingKey2)).Returns(test4ContentType);
|
|
var publishedSnapshot = Mock.Of<IPublishedSnapshot>(x => x.Content == contentCache.Object);
|
|
var publishedSnapshotAccessor =
|
|
Mock.Of<IPublishedSnapshotAccessor>(x => x.TryGetPublishedSnapshot(out publishedSnapshot));
|
|
return publishedSnapshotAccessor;
|
|
}
|
|
|
|
protected IPublishedPropertyType GetPropertyType(TPropertyEditorConfig config)
|
|
{
|
|
var dataType = new PublishedDataType(1, "test", new Lazy<object>(() => config));
|
|
var propertyType = Mock.Of<IPublishedPropertyType>(x =>
|
|
x.EditorAlias == PropertyEditorAlias
|
|
&& x.DataType == dataType);
|
|
return propertyType;
|
|
}
|
|
|
|
protected IPublishedElement GetPublishedElement()
|
|
=> Mock.Of<IPublishedElement>(m => m.ContentType == Mock.Of<IPublishedContentType>());
|
|
}
|