Service refactoring to "fully" enable segments (#19114)
* Refactor serverside content editing to support all variance combinations * Fix build errors * Reintroduce the tests ignored by #19060 --------- Co-authored-by: Mads Rasmussen <madsr@hey.com>
This commit is contained in:
@@ -76,12 +76,12 @@ internal sealed class DocumentHybridCachePropertyTest : UmbracoIntegrationTest
|
||||
// Update content
|
||||
var updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = "Root Create",
|
||||
InvariantProperties = new[]
|
||||
{
|
||||
Variants = [new() { Name = "Root Create" }],
|
||||
Properties =
|
||||
[
|
||||
new PropertyValueModel { Alias = "title", Value = "Updated title" },
|
||||
new PropertyValueModel { Alias = "bodyText", Value = "The body text" }
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
var updateResult = await ContentEditingService.UpdateAsync(textPage.Key, updateModel, Constants.Security.SuperUserKey);
|
||||
|
||||
@@ -36,7 +36,7 @@ internal sealed class DocumentHybridCacheTemplateTests : UmbracoIntegrationTestW
|
||||
var updateModel = new ContentUpdateModel();
|
||||
{
|
||||
updateModel.TemplateKey = null;
|
||||
updateModel.InvariantName = textPageBefore.Name;
|
||||
updateModel.Variants = [new() { Name = textPageBefore.Name }];
|
||||
}
|
||||
|
||||
// Act
|
||||
|
||||
@@ -111,11 +111,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Draft_Content_By_Id()
|
||||
{
|
||||
// Arrange
|
||||
Textpage.InvariantName = NewName;
|
||||
Textpage.Variants = [new() { Name = NewName }];
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = NewName,
|
||||
InvariantProperties = Textpage.InvariantProperties,
|
||||
Properties = Textpage.Properties,
|
||||
Variants = Textpage.Variants,
|
||||
TemplateKey = Textpage.TemplateKey,
|
||||
};
|
||||
@@ -132,11 +131,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Draft_Content_By_Key()
|
||||
{
|
||||
// Arrange
|
||||
Textpage.InvariantName = NewName;
|
||||
Textpage.Variants = [new() { Name = NewName }];
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = NewName,
|
||||
InvariantProperties = Textpage.InvariantProperties,
|
||||
Properties = Textpage.Properties,
|
||||
Variants = Textpage.Variants,
|
||||
TemplateKey = Textpage.TemplateKey,
|
||||
};
|
||||
@@ -156,11 +154,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Draft_Published_Content_By_Id(bool preview, bool result)
|
||||
{
|
||||
// Arrange
|
||||
PublishedTextPage.InvariantName = NewName;
|
||||
PublishedTextPage.Variants = [new() { Name = NewName }];
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = NewName,
|
||||
InvariantProperties = PublishedTextPage.InvariantProperties,
|
||||
Properties = PublishedTextPage.Properties,
|
||||
Variants = PublishedTextPage.Variants,
|
||||
TemplateKey = PublishedTextPage.TemplateKey,
|
||||
};
|
||||
@@ -180,11 +177,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Draft_Published_Content_By_Key(bool preview, bool result)
|
||||
{
|
||||
// Arrange
|
||||
PublishedTextPage.InvariantName = NewName;
|
||||
PublishedTextPage.Variants = [new() { Name = NewName }];;
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = NewName,
|
||||
InvariantProperties = PublishedTextPage.InvariantProperties,
|
||||
Properties = PublishedTextPage.Properties,
|
||||
Variants = PublishedTextPage.Variants,
|
||||
TemplateKey = PublishedTextPage.TemplateKey,
|
||||
};
|
||||
@@ -201,7 +197,7 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Draft_Content_Property_By_Id()
|
||||
{
|
||||
// Arrange
|
||||
var titleValue = Textpage.InvariantProperties.First(x => x.Alias == "title").Value;
|
||||
var titleValue = Textpage.Properties.First(x => x.Alias == "title").Value;
|
||||
|
||||
// Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(TextpageId, true);
|
||||
@@ -214,7 +210,7 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Draft_Content_Property_By_Key()
|
||||
{
|
||||
// Arrange
|
||||
var titleValue = Textpage.InvariantProperties.First(x => x.Alias == "title").Value;
|
||||
var titleValue = Textpage.Properties.First(x => x.Alias == "title").Value;
|
||||
|
||||
// Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(Textpage.Key.Value, true);
|
||||
@@ -227,7 +223,7 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Published_Content_Property_By_Id()
|
||||
{
|
||||
// Arrange
|
||||
var titleValue = PublishedTextPage.InvariantProperties.First(x => x.Alias == "title").Value;
|
||||
var titleValue = PublishedTextPage.Properties.First(x => x.Alias == "title").Value;
|
||||
|
||||
// Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, true);
|
||||
@@ -240,7 +236,7 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Published_Content_Property_By_Key()
|
||||
{
|
||||
// Arrange
|
||||
var titleValue = PublishedTextPage.InvariantProperties.First(x => x.Alias == "title").Value;
|
||||
var titleValue = PublishedTextPage.Properties.First(x => x.Alias == "title").Value;
|
||||
|
||||
// Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, true);
|
||||
@@ -253,7 +249,7 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Draft_Of_Published_Content_Property_By_Id()
|
||||
{
|
||||
// Arrange
|
||||
var titleValue = PublishedTextPage.InvariantProperties.First(x => x.Alias == "title").Value;
|
||||
var titleValue = PublishedTextPage.Properties.First(x => x.Alias == "title").Value;
|
||||
|
||||
// Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, true);
|
||||
@@ -266,7 +262,7 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Draft_Of_Published_Content_Property_By_Key()
|
||||
{
|
||||
// Arrange
|
||||
var titleValue = PublishedTextPage.InvariantProperties.First(x => x.Alias == "title").Value;
|
||||
var titleValue = PublishedTextPage.Properties.First(x => x.Alias == "title").Value;
|
||||
|
||||
// Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, true);
|
||||
@@ -279,11 +275,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Draft_Content_Property_By_Id()
|
||||
{
|
||||
// Arrange
|
||||
Textpage.InvariantProperties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
Textpage.Properties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = Textpage.InvariantName,
|
||||
InvariantProperties = Textpage.InvariantProperties,
|
||||
Properties = Textpage.Properties,
|
||||
Variants = Textpage.Variants,
|
||||
TemplateKey = Textpage.TemplateKey,
|
||||
};
|
||||
@@ -300,11 +295,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Draft_Content_Property_By_Key()
|
||||
{
|
||||
// Arrange
|
||||
Textpage.InvariantProperties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
Textpage.Properties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = Textpage.InvariantName,
|
||||
InvariantProperties = Textpage.InvariantProperties,
|
||||
Properties = Textpage.Properties,
|
||||
Variants = Textpage.Variants,
|
||||
TemplateKey = Textpage.TemplateKey,
|
||||
};
|
||||
@@ -321,11 +315,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Published_Content_Property_By_Id()
|
||||
{
|
||||
// Arrange
|
||||
PublishedTextPage.InvariantProperties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
PublishedTextPage.Properties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = PublishedTextPage.InvariantName,
|
||||
InvariantProperties = PublishedTextPage.InvariantProperties,
|
||||
Properties = PublishedTextPage.Properties,
|
||||
Variants = PublishedTextPage.Variants,
|
||||
TemplateKey = PublishedTextPage.TemplateKey,
|
||||
};
|
||||
@@ -343,11 +336,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Published_Content_Property_By_Key()
|
||||
{
|
||||
// Arrange
|
||||
PublishedTextPage.InvariantProperties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
PublishedTextPage.Properties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = PublishedTextPage.InvariantName,
|
||||
InvariantProperties = PublishedTextPage.InvariantProperties,
|
||||
Properties = PublishedTextPage.Properties,
|
||||
Variants = PublishedTextPage.Variants,
|
||||
TemplateKey = PublishedTextPage.TemplateKey,
|
||||
};
|
||||
@@ -367,11 +359,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Draft_Of_Published_Content_Property_By_Id(bool preview, string titleName)
|
||||
{
|
||||
// Arrange
|
||||
PublishedTextPage.InvariantProperties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
PublishedTextPage.Properties.First(x => x.Alias == "title").Value = NewTitle;
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = PublishedTextPage.InvariantName,
|
||||
InvariantProperties = PublishedTextPage.InvariantProperties,
|
||||
Properties = PublishedTextPage.Properties,
|
||||
Variants = PublishedTextPage.Variants,
|
||||
TemplateKey = PublishedTextPage.TemplateKey,
|
||||
};
|
||||
@@ -390,11 +381,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
public async Task Can_Get_Updated_Draft_Of_Published_Content_Property_By_Key(bool preview, string titleName)
|
||||
{
|
||||
// Arrange
|
||||
PublishedTextPage.InvariantProperties.First(x => x.Alias == "title").Value = titleName;
|
||||
PublishedTextPage.Properties.First(x => x.Alias == "title").Value = titleName;
|
||||
ContentUpdateModel updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantName = PublishedTextPage.InvariantName,
|
||||
InvariantProperties = PublishedTextPage.InvariantProperties,
|
||||
Properties = PublishedTextPage.Properties,
|
||||
Variants = PublishedTextPage.Variants,
|
||||
TemplateKey = PublishedTextPage.TemplateKey,
|
||||
};
|
||||
@@ -477,10 +467,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
Assert.IsNotNull(textPage);
|
||||
Assert.AreEqual(Textpage.Key, textPage.Key);
|
||||
Assert.AreEqual(Textpage.ContentTypeKey, textPage.ContentType.Key);
|
||||
Assert.AreEqual(Textpage.InvariantName, textPage.Name);
|
||||
Assert.AreEqual(Textpage.Variants.Single().Name, textPage.Name);
|
||||
});
|
||||
|
||||
AssertProperties(Textpage.InvariantProperties, textPage.Properties);
|
||||
AssertProperties(Textpage.Properties, textPage.Properties);
|
||||
}
|
||||
|
||||
private void AssertPublishedTextPage(IPublishedContent textPage)
|
||||
@@ -490,10 +480,10 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
Assert.IsNotNull(textPage);
|
||||
Assert.AreEqual(PublishedTextPage.Key, textPage.Key);
|
||||
Assert.AreEqual(PublishedTextPage.ContentTypeKey, textPage.ContentType.Key);
|
||||
Assert.AreEqual(PublishedTextPage.InvariantName, textPage.Name);
|
||||
Assert.AreEqual(PublishedTextPage.Variants.Single().Name, textPage.Name);
|
||||
});
|
||||
|
||||
AssertProperties(PublishedTextPage.InvariantProperties, textPage.Properties);
|
||||
AssertProperties(PublishedTextPage.Properties, textPage.Properties);
|
||||
}
|
||||
|
||||
private void AssertProperties(IEnumerable<PropertyValueModel> propertyCollection, IEnumerable<IPublishedProperty> publishedProperties)
|
||||
|
||||
@@ -59,27 +59,16 @@ internal sealed class DocumentHybridCacheVariantsTests : UmbracoIntegrationTest
|
||||
|
||||
var updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantProperties =
|
||||
new[] { new PropertyValueModel { Alias = _invariantTitleAlias, Value = updatedInvariantTitle } },
|
||||
Variants = new[]
|
||||
{
|
||||
new VariantModel
|
||||
{
|
||||
Culture = _englishIsoCode,
|
||||
Name = "Updated English Name",
|
||||
Properties =
|
||||
new[] { new PropertyValueModel { Alias = _variantTitleAlias, Value = updatedVariantTitle } },
|
||||
},
|
||||
new VariantModel
|
||||
{
|
||||
Culture = _danishIsoCode,
|
||||
Name = "Updated Danish Name",
|
||||
Properties = new[]
|
||||
{
|
||||
new PropertyValueModel { Alias = _variantTitleAlias, Value = updatedVariantTitle },
|
||||
},
|
||||
},
|
||||
},
|
||||
Properties = [
|
||||
new PropertyValueModel { Alias = _invariantTitleAlias, Value = updatedInvariantTitle },
|
||||
new PropertyValueModel { Alias = _variantTitleAlias, Value = updatedVariantTitle, Culture = _englishIsoCode },
|
||||
new PropertyValueModel { Alias = _variantTitleAlias, Value = updatedVariantTitle, Culture = _danishIsoCode }
|
||||
],
|
||||
Variants =
|
||||
[
|
||||
new VariantModel { Culture = _englishIsoCode, Name = "Updated English Name" },
|
||||
new VariantModel { Culture = _danishIsoCode, Name = "Updated Danish Name" }
|
||||
],
|
||||
};
|
||||
|
||||
var result =
|
||||
@@ -106,20 +95,15 @@ internal sealed class DocumentHybridCacheVariantsTests : UmbracoIntegrationTest
|
||||
|
||||
var updateModel = new ContentUpdateModel
|
||||
{
|
||||
InvariantProperties =
|
||||
new[] { new PropertyValueModel { Alias = _invariantTitleAlias, Value = updatedInvariantTitle } },
|
||||
Variants = new[]
|
||||
{
|
||||
new VariantModel
|
||||
{
|
||||
Culture = _englishIsoCode,
|
||||
Name = "Updated English Name",
|
||||
Properties = new[]
|
||||
{
|
||||
new PropertyValueModel { Alias = _variantTitleAlias, Value = updatedVariantTitle },
|
||||
},
|
||||
},
|
||||
},
|
||||
Properties =
|
||||
[
|
||||
new PropertyValueModel { Alias = _invariantTitleAlias, Value = updatedInvariantTitle },
|
||||
new PropertyValueModel { Alias = _variantTitleAlias, Value = updatedVariantTitle, Culture = _englishIsoCode }
|
||||
],
|
||||
Variants =
|
||||
[
|
||||
new VariantModel { Culture = _englishIsoCode, Name = "Updated English Name" }
|
||||
],
|
||||
};
|
||||
|
||||
var result =
|
||||
|
||||
@@ -128,9 +128,8 @@ internal sealed class MediaHybridCacheTests : UmbracoIntegrationTestWithMediaEdi
|
||||
|
||||
var mediaUpdateModel = new MediaUpdateModel
|
||||
{
|
||||
InvariantName = newName,
|
||||
InvariantProperties = SubImage.InvariantProperties,
|
||||
Variants = SubImage.Variants,
|
||||
Properties = SubImage.Properties,
|
||||
Variants = [new VariantModel { Name = newName }]
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -152,9 +151,8 @@ internal sealed class MediaHybridCacheTests : UmbracoIntegrationTestWithMediaEdi
|
||||
|
||||
var mediaUpdateModel = new MediaUpdateModel
|
||||
{
|
||||
InvariantName = newName,
|
||||
InvariantProperties = SubImage.InvariantProperties,
|
||||
Variants = SubImage.Variants,
|
||||
Properties = SubImage.Properties,
|
||||
Variants = [new VariantModel { Name = newName }]
|
||||
};
|
||||
|
||||
// Act
|
||||
|
||||
@@ -62,12 +62,12 @@ internal sealed class MemberHybridCacheTests : UmbracoIntegrationTest
|
||||
IsApproved = true,
|
||||
ContentTypeKey = memberType.Key,
|
||||
Roles = new [] { group.Key },
|
||||
InvariantName = "T. Est",
|
||||
InvariantProperties = new[]
|
||||
{
|
||||
Variants = [new () { Name = "T. Est" }],
|
||||
Properties =
|
||||
[
|
||||
new PropertyValueModel { Alias = "title", Value = "The title value" },
|
||||
new PropertyValueModel { Alias = "author", Value = "The author value" }
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var result = await MemberEditingService.CreateAsync(createModel, SuperUser());
|
||||
|
||||
Reference in New Issue
Block a user