Block level variance (#17120)
* 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>
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models;
|
||||
[TestFixture]
|
||||
public class VariationTests
|
||||
{
|
||||
private readonly PropertyEditorCollection _propertyEditorCollection = new (new DataEditorCollection(() => []));
|
||||
|
||||
[Test]
|
||||
public void ValidateVariationTests()
|
||||
{
|
||||
@@ -315,7 +317,7 @@ public class VariationTests
|
||||
|
||||
// can publish value
|
||||
// and get edited and published values
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.All));
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.All, DateTime.Now, _propertyEditorCollection));
|
||||
Assert.AreEqual("a", content.GetValue("prop"));
|
||||
Assert.AreEqual("a", content.GetValue("prop", published: true));
|
||||
|
||||
@@ -345,9 +347,9 @@ public class VariationTests
|
||||
|
||||
// can publish value
|
||||
// and get edited and published values
|
||||
Assert.IsFalse(content.PublishCulture(CultureImpact.Explicit(langFr, false))); // no name
|
||||
Assert.IsFalse(content.PublishCulture(CultureImpact.Explicit(langFr, false), DateTime.Now, _propertyEditorCollection)); // no name
|
||||
content.SetCultureName("name-fr", langFr);
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.Explicit(langFr, false)));
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.Explicit(langFr, false), DateTime.Now, _propertyEditorCollection));
|
||||
Assert.IsNull(content.GetValue("prop"));
|
||||
Assert.IsNull(content.GetValue("prop", published: true));
|
||||
Assert.AreEqual("c", content.GetValue("prop", langFr));
|
||||
@@ -361,7 +363,7 @@ public class VariationTests
|
||||
Assert.IsNull(content.GetValue("prop", langFr, published: true));
|
||||
|
||||
// can publish all
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.All));
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.All, DateTime.Now, _propertyEditorCollection));
|
||||
Assert.IsNull(content.GetValue("prop"));
|
||||
Assert.IsNull(content.GetValue("prop", published: true));
|
||||
Assert.AreEqual("c", content.GetValue("prop", langFr));
|
||||
@@ -371,14 +373,14 @@ public class VariationTests
|
||||
content.UnpublishCulture(langFr);
|
||||
Assert.AreEqual("c", content.GetValue("prop", langFr));
|
||||
Assert.IsNull(content.GetValue("prop", langFr, published: true));
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.Explicit(langFr, false)));
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.Explicit(langFr, false), DateTime.Now, _propertyEditorCollection));
|
||||
Assert.AreEqual("c", content.GetValue("prop", langFr));
|
||||
Assert.AreEqual("c", content.GetValue("prop", langFr, published: true));
|
||||
|
||||
content.UnpublishCulture(); // clears invariant props if any
|
||||
Assert.IsNull(content.GetValue("prop"));
|
||||
Assert.IsNull(content.GetValue("prop", published: true));
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.All)); // publishes invariant props if any
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.All, DateTime.Now, _propertyEditorCollection)); // publishes invariant props if any
|
||||
Assert.IsNull(content.GetValue("prop"));
|
||||
Assert.IsNull(content.GetValue("prop", published: true));
|
||||
|
||||
@@ -437,19 +439,19 @@ public class VariationTests
|
||||
var langFrImpact = CultureImpact.Explicit(langFr, true);
|
||||
|
||||
Assert.IsTrue(
|
||||
content.PublishCulture(langFrImpact)); // succeeds because names are ok (not validating properties here)
|
||||
content.PublishCulture(langFrImpact, DateTime.Now, _propertyEditorCollection)); // succeeds because names are ok (not validating properties here)
|
||||
Assert.IsFalse(
|
||||
propertyValidationService.IsPropertyDataValid(content, out _, langFrImpact)); // fails because prop1 is mandatory
|
||||
|
||||
content.SetValue("prop1", "a", langFr);
|
||||
Assert.IsTrue(
|
||||
content.PublishCulture(langFrImpact)); // succeeds because names are ok (not validating properties here)
|
||||
content.PublishCulture(langFrImpact, DateTime.Now, _propertyEditorCollection)); // succeeds because names are ok (not validating properties here)
|
||||
|
||||
// Fails because prop2 is mandatory and invariant and the item isn't published.
|
||||
// Invariant is validated against the default language except when there isn't a published version, in that case it's always validated.
|
||||
Assert.IsFalse(propertyValidationService.IsPropertyDataValid(content, out _, langFrImpact));
|
||||
content.SetValue("prop2", "x");
|
||||
Assert.IsTrue(content.PublishCulture(langFrImpact)); // still ok...
|
||||
Assert.IsTrue(content.PublishCulture(langFrImpact, DateTime.Now, _propertyEditorCollection)); // still ok...
|
||||
Assert.IsTrue(propertyValidationService.IsPropertyDataValid(content, out _, langFrImpact)); // now it's ok
|
||||
|
||||
Assert.AreEqual("a", content.GetValue("prop1", langFr, published: true));
|
||||
@@ -485,12 +487,12 @@ public class VariationTests
|
||||
content.SetValue("prop", "a-es", langEs);
|
||||
|
||||
// cannot publish without a name
|
||||
Assert.IsFalse(content.PublishCulture(CultureImpact.Explicit(langFr, false)));
|
||||
Assert.IsFalse(content.PublishCulture(CultureImpact.Explicit(langFr, false), DateTime.Now, _propertyEditorCollection));
|
||||
|
||||
// works with a name
|
||||
// and then FR is available, and published
|
||||
content.SetCultureName("name-fr", langFr);
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.Explicit(langFr, false)));
|
||||
Assert.IsTrue(content.PublishCulture(CultureImpact.Explicit(langFr, false), DateTime.Now, _propertyEditorCollection));
|
||||
|
||||
// now UK is available too
|
||||
content.SetCultureName("name-uk", langUk);
|
||||
|
||||
Reference in New Issue
Block a user