mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 09:11:10 +00:00
Replaces the custom EmptyRequest with explicit API client operations
Removes the Web-specific EmptyRequest record struct and keeps FastEndpoints.EmptyRequest only as an endpoint request DTO. Adds bodyless and response-ignoring client overloads, centralizes request construction and response disposal, and separates stale-session failures from generic 404 responses. Updates the API client stub and tests, including regression coverage for non-empty response bodies, overload selection, and crafted theme asset paths.
This commit is contained in:
1 parent
c1dd08706c
commit
0a86f1a70b
70 files changed
+679
-384
No files matched your search
+2
-3
@@ -4,7 +4,6 @@ using Lumina.Presentation.Web.Core.Endpoints.Admin.Scheduler.FireScheduledJob;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.Requests.Scheduling;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
@@ -41,11 +40,11 @@ public class FireScheduledJobEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
FireScheduledJobRequest request = _fireScheduledJobRequestFixture.Create();
|
||||
string expectedEndpoint = $"scheduled-jobs/{request.ScheduledJobId}/fire";
|
||||
_apiFactory.ApiClientStub.RegisterPutResponseFactory(expectedEndpoint, _ => new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest());
|
||||
_apiFactory.ApiClientStub.RegisterPutPayload<FireScheduledJobRequest>(expectedEndpoint);
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
HttpRequestMessage fireRequest = new(HttpMethod.Put, $"/en-us/admin/api-scheduled-jobs/{request.ScheduledJobId}/fire")
|
||||
{
|
||||
Content = JsonContent.Create(new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest())
|
||||
Content = JsonContent.Create(request)
|
||||
};
|
||||
fireRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
fireRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
+2
-2
@@ -40,11 +40,11 @@ public class StartScheduledJobEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
StartScheduledJobRequest request = _startScheduledJobRequestFixture.Create();
|
||||
string expectedEndpoint = $"scheduled-jobs/{request.ScheduledJobId}/start";
|
||||
_apiFactory.ApiClientStub.RegisterPutResponseFactory(expectedEndpoint, _ => new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest());
|
||||
_apiFactory.ApiClientStub.RegisterPutPayload<StartScheduledJobRequest>(expectedEndpoint);
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
HttpRequestMessage startRequest = new(HttpMethod.Put, $"/en-us/admin/api-scheduled-jobs/{request.ScheduledJobId}/start")
|
||||
{
|
||||
Content = JsonContent.Create(new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest())
|
||||
Content = JsonContent.Create(request)
|
||||
};
|
||||
startRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
startRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
+2
-2
@@ -40,11 +40,11 @@ public class StopScheduledJobEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
StopScheduledJobRequest request = _stopScheduledJobRequestFixture.Create();
|
||||
string expectedEndpoint = $"scheduled-jobs/{request.ScheduledJobId}/stop";
|
||||
_apiFactory.ApiClientStub.RegisterPutResponseFactory(expectedEndpoint, _ => new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest());
|
||||
_apiFactory.ApiClientStub.RegisterPutPayload<StopScheduledJobRequest>(expectedEndpoint);
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
HttpRequestMessage stopRequest = new(HttpMethod.Put, $"/en-us/admin/api-scheduled-jobs/{request.ScheduledJobId}/stop")
|
||||
{
|
||||
Content = JsonContent.Create(new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest())
|
||||
Content = JsonContent.Create(request)
|
||||
};
|
||||
stopRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
stopRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class UpdateSchedulerDisplayPreferencesEndpointTests : IClassFixture<Lumi
|
||||
// Arrange
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
UpdateSchedulerDisplayPreferencesRequest request = _updateSchedulerDisplayPreferencesRequestFixture.Create();
|
||||
_apiFactory.ApiClientStub.RegisterPutResponseFactory("scheduled-jobs/display-preferences", _ => new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest());
|
||||
_apiFactory.ApiClientStub.RegisterPutPayload<UpdateSchedulerDisplayPreferencesRequest>("scheduled-jobs/display-preferences");
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
HttpRequestMessage updateRequest = new(HttpMethod.Put, "/en-us/admin/api-scheduled-jobs/display-preferences")
|
||||
{
|
||||
|
||||
+1
-5
@@ -1,10 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.RestoreTheme;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
@@ -23,7 +20,6 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes.R
|
||||
public class RestoreThemeEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RestoreThemeEndpointTests"/> class.
|
||||
@@ -40,7 +36,7 @@ public class RestoreThemeEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
// Arrange
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
const string THEME_ID = "test-theme";
|
||||
_apiFactory.ApiClientStub.RegisterPostResponse($"themes/{THEME_ID}/restore", _themeResponseDtoFixture.Create());
|
||||
_apiFactory.ApiClientStub.RegisterPostSuccess($"themes/{THEME_ID}/restore");
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
HttpRequestMessage restoreRequest = new(HttpMethod.Post, $"/en-us/admin/themes/api-restore-theme/{THEME_ID}")
|
||||
{
|
||||
|
||||
+2
-5
@@ -1,11 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Themes;
|
||||
using Lumina.Presentation.Web.Common.Requests.Themes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.SetCurrentTheme;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
@@ -24,7 +22,6 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes.S
|
||||
public class SetCurrentThemeEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
|
||||
private readonly SetCurrentThemeRequestFixture _setCurrentThemeRequestFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +39,7 @@ public class SetCurrentThemeEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
// Arrange
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
const string THEME_ID = "test-theme";
|
||||
_apiFactory.ApiClientStub.RegisterPutResponse("themes/current", _themeResponseDtoFixture.Create());
|
||||
_apiFactory.ApiClientStub.RegisterPutPayload<SetCurrentThemeRequest>("themes/current");
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
HttpRequestMessage setCurrentThemeRequest = new(HttpMethod.Put, "/en-us/admin/themes/api-set-current-theme")
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user