Merge branch 'main' into v17/dev
# Conflicts: # src/Umbraco.Core/Services/DataTypeService.cs
This commit is contained in:
@@ -81,6 +81,9 @@ internal sealed class PublishContentTypeFactoryTest : UmbracoIntegrationTest
|
||||
{
|
||||
var dataType = new DataTypeBuilder()
|
||||
.WithId(0)
|
||||
.AddEditor()
|
||||
.WithAlias(Constants.PropertyEditors.Aliases.TextBox)
|
||||
.Done()
|
||||
.Build();
|
||||
dataType.EditorUiAlias = "NotUpdated";
|
||||
var dataTypeCreateResult = await DataTypeService.CreateAsync(dataType, Constants.Security.SuperUserKey);
|
||||
|
||||
@@ -690,7 +690,7 @@ internal sealed class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Get_Scheduled_Content_Keys()
|
||||
public void Can_Get_Content_Schedules_By_Keys()
|
||||
{
|
||||
// Arrange
|
||||
var root = ContentService.GetById(Textpage.Id);
|
||||
@@ -701,11 +701,12 @@ internal sealed class ContentServiceTests : UmbracoIntegrationTestWithContent
|
||||
ContentService.Publish(content, content.AvailableCultures.ToArray());
|
||||
|
||||
// Act
|
||||
var keys = ContentService.GetScheduledContentKeys([Textpage.Key, Subpage.Key, Subpage2.Key]).ToList();
|
||||
var keys = ContentService.GetContentSchedulesByIds([Textpage.Key, Subpage.Key, Subpage2.Key]).ToList();
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(1, keys.Count);
|
||||
Assert.AreEqual(Subpage.Key, keys.First());
|
||||
Assert.AreEqual(keys[0].Key, Subpage.Id);
|
||||
Assert.AreEqual(keys[0].Value.First().Id, contentSchedule.FullSchedule.First().Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
@@ -19,29 +20,41 @@ internal sealed class MediaEditingServiceTests : UmbracoIntegrationTest
|
||||
|
||||
protected IMediaType ImageMediaType { get; set; }
|
||||
|
||||
protected IMediaType ArticleMediaType { get; set; }
|
||||
|
||||
[SetUp]
|
||||
public async Task Setup()
|
||||
{
|
||||
ImageMediaType = MediaTypeService.Get(Constants.Conventions.MediaTypes.Image);
|
||||
ArticleMediaType = MediaTypeService.Get(Constants.Conventions.MediaTypes.ArticleAlias);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Cannot_Create_Media_With_Mandatory_Property()
|
||||
public async Task Cannot_Create_Media_With_Mandatory_File_Property_Without_Providing_File()
|
||||
{
|
||||
var imageModel = CreateMediaCreateModel("Image", new Guid(), ImageMediaType.Key);
|
||||
var imageModel = CreateMediaCreateModel("Image", Guid.NewGuid(), ImageMediaType.Key);
|
||||
var imageCreateAttempt = await MediaEditingService.CreateAsync(imageModel, Constants.Security.SuperUserKey);
|
||||
|
||||
// Assert
|
||||
Assert.IsFalse(imageCreateAttempt.Success);
|
||||
Assert.AreEqual(ContentEditingOperationStatus.PropertyValidationError, imageCreateAttempt.Status);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Can_Create_Media_Without_Mandatory_Property()
|
||||
public async Task Can_Create_Media_With_Mandatory_File_Property_With_File_Provided()
|
||||
{
|
||||
ImageMediaType.PropertyTypes.First(x => x.Alias == "umbracoFile").Mandatory = false;
|
||||
var imageModel = CreateMediaCreateModelWithFile("Image", Guid.NewGuid(), ArticleMediaType.Key);
|
||||
var imageCreateAttempt = await MediaEditingService.CreateAsync(imageModel, Constants.Security.SuperUserKey);
|
||||
|
||||
Assert.IsTrue(imageCreateAttempt.Success);
|
||||
Assert.AreEqual(ContentEditingOperationStatus.Success, imageCreateAttempt.Status);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Can_Create_Media_With_Optional_File_Property_Without_Providing_File()
|
||||
{
|
||||
ImageMediaType.PropertyTypes.First(x => x.Alias == Constants.Conventions.Media.File).Mandatory = false;
|
||||
MediaTypeService.Save(ImageMediaType);
|
||||
var imageModel = CreateMediaCreateModel("Image", new Guid(), ImageMediaType.Key);
|
||||
var imageModel = CreateMediaCreateModel("Image", Guid.NewGuid(), ImageMediaType.Key);
|
||||
var imageCreateAttempt = await MediaEditingService.CreateAsync(imageModel, Constants.Security.SuperUserKey);
|
||||
|
||||
// Assert
|
||||
@@ -49,12 +62,57 @@ internal sealed class MediaEditingServiceTests : UmbracoIntegrationTest
|
||||
Assert.AreEqual(ContentEditingOperationStatus.Success, imageCreateAttempt.Status);
|
||||
}
|
||||
|
||||
private MediaCreateModel CreateMediaCreateModel(string name, Guid key, Guid mediaTypeKey)
|
||||
[Test]
|
||||
public async Task Can_Update_Media_With_Mandatory_File_Property_With_File_Provided()
|
||||
{
|
||||
Guid articleKey = Guid.NewGuid();
|
||||
var articleModel = CreateMediaCreateModelWithFile("Article", articleKey, ArticleMediaType.Key);
|
||||
var articleCreateAttempt = await MediaEditingService.CreateAsync(articleModel, Constants.Security.SuperUserKey);
|
||||
|
||||
Assert.IsTrue(articleCreateAttempt.Success);
|
||||
|
||||
var updateModel = new MediaUpdateModel
|
||||
{
|
||||
Properties =
|
||||
[
|
||||
new PropertyValueModel
|
||||
{
|
||||
Alias = Constants.Conventions.Media.File,
|
||||
Value = new JsonObject
|
||||
{
|
||||
{ "src", string.Empty },
|
||||
},
|
||||
}
|
||||
],
|
||||
Variants = articleModel.Variants,
|
||||
};
|
||||
var articleUpdateAttempt = await MediaEditingService.ValidateUpdateAsync(articleKey, updateModel);
|
||||
Assert.IsFalse(articleUpdateAttempt.Success);
|
||||
Assert.AreEqual(ContentEditingOperationStatus.PropertyValidationError, articleUpdateAttempt.Status);
|
||||
}
|
||||
|
||||
private static MediaCreateModel CreateMediaCreateModel(string name, Guid key, Guid mediaTypeKey)
|
||||
=> new()
|
||||
{
|
||||
ContentTypeKey = mediaTypeKey,
|
||||
ParentKey = Constants.System.RootKey,
|
||||
Variants = [new () { Name = name }],
|
||||
Variants = [new() { Name = name }],
|
||||
Key = key,
|
||||
};
|
||||
|
||||
private static MediaCreateModel CreateMediaCreateModelWithFile(string name, Guid key, Guid mediaTypeKey)
|
||||
{
|
||||
var model = CreateMediaCreateModel(name, key, mediaTypeKey);
|
||||
model.Properties = [
|
||||
new PropertyValueModel
|
||||
{
|
||||
Alias = Constants.Conventions.Media.File,
|
||||
Value = new JsonObject
|
||||
{
|
||||
{ "src", "reference-to-file" },
|
||||
},
|
||||
}
|
||||
];
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user