Files
PnvPanel/backend/tests/PnvPanel.Domain.Tests/Support/SupportTicketTests.cs
T
Leonid Pershin fad03c2834
CI / Backend (build + test) (push) Failing after 1m23s
CI / Frontend (lint + typecheck + build) (push) Successful in 34s
Enhance user plan management and update related endpoints
- Added new configuration options for user plans in `.env.example`, including `Plans__MaxCustomConfigCount` and `Plans__MinCustomConfigCount`.
- Introduced `MapPlanEndpoints` in `Program.cs` to handle plan-related API routes.
- Implemented `SetUserPlan` endpoint in `RoleEndpoints` to allow admins to assign plans to users.
- Removed deprecated role request approval endpoints from `AdminSupportEndpoints`.
- Updated `ITelegramNotifier` and related classes to reflect changes in role request handling and payment notifications.
- Refactored role management commands to remove `MaxConfigs` and focus on `MaxIpLimit` and billing settings.
- Enhanced billing request handling to accommodate plan changes instead of role changes.
- Updated various interfaces and command handlers to support new plan management features.
2026-07-23 22:52:20 +03:00

112 lines
2.7 KiB
C#

using PnvPanel.Domain.Exceptions;
using PnvPanel.Domain.Support;
using Xunit;
namespace PnvPanel.Domain.Tests.Support;
public class SupportTicketTests
{
[Fact]
public void CreateBugReport_SetsOpenStatus()
{
var userId = Guid.NewGuid();
var ticket = SupportTicket.CreateBugReport(userId);
Assert.Equal(userId, ticket.UserId);
Assert.Equal(TicketType.BugReport, ticket.Type);
Assert.Equal(TicketStatus.Open, ticket.Status);
Assert.Null(ticket.RequestedDays);
}
[Fact]
public void CreateExtensionRequest_SetsRequestedDays()
{
var userId = Guid.NewGuid();
var ticket = SupportTicket.CreateExtensionRequest(userId, 14);
Assert.Equal(userId, ticket.UserId);
Assert.Equal(TicketType.ExtensionRequest, ticket.Type);
Assert.Equal(TicketStatus.Open, ticket.Status);
Assert.Equal(14, ticket.RequestedDays);
}
[Fact]
public void Resolve_WhenOpen_SetsResolved()
{
var ticket = SupportTicket.CreateBugReport(Guid.NewGuid());
ticket.Resolve();
Assert.Equal(TicketStatus.Resolved, ticket.Status);
}
[Fact]
public void Resolve_WhenNotOpen_Throws()
{
var ticket = SupportTicket.CreateBugReport(Guid.NewGuid());
ticket.Resolve();
Assert.Throws<DomainException>(() => ticket.Resolve());
}
[Fact]
public void Close_WhenOpen_SetsClosed()
{
var ticket = SupportTicket.CreateBugReport(Guid.NewGuid());
ticket.Close();
Assert.Equal(TicketStatus.Closed, ticket.Status);
}
[Fact]
public void Close_WhenResolved_SetsClosed()
{
var ticket = SupportTicket.CreateBugReport(Guid.NewGuid());
ticket.Resolve();
ticket.Close();
Assert.Equal(TicketStatus.Closed, ticket.Status);
}
[Fact]
public void Close_WhenAlreadyClosed_Throws()
{
var ticket = SupportTicket.CreateBugReport(Guid.NewGuid());
ticket.Close();
Assert.Throws<DomainException>(() => ticket.Close());
}
[Fact]
public void Reopen_WhenResolved_SetsOpen()
{
var ticket = SupportTicket.CreateBugReport(Guid.NewGuid());
ticket.Resolve();
ticket.Reopen();
Assert.Equal(TicketStatus.Open, ticket.Status);
}
[Fact]
public void Reopen_WhenOpen_Throws()
{
var ticket = SupportTicket.CreateBugReport(Guid.NewGuid());
Assert.Throws<DomainException>(() => ticket.Reopen());
}
[Fact]
public void Reopen_WhenClosed_Throws()
{
var ticket = SupportTicket.CreateBugReport(Guid.NewGuid());
ticket.Close();
Assert.Throws<DomainException>(() => ticket.Reopen());
}
}