Files
Umbraco-CMS/tests/Umbraco.Tests.Integration/Umbraco.Core/Services/WebhookLogServiceTests.cs
Andy Butland 1c68e3d825 Added deliveries workspace view to the webhook details workspace (#18175)
* Added deliveries workspace view to the webhook details workspace.

* Front-end linting fixes.

* rename to unique

* update filter value

* make delivery feature folder

* move delivery workspace view for delivery feature folder

* correct details workspace view label and pathname to match name

* remove unused alias

* use singular form to align naming

* remove pagination as the default collection kind already includes this

* show icon

* remove double registration

* add observables for webhook data, add get methods + add jsdocs

* align UX with languages

* remove hardcoded fake name + make url the link

* remove redundant url in table

* render status code as tag

* use tags for enabled/disabled webhook state to align with users

* make the name more explicit

* move webhook root to a feature folder

* export consts

* fix webhook collection pagination

* move menu item manifests into root folder

* move webhook delivery filering responsibility from repo to workspace view

* reorganize

* move workspace

* fix import

* move entity actions

* export delivery consts

* dot not export const

* rename folder

* update name

* make event feature folder

* export consts

* move repository files

* more clean up

* split types

* add deprecation warning for a temp method

* bring back url to deliveries table

---------

Co-authored-by: Mads Rasmussen <madsr@hey.com>
2025-02-04 06:36:38 +01:00

60 lines
2.5 KiB
C#

using System.Globalization;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Webhooks;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Core.Services;
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class WebhookLogServiceTests : UmbracoIntegrationTest
{
private IWebhookLogService WebhookLogService => GetRequiredService<IWebhookLogService>();
[Test]
public async Task Can_Create_And_Get()
{
var webHookKey = Guid.NewGuid();
var createdWebhookLog = await WebhookLogService.CreateAsync(new WebhookLog
{
Date = DateTime.UtcNow,
EventAlias = Constants.WebhookEvents.Aliases.ContentPublish,
RequestBody = "Test Request Body",
ResponseBody = "Test response body",
StatusCode = "200",
RetryCount = 0,
Key = Guid.NewGuid(),
WebhookKey = webHookKey
});
var allWebhookLogsPaged = await WebhookLogService.Get();
var specificWebhookLogsPaged = await WebhookLogService.Get(webHookKey);
Assert.Multiple(() =>
{
AssertGetResult(createdWebhookLog, allWebhookLogsPaged);
AssertGetResult(createdWebhookLog, specificWebhookLogsPaged);
static void AssertGetResult(WebhookLog createdWebhookLog, PagedModel<WebhookLog> allWebhookLogsPaged)
{
Assert.IsNotNull(allWebhookLogsPaged);
Assert.IsNotEmpty(allWebhookLogsPaged.Items);
Assert.AreEqual(1, allWebhookLogsPaged.Items.Count());
var webhookLog = allWebhookLogsPaged.Items.First();
Assert.AreEqual(createdWebhookLog.Date.ToString(CultureInfo.InvariantCulture), webhookLog.Date.ToString(CultureInfo.InvariantCulture));
Assert.AreEqual(createdWebhookLog.EventAlias, webhookLog.EventAlias);
Assert.AreEqual(createdWebhookLog.RequestBody, webhookLog.RequestBody);
Assert.AreEqual(createdWebhookLog.ResponseBody, webhookLog.ResponseBody);
Assert.AreEqual(createdWebhookLog.StatusCode, webhookLog.StatusCode);
Assert.AreEqual(createdWebhookLog.RetryCount, webhookLog.RetryCount);
Assert.AreEqual(createdWebhookLog.Key, webhookLog.Key);
}
});
}
}