* Create sign provider collection and call registered providers on rendering a page of tree item view models. Re-work tree controller constructors to provide registered providers as a collection. * Stub implementation of sign provider for documents with a scheduled publish pending. * Complete implementation of tree sign for pending scheduled publish. * Added integration test for new method on IContentService. * Added unit test for HasScheduleSignProvider. * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Tidied usings and clarified method header comments. * Adding a fixed prefix to all future signs, and removing the provider property * Adding a sign for protected tree documents. * Adding IsProtectedSignProviderTest.cs & correcting HasScheduleSignProviderTests.cs to no longer assert the provider * Fixing minor things in accordance with CR * Adding collection items compatibility * Introduced IHasSigns interface to provide more re-use across trees and collections. Fixed updates to base content controllers (no need to introduce a new type variable). Removed passing entities for populating tree signs (we aren't using it, so simplifies things). * Refactoring a bit to make existing code less duplicated and fixing some constructor obsoletion * Introducing a has pending changes sign. * Applying changes based on CR * Introducing tests for HasPendingChangesSignProvider.cs and stopped the use of contentService * Introducing tests for HasPendingChangesSignProvider.cs and slight logic change * Introduced HasCollectionSignProvider.cs and tests. * Introducing collection signs to Media Tree & Media Collection items * Introducing Plain Items and tests. Refactoring tests as well * Introduced alternative CanProvideSigns() implementation on IsProtectedSignProvider.cs * Slight refactoring to reduce bloating. * Adding [ActivatorUtilitiesConstructor] since it threw an error otherwise * Minor cleanup. * Updated OpenApi.json. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: NillasKA <kramernicklas@gmail.com>
93 lines
2.7 KiB
C#
93 lines
2.7 KiB
C#
using NUnit.Framework;
|
|
using Umbraco.Cms.Api.Management.Services.Signs;
|
|
using Umbraco.Cms.Api.Management.ViewModels.Document.Collection;
|
|
using Umbraco.Cms.Api.Management.ViewModels.Document.Item;
|
|
using Umbraco.Cms.Api.Management.ViewModels.Tree;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Cms.Api.Management.Services.Signs;
|
|
|
|
[TestFixture]
|
|
internal class IsProtectedSignProviderTests
|
|
{
|
|
[Test]
|
|
public void IsProtectedSignProvider_Can_Provide_Tree_Signs()
|
|
{
|
|
var sut = new IsProtectedSignProvider();
|
|
Assert.IsTrue(sut.CanProvideSigns<DocumentTreeItemResponseModel>());
|
|
}
|
|
|
|
[Test]
|
|
public void IsProtectedSignProvider_Can_Provide_Collection_Signs()
|
|
{
|
|
var sut = new IsProtectedSignProvider();
|
|
Assert.IsTrue(sut.CanProvideSigns<DocumentCollectionResponseModel>());
|
|
}
|
|
|
|
[Test]
|
|
public void IsProtectedSignProvider_Can_Provide_Plain_Signs()
|
|
{
|
|
var sut = new IsProtectedSignProvider();
|
|
Assert.IsTrue(sut.CanProvideSigns<DocumentItemResponseModel>());
|
|
}
|
|
|
|
[Test]
|
|
public async Task IsProtectedSignProvider_Should_Populate_Tree_Signs()
|
|
{
|
|
var sut = new IsProtectedSignProvider();
|
|
|
|
var viewModels = new List<DocumentTreeItemResponseModel>
|
|
{
|
|
new(),
|
|
new() { IsProtected = true },
|
|
};
|
|
|
|
await sut.PopulateSignsAsync(viewModels);
|
|
|
|
Assert.AreEqual(viewModels[0].Signs.Count(), 0);
|
|
Assert.AreEqual(viewModels[1].Signs.Count(), 1);
|
|
|
|
var signModel = viewModels[1].Signs.First();
|
|
Assert.AreEqual("Umb.IsProtected", signModel.Alias);
|
|
}
|
|
|
|
[Test]
|
|
public async Task IsProtectedSignProvider_Should_Populate_Collection_Signs()
|
|
{
|
|
var sut = new IsProtectedSignProvider();
|
|
|
|
var viewModels = new List<DocumentCollectionResponseModel>
|
|
{
|
|
new(),
|
|
new() { IsProtected = true },
|
|
};
|
|
|
|
await sut.PopulateSignsAsync(viewModels);
|
|
|
|
Assert.AreEqual(viewModels[0].Signs.Count(), 0);
|
|
Assert.AreEqual(viewModels[1].Signs.Count(), 1);
|
|
|
|
var signModel = viewModels[1].Signs.First();
|
|
Assert.AreEqual("Umb.IsProtected", signModel.Alias);
|
|
}
|
|
|
|
[Test]
|
|
public async Task IsProtectedSignProvider_Should_Populate_Plain_Signs()
|
|
{
|
|
var sut = new IsProtectedSignProvider();
|
|
|
|
var viewModels = new List<DocumentItemResponseModel>
|
|
{
|
|
new(),
|
|
new() { IsProtected = true },
|
|
};
|
|
|
|
await sut.PopulateSignsAsync(viewModels);
|
|
|
|
Assert.AreEqual(viewModels[0].Signs.Count(), 0);
|
|
Assert.AreEqual(viewModels[1].Signs.Count(), 1);
|
|
|
|
var signModel = viewModels[1].Signs.First();
|
|
Assert.AreEqual("Umb.IsProtected", signModel.Alias);
|
|
}
|
|
}
|