Implements tests for commit 525ac1348d

Covers the favorites feature and the playlist and favorite pagination changes with unit, integration and security tests, and fixtures for the new request, response, DTO and entity types.

Also fixes the issues found while covering the commit: declares FavoriteMediaKind.None as the default value and rejects it in every favorite operation; queues the favorite added domain event only after the persisted favorite is read back; and preserves the private, no-store cache header on view pages after the antiforgery and session middlewares overwrite it.
This commit is contained in:
BinaryAlley committed 2026-10-29 10:13:57 +02:00
1 parent 468f1846f1
commit 394f6b510c
135 files changed
+19167 -13

No files matched your search

@@ -83,6 +83,63 @@ public class BaseEndpointTests
session.Received(1).Set(HttpContextItemKeys.LAST_DISPLAYED_VIEW, Arg.Any<byte[]>());
}
[Fact]
public void TestSetCacheControl_WhenCalled_ShouldSetTheHeaderAndRememberTheValue()
{
// Act
_sut.TestSetCacheControl("private, no-store");
// Assert
Assert.Equal("private, no-store", _sut.HttpContext.Response.Headers.CacheControl.ToString());
Assert.Equal("private, no-store", _sut.HttpContext.Items[HttpContextItemKeys.CACHE_CONTROL]);
}
[Fact]
public void TestView_WhenACacheControlValueWasRemembered_ShouldKeepItAfterALaterHeaderOverwrite()
{
// Arrange
TestHttpContextFactory.ConfigureSession(_sut.HttpContext, TestHttpContextFactory.CreateSession());
_sut.HttpContext.Request.Path = "/en-us/favorites";
_sut.TestSetCacheControl("private, no-store");
// The antiforgery token generation overwrites the header after the endpoint chose its value.
_sut.HttpContext.Response.Headers.CacheControl = "no-cache, no-store";
// Act
_sut.TestView("/Core/Views/Favorites/Index.cshtml");
// Assert
Assert.Equal("private, no-store", _sut.HttpContext.Items[HttpContextItemKeys.CACHE_CONTROL]);
}
[Fact]
public void TestView_WhenCacheControlIsSetDirectly_ShouldStoreItForTheResponseStartRestoration()
{
// Arrange
TestHttpContextFactory.ConfigureSession(_sut.HttpContext, TestHttpContextFactory.CreateSession());
_sut.HttpContext.Request.Path = "/en-us/favorites";
_sut.HttpContext.Response.Headers.CacheControl = "private, no-store";
// Act
_sut.TestView("/Core/Views/Favorites/Index.cshtml");
// Assert
Assert.Equal("private, no-store", _sut.HttpContext.Items[HttpContextItemKeys.CACHE_CONTROL]);
}
[Fact]
public void TestView_WhenCacheControlIsNotSet_ShouldNotStoreACacheControlValue()
{
// Arrange
TestHttpContextFactory.ConfigureSession(_sut.HttpContext, TestHttpContextFactory.CreateSession());
_sut.HttpContext.Request.Path = "/en-us/favorites";
// Act
_sut.TestView("/Core/Views/Favorites/Index.cshtml");
// Assert
Assert.False(_sut.HttpContext.Items.ContainsKey(HttpContextItemKeys.CACHE_CONTROL));
}
[Fact]
public void TestCulture_WhenCultureRouteValuePresent_ShouldReturnCulture()
{