mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 02:01:10 +00:00
Adapts the theme integration tests to the bundled lumina-default theme
This commit is contained in:
1 parent
85849783b3
commit
75281f48ef
5 files changed
+18
-10
No files matched your search
+3
-3
@@ -17,7 +17,7 @@ namespace Lumina.Presentation.Api.IntegrationTests.Common.Setup;
|
||||
public static class ThemeTestHelpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Waits until the bundled 'editorial-paper' theme has been installed and activated by the theme detection job at startup.
|
||||
/// Waits until the bundled 'lumina-default' theme has been installed and activated by the theme detection job at startup.
|
||||
/// </summary>
|
||||
/// <param name="apiFactory">The shared API factory whose database is polled.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
@@ -31,12 +31,12 @@ public static class ThemeTestHelpers
|
||||
using IServiceScope scope = apiFactory.Services.CreateScope();
|
||||
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService<LuminaDbContext>();
|
||||
|
||||
if (await dbContext.Themes.AnyAsync(theme => theme.ThemeId == "editorial-paper" && theme.IsCurrent == true))
|
||||
if (await dbContext.Themes.AnyAsync(theme => theme.ThemeId == "lumina-default" && theme.IsCurrent == true))
|
||||
return;
|
||||
|
||||
await Task.Delay(DELAY_MILLISECONDS);
|
||||
}
|
||||
|
||||
Assert.Fail("The bundled theme 'editorial-paper' was not installed and activated within the expected time.");
|
||||
Assert.Fail("The bundled theme 'lumina-default' was not installed and activated within the expected time.");
|
||||
}
|
||||
}
|
||||
+11
-3
@@ -114,8 +114,12 @@ public class DeleteThemeEndpointTests : IClassFixture<AuthenticatedLuminaApiFact
|
||||
// Arrange
|
||||
await ThemeTestHelpers.WaitForBundledThemeAsync(_apiFactory);
|
||||
|
||||
// Act
|
||||
HttpResponseMessage response = await _client.DeleteAsync("/api/v1/themes/editorial-paper");
|
||||
// deleting a bundled theme that is not the last remaining one is allowed, so only the last one is protected
|
||||
HttpResponseMessage firstDeletionResponse = await _client.DeleteAsync("/api/v1/themes/editorial-paper");
|
||||
Assert.Equal(HttpStatusCode.NoContent, firstDeletionResponse.StatusCode);
|
||||
|
||||
// Act: the last remaining bundled theme cannot be deleted
|
||||
HttpResponseMessage response = await _client.DeleteAsync("/api/v1/themes/lumina-default");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||
@@ -127,9 +131,13 @@ public class DeleteThemeEndpointTests : IClassFixture<AuthenticatedLuminaApiFact
|
||||
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemDetails["type"].GetString());
|
||||
Assert.Equal("General.Forbidden", problemDetails["title"].GetString());
|
||||
Assert.Equal("LastBundledThemeCannotBeDeleted", problemDetails["detail"].GetString());
|
||||
Assert.Equal("/api/v1/themes/editorial-paper", problemDetails["instance"].GetString());
|
||||
Assert.Equal("/api/v1/themes/lumina-default", problemDetails["instance"].GetString());
|
||||
Assert.NotNull(problemDetails["traceId"].GetString());
|
||||
Assert.NotEmpty(problemDetails["traceId"].GetString()!);
|
||||
|
||||
// restore the soft-deleted bundled theme, so the following tests start from a clean state
|
||||
HttpResponseMessage restoreResponse = await _client.PostAsJsonAsync("/api/v1/themes/editorial-paper/restore", new { });
|
||||
Assert.Equal(HttpStatusCode.NoContent, restoreResponse.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+2
-2
@@ -220,8 +220,8 @@ public class SetCurrentThemeEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
}
|
||||
}
|
||||
|
||||
// restore the bundled theme as the active one, so the following tests start from a clean state
|
||||
ThemeEntity? bundledTheme = await dbContext.Themes.FirstOrDefaultAsync(t => t.ThemeId == "editorial-paper");
|
||||
// restore the bundled default theme as the active one, so the following tests start from a clean state
|
||||
ThemeEntity? bundledTheme = await dbContext.Themes.FirstOrDefaultAsync(t => t.ThemeId == "lumina-default");
|
||||
if (bundledTheme is not null)
|
||||
bundledTheme.IsCurrent = true;
|
||||
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class GetCurrentThemeEndpointTests : IClassFixture<AuthenticatedLuminaApi
|
||||
|
||||
ThemeResponse? theme = await response.Content.ReadFromJsonAsync<ThemeResponse>(_jsonOptions);
|
||||
Assert.NotNull(theme);
|
||||
Assert.Equal("editorial-paper", theme!.ThemeId);
|
||||
Assert.Equal("lumina-default", theme!.ThemeId);
|
||||
Assert.True(theme.IsCurrent);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class GetThemesEndpointTests : IClassFixture<AuthenticatedLuminaApiFactor
|
||||
List<ThemeResponse>? themes = await response.Content.ReadFromJsonAsync<List<ThemeResponse>>(_jsonOptions);
|
||||
Assert.NotNull(themes);
|
||||
|
||||
ThemeResponse? bundledTheme = themes!.FirstOrDefault(theme => theme.ThemeId == "editorial-paper");
|
||||
ThemeResponse? bundledTheme = themes!.FirstOrDefault(theme => theme.ThemeId == "lumina-default");
|
||||
Assert.NotNull(bundledTheme);
|
||||
Assert.NotEmpty(bundledTheme!.Name);
|
||||
Assert.Equal(ThemeInstallSource.Bundled, bundledTheme.InstallSource);
|
||||
|
||||
Reference in new issue
Block a user