From d87a84be14cc7a1759b5c06ed69827a9ee787f95 Mon Sep 17 00:00:00 2001 From: Sven Geusens Date: Mon, 17 Feb 2025 15:27:22 +0100 Subject: [PATCH] Loosen the RTEValue datacontract to improve migrations (#18349) --- .../Models/RichTextEditorValue.cs | 2 +- .../RichTextPropertyEditorHelperTests.cs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Infrastructure/Models/RichTextEditorValue.cs b/src/Umbraco.Infrastructure/Models/RichTextEditorValue.cs index 9904ea33bb..cf64747ec2 100644 --- a/src/Umbraco.Infrastructure/Models/RichTextEditorValue.cs +++ b/src/Umbraco.Infrastructure/Models/RichTextEditorValue.cs @@ -10,5 +10,5 @@ public class RichTextEditorValue public required string Markup { get; set; } [DataMember(Name = "blocks")] - public required RichTextBlockValue? Blocks { get; set; } + public RichTextBlockValue? Blocks { get; set; } } diff --git a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs index 8d2d59337f..ab68db550f 100644 --- a/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs +++ b/tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/RichTextPropertyEditorHelperTests.cs @@ -94,6 +94,22 @@ public class RichTextPropertyEditorHelperTests }); } + [Test] + public void Can_Parse_JObject_With_Missing_Blocks() + { + var input = JsonNode.Parse("""" + { + "markup": "

Vælg et af vores mest populære produkter

" + } + """"); + + var result = RichTextPropertyEditorHelper.TryParseRichTextEditorValue(input, JsonSerializer(), Logger(), out RichTextEditorValue? value); + Assert.IsTrue(result); + Assert.IsNotNull(value); + Assert.AreEqual("

Vælg et af vores mest populære produkter

", value.Markup); + Assert.IsNull(value.Blocks); + } + [Test] public void Can_Parse_Blocks_With_Both_Content_And_Settings() {