Skip to content

Commit

Permalink
Add helper that prepares the shape table cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Jul 16, 2024
1 parent bed91f8 commit 65a16a3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Lombiq.Tests.UI.Shortcuts/Controllers/ShapeTableController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Admin;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.DisplayManagement.Theming;
using System.Threading.Tasks;

namespace Lombiq.Tests.UI.Shortcuts.Controllers;

public class ShapeTableController : Controller
{
/// <summary>
/// Prepares the shape table for the current site and admin themes.
/// </summary>
public async Task<IActionResult> Prepare()
{
var provider = HttpContext.RequestServices;

var shapeTableManager = provider.GetRequiredService<IShapeTableManager>();
var siteTheme = await provider.GetRequiredService<IThemeManager>().GetThemeAsync();
var adminTheme = await provider.GetRequiredService<IAdminThemeService>().GetAdminThemeAsync();

await shapeTableManager.GetShapeTableAsync(themeId: null);
await shapeTableManager.GetShapeTableAsync(siteTheme.Id);
await shapeTableManager.GetShapeTableAsync(adminTheme.Id);

return Ok();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ public static async Task RunAndAssertSecurityScanAsync(
{
var configuration = context.Configuration.SecurityScanningConfiguration ?? new SecurityScanningConfiguration();

await context.GoToAsync<ShapeTableController>(controller => controller.Prepare());

SecurityScanResult result = null;
try
{
Expand Down

0 comments on commit 65a16a3

Please sign in to comment.