diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs index 0e3885df0..72a842e91 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/ContentUpdateTests.cs @@ -132,6 +132,63 @@ namespace TestSuite.ApiTests } } + [Fact] + public async Task Should_create_null_text() + { + TestEntity content = null; + try + { + // STEP 1: Create a content item with a text that caused a bug before. + content = await _.Contents.CreateAsync(new TestEntityData + { + Localized = new Dictionary + { + ["en"] = null + } + }, true); + + + // STEP 2: Get the item and ensure that the text is the same. + var updated = await _.Contents.GetAsync(content.Id); + + Assert.Null(updated.Data.Localized["en"]); + } + finally + { + if (content != null) + { + await _.Contents.DeleteAsync(content.Id); + } + } + } + + [Fact] + public async Task Should_create_default_text() + { + TestEntity content = null; + try + { + // STEP 1: Create a content item with a text that caused a bug before. + content = await _.Contents.CreateAsync(new TestEntityData + { + Localized = new Dictionary() + }, true); + + + // STEP 2: Get the item and ensure that the text is the same. + var updated = await _.Contents.GetAsync(content.Id); + + Assert.Equal("default", updated.Data.Localized["en"]); + } + finally + { + if (content != null) + { + await _.Contents.DeleteAsync(content.Id); + } + } + } + [Fact] public async Task Should_create_content_with_scripting() { diff --git a/backend/tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs b/backend/tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs index 1a2391a4b..48fad33cb 100644 --- a/backend/tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs +++ b/backend/tools/TestSuite/TestSuite.Shared/Model/TestEntity.cs @@ -47,6 +47,15 @@ namespace TestSuite.Model { IsRequired = false } + }, + new UpsertSchemaFieldDto + { + Name = TestEntityData.LocalizedField, + Partitioning = "language", + Properties = new StringFieldPropertiesDto + { + DefaultValue = "default" + } } }, Scripts = new SchemaScriptsDto @@ -66,12 +75,16 @@ namespace TestSuite.Model public sealed class TestEntityData { + public static readonly string LocalizedField = nameof(Localized).ToLowerInvariant(); + public static readonly string StringField = nameof(String).ToLowerInvariant(); public static readonly string NumberField = nameof(Number).ToLowerInvariant(); public static readonly string GeoField = nameof(Geo).ToLowerInvariant(); + public Dictionary Localized { get; set; } + [JsonConverter(typeof(InvariantConverter))] public int Number { get; set; }