* Only prevent the unpublish or delete of a related item when configured to do so if it is related as a child, not as a parent (#18886) * Only prevent the unpubkish or delete of a related item when configured to do so if it is related as a child, not as a parent. * Fixed incorect parameter names. * Fixed failing integration tests. * Use using variable instead to reduce nesting * Applied suggestions from code review. * Used simple using statement throughout RelationService for consistency. * Applied XML header comments consistently. --------- Co-authored-by: mole <nikolajlauridsen@protonmail.ch> * Feature: highlight invariant doc with variant blocks is unsupported (#18806) * mark variant blocks in invariant docs as invalid * implement RTE Blocks * Fix pagination for users restricted by start nodes (#18907) * Fix pagination for users restricted by start nodes * Default implementation to avoid breakage * Review comments * Fix failing test * Add media start node tests * Fix issue preventing blueprint derived values from being scaffolded (#18917) * Fix issue preventing blueprint derived values from being scaffolded. * fix manipulating frooen array * compare with variantId as well --------- Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> * ci: add Azure Static Web Apps workflow file on-behalf-of: @Azure opensource@microsoft.com * ci: add Azure Static Web Apps workflow file on-behalf-of: @Azure opensource@microsoft.com * ci: add Azure Static Web Apps workflow file on-behalf-of: @Azure opensource@microsoft.com * Remove admin permission on user configuration, allowing users with user section access only to manaage users and groups. (#18848) * Tiptap RTE: Style Menu extension kind (#18918) * Adds 'styleMenu' Tiptap toolbar extension kind * Adds icons for `<h4>` and `<p>` tags * Adds commands to HTML Global Attributes extension for setting the `class` and `id` attributes. * Renamed "default-tiptap-toolbar-element.api.ts" file The "element" part was confusing. * Toolbar Menu: uses correct `item` value * Cascading Menu: adds localization for the label * Adds `label` attribute to UUI components for accessibility. * Toolbar Menu: uses correct `appearance` value * Removed unrequired `api` from Style Select * Destructs the `item.data` object * Ensure has children reflects only items with folder children when folders only are queried. (#18790) * Ensure has children reflects only items with folder children when folders only are queried. * Added supression for change to integration test public code. --------- Co-authored-by: Migaroez <geusens@gmail.com> * Only apply validation on content update to variant cultures where the editor has permission for the culture (#18778) * Only apply validation on content update to variant cultures where the editor has permission for the culture. * Remove inadvertent comment updates. * Fixed failing integration test. * Adds ancestor ID details on document tree and collection responses (#18909) * Populate ancestor keys on document tree response items. * Populate ancestor keys on document collection response items. * Update OpenApi.json * Use array of objects rather than Ids for the ancestor collection. * Update OpenApi.json. * Move publish with descendants to a background task with polling (#18497) * Use background queue for database cache rebuild and track rebuilding status. * Updated OpenApi.json and client-side types. * Updated client to poll for completion of database rebuild. * Move IBackgroundTaskQueue to core and prepare publish branch to run as background task. * Endpoints for retrieval of status and result from branch publish operations. * Poll and retrieve result for publish with descendants. * Handled issues from testing. * Rework to single controller for status and result. * Updated client side sdk. * OpenApi post dev merge gen --------- Co-authored-by: Migaroez <geusens@gmail.com> * Clear roots before rebuilding navigation dictionary (#18766) * Clear roots before rebuilding navigation dictionary. * Added tests to verify fix. * Correct test implementation. * Convert integration tests with method overloads into test cases. * Integration test compatibility supressions. * Fixes save of empty, invariant block list on variant content. (#18932) * remove unnecessary code (#18927) * V15/bugfix/fix route issue from 18859 (#18931) * unique check * unique for workspace empty path * more unique routes * Bump vite from 6.2.3 to 6.2.4 in /src/Umbraco.Web.UI.Client Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.3 to 6.2.4. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.2.4/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.2.4/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.2.4 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * removes autogenerated workflows * make getHasUnpersistedChanges public (#18929) * Added management API endpoint, service and repository for retrieval of references from the recycle bin (#18882) * Added management API endpoint, service and repository for retrieval of references from the recycle bin. * Update src/Umbraco.Cms.Api.Management/Controllers/Document/RecycleBin/ReferencedByDocumentRecycleBinController.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Removed unused code. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Updated management API endpoint and model for data type references to align with that used for documents, media etc. (#18905) * Updated management API endpoint and model for data type references to align with that used for documents, media etc. * Refactoring. * Update src/Umbraco.Core/Constants-ReferenceTypes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed typos. * Added id to tracked reference content type response. * Updated OpenApi.json. * Added missing updates. * Renamed model and constants from code review feedback. * Fix typo * Fix multiple enumeration --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: mole <nikolajlauridsen@protonmail.ch> * Skip lock tests * Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined (#18763) * Look-up redirect in content finder for multi-lingual sites using path and legacy route prefixed with the integer ID of the node with domains defined. * Added tests to verify functionality. * Added reference to previous PR. * Referenced second PR. * Assemble URLs for all cultures, not just the default. * Revert previous update. * Display an original URL if we have one. * Bump vite from 6.2.4 to 6.2.5 in /src/Umbraco.Web.UI.Client Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.2.4 to 6.2.5. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v6.2.5/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v6.2.5/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-version: 6.2.5 dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> * Add raw value validation to multiple text strings property editor (#18936) * Add raw value validation to multiple text strings property editor * Added additional assert on unit test and comment on validation logic. * Don't remove items to obtain a valid value --------- Co-authored-by: Andy Butland <abutland73@gmail.com> * Integration tests for content publishing with ancestor unpublished (#18941) * Resolved warnings in test class. * Refactor regions into partial classes. * Aligned test names. * Variable name refactoring. * Added tests for unpublished paths. * Adjust tests to verify current behaviour. * Cleaned up project file. * fix circular icon import (#18952) * remove segment toggle for elements (#18949) * Fix modal route registration circular import (#18953) * fix modal route registration circular import * Update modal-route-registration.controller.ts * V15/fix/18595 (#18925) * fix for #18595 * updates the en.ts * Avoid unneeded Dictionary operations (#18890) * Avoid some heap allocations * Remove unneeded double seek * Avoid allocating new empty arrays, reuse existing empty array * Avoid allocating strings for parsing comma separated int values (#18199) * Data type References UI: Workspace + Delete (#18914) * Updated management API endpoint and model for data type references to align with that used for documents, media etc. * Refactoring. * Update src/Umbraco.Core/Constants-ReferenceTypes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed typos. * generate server models * add extension slot * register data type reference info app * add reference data mappers * Added id to tracked reference content type response. * Updated OpenApi.json. * Added missing updates. * generate new models * update models * register ref item * remove debugger * render types * register member type property type ref * register media type property type ref * Renamed model and constants from code review feedback. * register reference workspace info app kind * use kind for document references * use kind for media references * use kind for member references * use deleteWithRelation kind when deleting data types * fix manifest types * fix types * Update types.gen.ts * update code to fit new server models --------- Co-authored-by: Andy Butland <abutland73@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Feature: discard changes for block workspace (#18930) * make getHasUnpersistedChanges public * Discard changes impl for Block Workspace * fix 18367 (#18956) * Merge commit from fork * Prevent path traveral vulnerability with upload of temporary files. * Used BadRequest instead of NotFound for invalid file name response. * V15 QA Fixing the failing media acceptance tests (#18881) * Fixed the function name due to test helper changes * Updated assertion steps due to UI changes * Added more waits * Bumped version * Increase timeout * Reverted --------- Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com> * V15 QA added clipboard test for not being able to copy to root when block is not allowed at root (#18937) * Added clipboard test * Bumped version * Updated to use the name * Run all tests on the pipeline * Reverted command * build: adjusts circular ref number to 4 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Andy Butland <abutland73@gmail.com> Co-authored-by: mole <nikolajlauridsen@protonmail.ch> Co-authored-by: Niels Lyngsø <nsl@umbraco.dk> Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com> Co-authored-by: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Co-authored-by: Lee Kelleher <leekelleher@users.noreply.github.com> Co-authored-by: Migaroez <geusens@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Co-authored-by: Mads Rasmussen <madsr@hey.com> Co-authored-by: Jacob Welander Jensen <64834767+Welander1994@users.noreply.github.com> Co-authored-by: Henrik <hg@impact.dk> Co-authored-by: Sebastiaan Janssen <sebastiaan@umbraco.com> Co-authored-by: Nhu Dinh <150406148+nhudinh0309@users.noreply.github.com> Co-authored-by: Andreas Zerbst <73799582+andr317c@users.noreply.github.com>
431 lines
17 KiB
C#
431 lines
17 KiB
C#
using NUnit.Framework;
|
|
using Umbraco.Cms.Core;
|
|
using Umbraco.Cms.Core.Models;
|
|
using Umbraco.Cms.Core.Models.ContentEditing;
|
|
using Umbraco.Cms.Core.Services.OperationStatus;
|
|
using Umbraco.Cms.Tests.Common.Builders;
|
|
using Umbraco.Cms.Tests.Common.Builders.Extensions;
|
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services;
|
|
|
|
public partial class ContentEditingServiceTests
|
|
{
|
|
[Test]
|
|
public async Task Can_Update_Invariant()
|
|
{
|
|
var content = await CreateInvariantContent();
|
|
|
|
var updateModel = new ContentUpdateModel
|
|
{
|
|
InvariantName = "Updated Name",
|
|
InvariantProperties = new[]
|
|
{
|
|
new PropertyValueModel { Alias = "title", Value = "The updated title" },
|
|
new PropertyValueModel { Alias = "text", Value = "The updated text" }
|
|
}
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.Success, result.Status);
|
|
VerifyUpdate(result.Result.Content);
|
|
|
|
// re-get and re-test
|
|
VerifyUpdate(await ContentEditingService.GetAsync(content.Key));
|
|
|
|
void VerifyUpdate(IContent? updatedContent)
|
|
{
|
|
Assert.IsNotNull(updatedContent);
|
|
Assert.AreEqual("Updated Name", updatedContent.Name);
|
|
Assert.AreEqual("The updated title", updatedContent.GetValue<string>("title"));
|
|
Assert.AreEqual("The updated text", updatedContent.GetValue<string>("text"));
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Update_Variant()
|
|
{
|
|
var content = await CreateVariantContent();
|
|
|
|
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 = "variantTitle", Value = "The updated English title" }
|
|
}
|
|
},
|
|
new VariantModel
|
|
{
|
|
Culture = "da-DK",
|
|
Name = "Updated Danish Name",
|
|
Properties = new []
|
|
{
|
|
new PropertyValueModel { Alias = "variantTitle", Value = "The updated Danish title" }
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.Success, result.Status);
|
|
VerifyUpdate(result.Result.Content);
|
|
|
|
// re-get and re-test
|
|
VerifyUpdate(await ContentEditingService.GetAsync(content.Key));
|
|
|
|
void VerifyUpdate(IContent? updatedContent)
|
|
{
|
|
Assert.IsNotNull(updatedContent);
|
|
Assert.AreEqual("Updated English Name", updatedContent.GetCultureName("en-US"));
|
|
Assert.AreEqual("Updated Danish Name", updatedContent.GetCultureName("da-DK"));
|
|
Assert.AreEqual("The updated invariant title", updatedContent.GetValue<string>("invariantTitle"));
|
|
Assert.AreEqual("The updated English title", updatedContent.GetValue<string>("variantTitle", "en-US"));
|
|
Assert.AreEqual("The updated Danish title", updatedContent.GetValue<string>("variantTitle", "da-DK"));
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Update_Template()
|
|
{
|
|
var templateOne = new TemplateBuilder().WithAlias("textPageOne").WithName("Text page one").Build();
|
|
var templateTwo = new TemplateBuilder().WithAlias("textPageTwo").WithName("Text page two").Build();
|
|
await TemplateService.CreateAsync(templateOne, Constants.Security.SuperUserKey);
|
|
await TemplateService.CreateAsync(templateTwo, Constants.Security.SuperUserKey);
|
|
|
|
var content = await CreateInvariantContent(templateOne, templateTwo);
|
|
Assert.AreEqual(templateOne.Id, content.TemplateId);
|
|
|
|
var updateModel = new ContentUpdateModel
|
|
{
|
|
InvariantName = "Updated Name",
|
|
TemplateKey = templateTwo.Key
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
VerifyUpdate(result.Result.Content);
|
|
|
|
// re-get and re-test
|
|
VerifyUpdate(await ContentEditingService.GetAsync(content.Key));
|
|
|
|
void VerifyUpdate(IContent? updatedContent)
|
|
{
|
|
Assert.IsNotNull(updatedContent);
|
|
Assert.AreEqual("Updated Name", updatedContent.Name);
|
|
Assert.AreEqual(templateTwo.Id, updatedContent.TemplateId);
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Remove_Template()
|
|
{
|
|
var templateOne = new TemplateBuilder().WithAlias("textPageOne").WithName("Text page one").Build();
|
|
await TemplateService.CreateAsync(templateOne, Constants.Security.SuperUserKey);
|
|
|
|
var content = await CreateInvariantContent(templateOne);
|
|
Assert.AreEqual(templateOne.Id, content.TemplateId);
|
|
|
|
var updateModel = new ContentUpdateModel
|
|
{
|
|
InvariantName = "Updated Name",
|
|
TemplateKey = null
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
VerifyUpdate(result.Result.Content);
|
|
|
|
// re-get and re-test
|
|
VerifyUpdate(await ContentEditingService.GetAsync(content.Key));
|
|
|
|
void VerifyUpdate(IContent? updatedContent)
|
|
{
|
|
Assert.IsNotNull(updatedContent);
|
|
Assert.AreEqual("Updated Name", updatedContent.Name);
|
|
Assert.AreEqual(null, updatedContent.TemplateId);
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public async Task Can_Remove_Property_Value()
|
|
{
|
|
var content = await CreateInvariantContent();
|
|
|
|
var updateModel = new ContentUpdateModel
|
|
{
|
|
InvariantName = "Updated Name",
|
|
InvariantProperties = new[]
|
|
{
|
|
new PropertyValueModel { Alias = "title", Value = "The updated title" }
|
|
}
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
Assert.IsTrue(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.Success, result.Status);
|
|
VerifyUpdate(result.Result.Content);
|
|
|
|
// re-get and re-test
|
|
VerifyUpdate(await ContentEditingService.GetAsync(content.Key));
|
|
|
|
void VerifyUpdate(IContent? updatedContent)
|
|
{
|
|
Assert.IsNotNull(updatedContent);
|
|
Assert.AreEqual("Updated Name", updatedContent.Name);
|
|
Assert.AreEqual("The updated title", updatedContent.GetValue<string>("title"));
|
|
Assert.AreEqual(null, updatedContent.GetValue<string>("text"));
|
|
}
|
|
}
|
|
|
|
[TestCase(true)]
|
|
[TestCase(false)]
|
|
public async Task Can_Update_With_Property_Validation(bool addValidProperties)
|
|
{
|
|
var content = await CreateInvariantContent();
|
|
var contentType = await ContentTypeService.GetAsync(content.ContentType.Key)!;
|
|
contentType.PropertyTypes.First(pt => pt.Alias == "title").Mandatory = true;
|
|
contentType.PropertyTypes.First(pt => pt.Alias == "text").ValidationRegExp = "^\\d*$";
|
|
await ContentTypeService.SaveAsync(contentType, Constants.Security.SuperUserKey);
|
|
|
|
var titleValue = addValidProperties ? "The title value" : null;
|
|
var textValue = addValidProperties ? "12345" : "This is not a number";
|
|
|
|
var updateModel = new ContentUpdateModel
|
|
{
|
|
InvariantName = content.Name,
|
|
InvariantProperties = new[]
|
|
{
|
|
new PropertyValueModel { Alias = "title", Value = titleValue },
|
|
new PropertyValueModel { Alias = "text", Value = textValue }
|
|
}
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
|
|
// success is expected regardless of property level validation - the validation error status is communicated in the attempt status (see below)
|
|
Assert.IsTrue(result.Success);
|
|
Assert.AreEqual(addValidProperties ? ContentEditingOperationStatus.Success : ContentEditingOperationStatus.PropertyValidationError, result.Status);
|
|
Assert.IsNotNull(result.Result);
|
|
|
|
if (addValidProperties is false)
|
|
{
|
|
Assert.AreEqual(2, result.Result.ValidationResult.ValidationErrors.Count());
|
|
Assert.IsNotNull(result.Result.ValidationResult.ValidationErrors.FirstOrDefault(v => v.Alias == "title" && v.ErrorMessages.Length == 1));
|
|
Assert.IsNotNull(result.Result.ValidationResult.ValidationErrors.FirstOrDefault(v => v.Alias == "text" && v.ErrorMessages.Length == 1));
|
|
}
|
|
|
|
// NOTE: content update must be successful, even if the mandatory property is missing (publishing however should not!)
|
|
Assert.AreEqual(titleValue, result.Result.Content!.GetValue<string>("title"));
|
|
Assert.AreEqual(textValue, result.Result.Content!.GetValue<string>("text"));
|
|
}
|
|
|
|
[Test]
|
|
public async Task Cannot_Update_With_Variant_Property_Value_For_Invariant_Content()
|
|
{
|
|
var content = await CreateInvariantContent();
|
|
|
|
var updateModel = new ContentUpdateModel
|
|
{
|
|
InvariantName = "Updated Name",
|
|
InvariantProperties = new[]
|
|
{
|
|
new PropertyValueModel { Alias = "title", Value = "The updated title" },
|
|
},
|
|
Variants = new[]
|
|
{
|
|
new VariantModel
|
|
{
|
|
Culture = "en-US",
|
|
Name = "Updated English Name",
|
|
Properties = new[]
|
|
{
|
|
new PropertyValueModel { Alias = "text", Value = "The updated text" }
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.ContentTypeCultureVarianceMismatch, result.Status);
|
|
|
|
// re-get and validate
|
|
content = await ContentEditingService.GetAsync(content.Key);
|
|
Assert.IsNotNull(content);
|
|
Assert.AreEqual("Initial Name", content.Name);
|
|
Assert.AreEqual("The initial title", content.GetValue<string>("title"));
|
|
Assert.AreEqual("The initial text", content.GetValue<string>("text"));
|
|
}
|
|
|
|
[Test]
|
|
public async Task Cannot_Update_With_Invariant_Property_Value_For_Variant_Content()
|
|
{
|
|
var content = await CreateVariantContent();
|
|
|
|
var updateModel = new ContentUpdateModel
|
|
{
|
|
InvariantName = "Updated Name",
|
|
InvariantProperties = new[]
|
|
{
|
|
new PropertyValueModel { Alias = "invariantTitle", Value = "The updated invariant title" },
|
|
new PropertyValueModel { Alias = "variantTitle", Value = "The updated variant title" }
|
|
}
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.PropertyTypeNotFound, result.Status);
|
|
Assert.IsNotNull(result.Result.Content);
|
|
|
|
// re-get and validate
|
|
content = await ContentEditingService.GetAsync(content.Key);
|
|
Assert.IsNotNull(content);
|
|
Assert.AreEqual("Initial English Name", content.GetCultureName("en-US"));
|
|
Assert.AreEqual("The initial invariant title", content.GetValue<string>("invariantTitle"));
|
|
Assert.AreEqual("The initial English title", content.GetValue<string>("variantTitle", "en-US"));
|
|
Assert.AreEqual("The initial Danish title", content.GetValue<string>("variantTitle", "da-DK"));
|
|
}
|
|
|
|
[Test]
|
|
public async Task Cannot_Update_Variant_With_Incorrect_Culture_Casing()
|
|
{
|
|
var content = await CreateVariantContent();
|
|
|
|
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 = "variantTitle", Value = "The updated English title" }
|
|
}
|
|
},
|
|
new VariantModel
|
|
{
|
|
Culture = "da-dk",
|
|
Name = "Updated Danish Name",
|
|
Properties = new []
|
|
{
|
|
new PropertyValueModel { Alias = "variantTitle", Value = "The updated Danish title" }
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var result = await ContentEditingService.UpdateAsync(content.Key, updateModel, Constants.Security.SuperUserKey);
|
|
Assert.IsFalse(result.Success);
|
|
Assert.AreEqual(ContentEditingOperationStatus.InvalidCulture, result.Status);
|
|
}
|
|
|
|
[Test]
|
|
public async Task Cannot_Update_Invariant_Readonly_Property_Value()
|
|
{
|
|
var content = await CreateInvariantContent();
|
|
content.SetValue("label", "The initial label value");
|
|
ContentService.Save(content);
|
|
|
|
var updateModel = new ContentUpdateModel
|
|
{
|
|
InvariantName = "Updated Name",
|
|
InvariantProperties = new[]
|
|
{
|
|
new PropertyValueModel { Alias = "title", Value = "The initial title" },
|
|
new PropertyValueModel { Alias = "label", Value = "The updated 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 Name", content.Name);
|
|
Assert.AreEqual("The initial label value", content.GetValue<string>("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 = "variantTitle", Value = "The initial English title" },
|
|
new PropertyValueModel { Alias = "variantLabel", Value = "The updated English label value" }
|
|
}
|
|
},
|
|
new VariantModel
|
|
{
|
|
Culture = "da-DK",
|
|
Name = "Updated Danish Name",
|
|
Properties = new []
|
|
{
|
|
new PropertyValueModel { Alias = "variantTitle", Value = "The initial Danish title" },
|
|
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<string>("variantLabel", "en-US"));
|
|
Assert.AreEqual("The initial Danish label value", content.GetValue<string>("variantLabel", "da-DK"));
|
|
});
|
|
}
|
|
}
|