Enhance admin endpoints and queries for improved filtering and management
CI / Backend (build + test) (push) Successful in 1m22s
CI / Frontend (lint + typecheck + build) (push) Successful in 34s

- Updated `ListPaymentRequestsQuery` to include `Kind` and `Search` parameters for better filtering of payment requests.
- Enhanced `ListAuditLogsQuery` to support additional filters: `Source`, `TargetType`, and `Action`, improving audit log retrieval.
- Modified `ListUsersQuery` to accept new filters: `RoleId`, `IsActivated`, `IsBlocked`, and `BillingExpired`, allowing for more granular user management.
- Introduced `DeleteInbound` endpoint to allow deletion of inbounds that are not currently available, enhancing inbound management capabilities.
- Updated frontend API calls to reflect new query parameters and support for additional filtering options in the admin interface.
- Revised API documentation to include new parameters and endpoint functionalities for better clarity and usage guidance.
This commit is contained in:
Leonid Pershin
2026-07-20 10:35:48 +03:00
parent e19860ba46
commit 33ad98cf62
37 changed files with 1115 additions and 124 deletions
@@ -0,0 +1,75 @@
using PnvPanel.Application.Admin.Audit;
using PnvPanel.Application.Tests.TestSupport;
using PnvPanel.Domain.Audit;
using Xunit;
namespace PnvPanel.Application.Tests.Admin.Audit;
public class ListAuditLogsQueryHandlerTests
{
[Fact]
public async Task Handle_FiltersBySource()
{
using var dbContext = InMemoryDbContextFactory.Create();
dbContext.AuditLogs.AddRange(
AuditLog.Create(null, "BillingSuspended", "User", Guid.NewGuid().ToString(), null, AuditSource.System),
AuditLog.Create(Guid.NewGuid(), "InboundDeleted", "Inbound", Guid.NewGuid().ToString(), null, AuditSource.Web)
);
await dbContext.SaveChangesAsync(CancellationToken.None);
var handler = new ListAuditLogsQueryHandler(dbContext);
var result = await handler.Handle(
new ListAuditLogsQuery(1, 50, AuditSource.System, TargetType: null, Action: null),
CancellationToken.None
);
Assert.True(result.IsSuccess);
var item = Assert.Single(result.Value.Items);
Assert.Equal("BillingSuspended", item.Action);
}
[Fact]
public async Task Handle_FiltersByTargetType()
{
using var dbContext = InMemoryDbContextFactory.Create();
dbContext.AuditLogs.AddRange(
AuditLog.Create(Guid.NewGuid(), "UserBlocked", "User", Guid.NewGuid().ToString(), null, AuditSource.Web),
AuditLog.Create(Guid.NewGuid(), "InboundDeleted", "Inbound", Guid.NewGuid().ToString(), null, AuditSource.Web)
);
await dbContext.SaveChangesAsync(CancellationToken.None);
var handler = new ListAuditLogsQueryHandler(dbContext);
var result = await handler.Handle(
new ListAuditLogsQuery(1, 50, Source: null, TargetType: "Inbound", Action: null),
CancellationToken.None
);
Assert.True(result.IsSuccess);
var item = Assert.Single(result.Value.Items);
Assert.Equal("InboundDeleted", item.Action);
}
[Fact]
public async Task Handle_FiltersByActionSubstring()
{
using var dbContext = InMemoryDbContextFactory.Create();
dbContext.AuditLogs.AddRange(
AuditLog.Create(Guid.NewGuid(), "TicketResolved", "SupportTicket", Guid.NewGuid().ToString(), null, AuditSource.Web),
AuditLog.Create(Guid.NewGuid(), "TicketClosed", "SupportTicket", Guid.NewGuid().ToString(), null, AuditSource.Web)
);
await dbContext.SaveChangesAsync(CancellationToken.None);
var handler = new ListAuditLogsQueryHandler(dbContext);
var result = await handler.Handle(
new ListAuditLogsQuery(1, 50, Source: null, TargetType: null, Action: "Resolved"),
CancellationToken.None
);
Assert.True(result.IsSuccess);
var item = Assert.Single(result.Value.Items);
Assert.Equal("TicketResolved", item.Action);
}
}