Merge branch 'v13/dev' into contrib

# Conflicts:
#	src/Umbraco.Cms.StaticAssets/umbraco/UmbracoBackOffice/Default.cshtml
#	src/Umbraco.Core/EmbeddedResources/Lang/en.xml
#	src/Umbraco.Web.UI.Client/src/common/services/blockeditormodelobject.service.js
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Login/login.spec.ts
This commit is contained in:
Sebastiaan Janssen
2024-01-02 10:33:35 +01:00
54 changed files with 776 additions and 231 deletions

View File

@@ -46,7 +46,7 @@ public static class UmbracoBuilderExtensions
builder.Services.AddUnique(Mock.Of<IUmbracoBootPermissionChecker>());
builder.Services.AddUnique(testHelper.MainDom);
builder.Services.AddUnique<ExamineIndexRebuilder, TestBackgroundIndexRebuilder>();
builder.Services.AddUnique<IIndexRebuilder, TestBackgroundIndexRebuilder>();
builder.Services.AddUnique(factory => Mock.Of<IRuntimeMinifier>());
// we don't want persisted nucache files in tests

View File

@@ -58,21 +58,64 @@ public class IndexInitializer
_contentTypeService = contentTypeService;
}
[Obsolete("Use ctor that is not obsolete. This will be removed in Umbraco 15.")]
public IndexInitializer(
IShortStringHelper shortStringHelper,
PropertyEditorCollection propertyEditors,
MediaUrlGeneratorCollection mediaUrlGenerators,
IScopeProvider scopeProvider,
ILoggerFactory loggerFactory,
IOptions<ContentSettings> contentSettings, IContentTypeService contentTypeService)
IOptions<ContentSettings> contentSettings,
ILocalizationService localizationService)
: this(
shortStringHelper,
propertyEditors,
mediaUrlGenerators,
scopeProvider,
loggerFactory,
contentSettings,
StaticServiceProvider.Instance.GetRequiredService<ILocalizationService>(), contentTypeService)
shortStringHelper,
propertyEditors,
mediaUrlGenerators,
scopeProvider,
loggerFactory,
contentSettings,
localizationService, StaticServiceProvider.Instance.GetRequiredService<IContentTypeService>())
{
}
[Obsolete("Use ctor that is not obsolete. This will be removed in Umbraco 15.")]
public IndexInitializer(
IShortStringHelper shortStringHelper,
PropertyEditorCollection propertyEditors,
MediaUrlGeneratorCollection mediaUrlGenerators,
IScopeProvider scopeProvider,
ILoggerFactory loggerFactory,
IOptions<ContentSettings> contentSettings,
IContentTypeService contentTypeService)
: this(
shortStringHelper,
propertyEditors,
mediaUrlGenerators,
scopeProvider,
loggerFactory,
contentSettings,
StaticServiceProvider.Instance.GetRequiredService<ILocalizationService>(), contentTypeService)
{
}
[Obsolete("Use ctor that is not obsolete. This will be removed in Umbraco 15.")]
public IndexInitializer(
IShortStringHelper shortStringHelper,
PropertyEditorCollection propertyEditors,
MediaUrlGeneratorCollection mediaUrlGenerators,
IScopeProvider scopeProvider,
ILoggerFactory loggerFactory,
IOptions<ContentSettings> contentSettings)
: this(
shortStringHelper,
propertyEditors,
mediaUrlGenerators,
scopeProvider,
loggerFactory,
contentSettings,
StaticServiceProvider.Instance.GetRequiredService<ILocalizationService>(),
StaticServiceProvider.Instance.GetRequiredService<IContentTypeService>())
{
}

View File

