Adds user settings management

Adds the UserSettings aggregate with pagination and alpha picker preferences, keyed to a user with a dedicated UserId foreign key. Adds GET and PUT /users/me/settings API endpoints, a localized Tools > Settings page with save confirmation, the EF migration for the UserSettings table, and unit, integration and security tests.
This commit is contained in:
BinaryAlley committed 2026-08-16 08:37:33 -07:00
1 parent c3f8786fe4
commit 2354e21d42
65 files changed
+4711 -21

No files matched your search

@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
/// <summary>
/// Fixture class for the <see cref="UserSettingsEntity"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserSettingsEntityFixture
{
/// <summary>
/// Creates a random valid <see cref="UserSettingsEntity"/>.
/// </summary>
/// <param name="id">Optional. The Id of the user settings.</param>
/// <param name="userId">Optional. The Id of the user that owns these settings.</param>
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user, or not.</param>
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
/// <param name="ignoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
/// <returns>The created user settings entity.</returns>
public UserSettingsEntity Create(
Guid? id = null,
Guid? userId = null,
bool? isPaginationEnabled = null,
int? itemsPerPage = null,
bool? ignoreThePrefixForAlphaPicker = null)
{
return new Faker<UserSettingsEntity>()
.CustomInstantiator(f => new UserSettingsEntity
{
Id = id ?? Guid.NewGuid(),
UserId = userId ?? Guid.NewGuid(),
IsPaginationEnabled = isPaginationEnabled ?? f.Random.Bool(),
ItemsPerPage = itemsPerPage ?? f.Random.Int(1, 100),
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker ?? f.Random.Bool()
})
.Generate();
}
/// <summary>
/// Creates a list of <see cref="UserSettingsEntity"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UserSettingsEntity"/> instances.</returns>
public List<UserSettingsEntity> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSettings;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Application.Fixtures.Core.UsersManagement.Settings.Commands.UpdateUserSettings;
/// <summary>
/// Fixture class for the <see cref="UpdateUserSettingsCommand"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateUserSettingsCommandFixture
{
/// <summary>
/// Creates a random valid command to update the settings of the current user.
/// </summary>
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user, or not.</param>
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
/// <param name="ignoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
/// <returns>The created command.</returns>
public UpdateUserSettingsCommand Create(
bool? isPaginationEnabled = null,
int? itemsPerPage = null,
bool? ignoreThePrefixForAlphaPicker = null)
{
return new Faker<UpdateUserSettingsCommand>()
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default))
.RuleFor(x => x.IsPaginationEnabled, f => isPaginationEnabled ?? f.Random.Bool())
.RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100))
.RuleFor(x => x.IgnoreThePrefixForAlphaPicker, f => ignoreThePrefixForAlphaPicker ?? f.Random.Bool())
.Generate();
}
/// <summary>
/// Creates a list of <see cref="UpdateUserSettingsCommand"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateUserSettingsCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}