diff --git a/src/Umbraco.Core/Services/ContentEditingServiceBase.cs b/src/Umbraco.Core/Services/ContentEditingServiceBase.cs index 1f5c1dda9f..1c0c5f7ff6 100644 --- a/src/Umbraco.Core/Services/ContentEditingServiceBase.cs +++ b/src/Umbraco.Core/Services/ContentEditingServiceBase.cs @@ -458,7 +458,8 @@ internal abstract class ContentEditingServiceBase + { + Assert.IsTrue(result.Success); + Assert.AreEqual(ContentEditingOperationStatus.Success, result.Status); + Assert.IsNotNull(result.Result.Content); + }); + + // re-get and validate + content = await ContentEditingService.GetAsync(content.Key); + Assert.IsNotNull(content); + Assert.Multiple(() => + { + Assert.AreEqual("Updated Name", content.Name); + Assert.AreEqual("The initial label value", content.GetValue("label")); + }); + } + + [Test] + public async Task Cannot_Update_Variant_Readonly_Property_Value() + { + var content = await CreateVariantContent(); + content.SetValue("variantLabel", "The initial English label value", "en-US"); + content.SetValue("variantLabel", "The initial Danish label value", "da-DK"); + ContentService.Save(content); + + var updateModel = new ContentUpdateModel + { + InvariantProperties = new[] + { + new PropertyValueModel { Alias = "invariantTitle", Value = "The updated invariant title" } + }, + Variants = new [] + { + new VariantModel + { + Culture = "en-US", + Name = "Updated English Name", + Properties = new [] + { + new PropertyValueModel { Alias = "variantLabel", Value = "The updated English label value" } + } + }, + new VariantModel + { + Culture = "da-DK", + Name = "Updated Danish Name", + Properties = new [] + { + new PropertyValueModel { Alias = "variantLabel", Value = "The updated Danish label value" } + } + } + } + }; + + var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey); + Assert.Multiple(() => + { + Assert.IsTrue(result.Success); + Assert.AreEqual(ContentEditingOperationStatus.Success, result.Status); + Assert.IsNotNull(result.Result.Content); + }); + + // re-get and validate + content = await ContentEditingService.GetAsync(content.Key); + Assert.IsNotNull(content); + Assert.Multiple(() => + { + Assert.AreEqual("Updated English Name", content.GetCultureName("en-US")); + Assert.AreEqual("Updated Danish Name", content.GetCultureName("da-DK")); + Assert.AreEqual("The initial English label value", content.GetValue("variantLabel", "en-US")); + Assert.AreEqual("The initial Danish label value", content.GetValue("variantLabel", "da-DK")); + }); + } } diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEditingServiceTestsBase.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEditingServiceTestsBase.cs index a8c9eca84a..f9dd811f0f 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEditingServiceTestsBase.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentEditingServiceTestsBase.cs @@ -38,6 +38,13 @@ public abstract class ContentEditingServiceTestsBase : UmbracoIntegrationTestWit .WithAlias("text") .WithName("Text") .WithVariations(ContentVariation.Nothing) + .Done() + .AddPropertyType() + .WithAlias("label") + .WithName("Label") + .WithDataTypeId(Constants.DataTypes.LabelString) + .WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.Label) + .WithVariations(ContentVariation.Nothing) .Done(); foreach (var template in templates) @@ -83,6 +90,13 @@ public abstract class ContentEditingServiceTestsBase : UmbracoIntegrationTestWit .WithName("Invariant Title") .WithVariations(ContentVariation.Nothing) .Done() + .AddPropertyType() + .WithAlias("variantLabel") + .WithName("Variant Label") + .WithDataTypeId(Constants.DataTypes.LabelString) + .WithPropertyEditorAlias(Constants.PropertyEditors.Aliases.Label) + .WithVariations(ContentVariation.Culture) + .Done() .Build(); contentType.AllowedAsRoot = true; ContentTypeService.Save(contentType);