Merge branch 'v14/dev' into v15/dev

# Conflicts:
#	Directory.Packages.props
#	build/azure-pipelines.yml
#	src/Umbraco.Core/MonitorLock.cs
#	src/Umbraco.PublishedCache.NuCache/ContentStore.cs
#	src/Umbraco.PublishedCache.NuCache/DependencyInjection/UmbracoBuilderExtensions.cs
#	src/Umbraco.PublishedCache.NuCache/SnapDictionary.cs
#	src/Umbraco.Web.Common/Authorization/AuthorizationPolicies.cs
#	src/Umbraco.Web.UI.Client~v14_dev
#	tests/Umbraco.Tests.AcceptanceTest/package-lock.json
#	tests/Umbraco.Tests.AcceptanceTest/package.json
#	tests/Umbraco.Tests.AcceptanceTest/playwright.config.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithCustomDataType.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowAtRoot.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowVaryByCulture.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedChildNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithAllowedTemplates.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithDocumentTypeProperties/ContentWithCollections.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/ContentWithListViewContent.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/DataType/DataTypeFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/ListViewMedia.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Media/Media.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Members/MemberGroups.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/CreatedPackages.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Packages/PackagesPackages.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithApprovedColor.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithCheckboxList.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithContentPicker.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDatePicker.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithDropdown.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithImageCropper.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithNumeric.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithRadiobox.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTags.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextarea.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTextstring.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/RenderingContent/RenderingContentWithTrueFalse.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/DocumentType/DocumentTypeTemplatesTab.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/MediaType/MediaTypeFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/PartialView/PartialViewFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/Script.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Script/ScriptFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Settings/Stylesheet/StylesheetFolder.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/ContentStartNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/MediaStartNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/User/UICulture.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/ContentStartNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/DefaultPermissionsInContent.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MediaStartNodes.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/Permissions/UserGroup/MemberSection.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/User.spec.ts
#	tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Users/UserGroups.spec.ts
This commit is contained in:
Sven Geusens
2024-11-27 15:10:20 +01:00
22 changed files with 397 additions and 117 deletions

View File

@@ -6,7 +6,6 @@ using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Editors;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
using Umbraco.Cms.Infrastructure.Serialization;
@@ -15,19 +14,11 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.PropertyEditors;
[TestFixture]
public class SliderValueEditorTests
{
// annoyingly we can't use decimals etc. in attributes, so we can't turn these into test cases :(
private List<object?> _invalidValues = new();
[SetUp]
public void SetUp() => _invalidValues = new List<object?>
public static object[] InvalidCaseData = new object[]
{
123m,
123,
-123,
123.45d,
"123.45",
"1.234,56",
"1.2.3.4",
"something",
true,
new object(),
@@ -36,21 +27,19 @@ public class SliderValueEditorTests
new GuidUdi(Constants.UdiEntityType.Document, Guid.NewGuid())
};
[Test]
public void Can_Handle_Invalid_Values_From_Editor()
[TestCaseSource(nameof(InvalidCaseData))]
public void Can_Handle_Invalid_Values_From_Editor(object value)
{
foreach (var value in _invalidValues)
{
var fromEditor = FromEditor(value);
Assert.IsNull(fromEditor, message: $"Failed for: {value}");
}
var fromEditor = FromEditor(value);
Assert.IsNull(fromEditor);
}
[TestCase("1", 1)]
[TestCase("0", 0)]
[TestCase("-1", -1)]
[TestCase("123456789", 123456789)]
public void Can_Parse_Single_Value_To_Editor(string value, int expected)
[TestCase("123.45", 123.45)]
public void Can_Parse_Single_Value_To_Editor(string value, decimal expected)
{
var toEditor = ToEditor(value) as SliderPropertyEditor.SliderPropertyValueEditor.SliderRange;
Assert.IsNotNull(toEditor);
@@ -62,7 +51,10 @@ public class SliderValueEditorTests
[TestCase("0,0", 0, 0)]
[TestCase("-1,-1", -1, -1)]
[TestCase("10,123456789", 10, 123456789)]
public void Can_Parse_Range_Value_To_Editor(string value, int expectedFrom, int expectedTo)
[TestCase("1.234,56", 1.234, 56)]
[TestCase("4,6.234", 4, 6.234)]
[TestCase("10.45,15.3", 10.45, 15.3)]
public void Can_Parse_Range_Value_To_Editor(string value, decimal expectedFrom, decimal expectedTo)
{
var toEditor = ToEditor(value) as SliderPropertyEditor.SliderPropertyValueEditor.SliderRange;
Assert.IsNotNull(toEditor);
@@ -75,21 +67,22 @@ public class SliderValueEditorTests
[TestCase(0, 0, "0")]
[TestCase(-10, -10, "-10")]
[TestCase(10, 123456789, "10,123456789")]
public void Can_Parse_Valid_Value_From_Editor(int from, int to, string expectedResult)
[TestCase(1.5, 1.5, "1.5")]
[TestCase(0, 0.5, "0,0.5")]
[TestCase(5, 5.4, "5,5.4")]
[TestCase(0.5, 0.6, "0.5,0.6")]
public void Can_Parse_Valid_Value_From_Editor(decimal from, decimal to, string expectedResult)
{
var value = JsonNode.Parse($"{{\"from\": {from}, \"to\": {to}}}");
var fromEditor = FromEditor(value) as string;
Assert.AreEqual(expectedResult, fromEditor);
}
[Test]
public void Can_Handle_Invalid_Values_To_Editor()
[TestCaseSource(nameof(InvalidCaseData))]
public void Can_Handle_Invalid_Values_To_Editor(object value)
{
foreach (var value in _invalidValues)
{
var toEditor = ToEditor(value);
Assert.IsNull(toEditor, message: $"Failed for: {value}");
}
var toEditor = ToEditor(value);
Assert.IsNull(toEditor, message: $"Failed for: {value}");
}
[Test]

View File

@@ -23,7 +23,9 @@ public class UriUtilityTests
// test that the trailing slash goes but not on hostname
[TestCase("http://LocalHost/", "http://localhost/")]
[TestCase("http://LocalHost/////", "http://localhost/")]
[TestCase("http://LocalHost/Home/", "http://localhost/home")]
[TestCase("http://LocalHost/Home/////", "http://localhost/home")]
[TestCase("http://LocalHost/Home/?x=y", "http://localhost/home?x=y")]
[TestCase("http://LocalHost/Home/Sub1/", "http://localhost/home/sub1")]
[TestCase("http://LocalHost/Home/Sub1/?x=y", "http://localhost/home/sub1?x=y")]