@@ -157,11 +157,45 @@ public class MultiUrlPickerValueConverterTests : PropertyValueConverterTests
var link = result.First();
Assert.AreEqual("The link", link.Title);
Assert.AreEqual("https://umbraco.com/?something=true", link.Url);
Assert.AreEqual("?something=true", link.QueryString);
Assert.AreEqual(LinkType.External, link.LinkType);
Assert.AreEqual("_blank", link.Target);
Assert.Null(link.Route);
}
[Test]
public void MultiUrlPickerValueConverter_AppliesExplicitConfigurationToMediaLink()
{
var publishedDataType = new PublishedDataType(123, "test", new Lazy<object>(() => new MultiUrlPickerConfiguration { MaxNumber = 1 }));
var publishedPropertyType = new Mock<IPublishedPropertyType>();
publishedPropertyType.SetupGet(p => p.DataType).Returns(publishedDataType);
var valueConverter = MultiUrlPickerValueConverter();
var inter = Serializer().Serialize(new[]
{
new MultiUrlPickerValueEditor.LinkDto
{
Udi = new GuidUdi(Constants.UdiEntityType.Media, PublishedMedia.Key),
Name = "Custom link name",
QueryString = "?something=true",
Target = "_blank"
}
});
var result = valueConverter.ConvertIntermediateToDeliveryApiObject(Mock.Of<IPublishedElement>(), publishedPropertyType.Object, PropertyCacheLevel.Element, inter, false, false) as IEnumerable<ApiLink>;
Assert.NotNull(result);
Assert.AreEqual(1, result.Count());
var link = result.First();
Assert.AreEqual("Custom link name", link.Title);
Assert.AreEqual(PublishedMedia.Key, link.DestinationId);
Assert.AreEqual("TheMediaType", link.DestinationType);
Assert.AreEqual("the-media-url?something=true", link.Url);
Assert.AreEqual(LinkType.Media, link.LinkType);
Assert.AreEqual("_blank", link.Target);
Assert.AreEqual("?something=true", link.QueryString);
Assert.AreEqual(null, link.Route);
}
[Test]
public void MultiUrlPickerValueConverter_AppliesExplicitConfigurationToContentLink()
{
@@ -190,6 +224,7 @@ public class MultiUrlPickerValueConverterTests : PropertyValueConverterTests
Assert.AreEqual("/the-page-url", link.Route!.Path);
Assert.AreEqual(LinkType.Content, link.LinkType);
Assert.AreEqual("_blank", link.Target);
Assert.AreEqual("?something=true", link.QueryString);
Assert.Null(link.Url);
}

View File

@@ -1,8 +1,6 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using NUnit.Framework;
using Umbraco.Cms.Core;
@@ -49,6 +47,71 @@ public class ArtifactBaseTests
string.Join(",", artifact.Dependencies.Select(x => x.Udi.ToString())));
}
[Test]
public void Dependencies_Correctly_Updates_Mode()
{
var udi = Udi.Create(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
var dependencies = new ArtifactDependencyCollection
{
// Keep Match
new ArtifactDependency(udi, false, ArtifactDependencyMode.Match),
new ArtifactDependency(udi, false, ArtifactDependencyMode.Exist),
};
Assert.AreEqual(1, dependencies.Count);
var dependency = dependencies.First();
Assert.AreEqual(udi, dependency.Udi);
Assert.AreEqual(false, dependency.Ordering);
Assert.AreEqual(ArtifactDependencyMode.Match, dependency.Mode);
Assert.AreEqual(null, dependency.Checksum);
}
[Test]
public void Dependencies_Correctly_Updates_Ordering()
{
var udi = Udi.Create(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
var dependencies = new ArtifactDependencyCollection
{
// Keep ordering (regardless of mode)
new ArtifactDependency(udi, false, ArtifactDependencyMode.Match),
new ArtifactDependency(udi, false, ArtifactDependencyMode.Exist),
new ArtifactDependency(udi, true, ArtifactDependencyMode.Match),
new ArtifactDependency(udi, true, ArtifactDependencyMode.Exist),
new ArtifactDependency(udi, false, ArtifactDependencyMode.Match),
new ArtifactDependency(udi, false, ArtifactDependencyMode.Exist),
};
Assert.AreEqual(1, dependencies.Count);
var dependency = dependencies.First();
Assert.AreEqual(udi, dependency.Udi);
Assert.AreEqual(true, dependency.Ordering);
Assert.AreEqual(ArtifactDependencyMode.Match, dependency.Mode);
Assert.AreEqual(null, dependency.Checksum);
}
[Test]
public void Dependencies_Correctly_Updates_Checksum()
{
var udi = Udi.Create(Constants.UdiEntityType.AnyGuid, Guid.NewGuid());
var dependencies = new ArtifactDependencyCollection
{
// Keep checksum
new ArtifactDependency(udi, true, ArtifactDependencyMode.Match, "123"),
new ArtifactDependency(udi, true, ArtifactDependencyMode.Match, string.Empty),
new ArtifactDependency(udi, true, ArtifactDependencyMode.Match),
};
Assert.AreEqual(1, dependencies.Count);
var dependency = dependencies.First();
Assert.AreEqual(udi, dependency.Udi);
Assert.AreEqual(true, dependency.Ordering);
Assert.AreEqual(ArtifactDependencyMode.Match, dependency.Mode);
Assert.AreEqual("123", dependency.Checksum);
}
private class TestArtifact : ArtifactBase<GuidUdi>
{
public TestArtifact(GuidUdi udi, IEnumerable<ArtifactDependency> dependencies = null)