Add instructions management functionality and update related components
- Introduced new endpoints for managing instruction intros and tabs, allowing admins to create, update, and delete instructional content. - Enhanced the FactoryResetCommandHandler to include the seeding of instruction data during a factory reset. - Updated the database schema to include InstructionIntro and InstructionTab entities, with corresponding migrations. - Improved frontend routing and components to support the new instructions section, including a dedicated page for displaying instructions and tabs. - Enhanced API documentation to reflect the new instruction management features and their expected request/response formats. - Added localization support for the new instructions functionality in both Russian and English.
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
using PnvPanel.Application.Instructions;
|
||||
using PnvPanel.Application.Tests.TestSupport;
|
||||
using PnvPanel.Domain.Instructions;
|
||||
using Xunit;
|
||||
|
||||
namespace PnvPanel.Application.Tests.Instructions;
|
||||
|
||||
public class GetInstructionIntroQueryHandlerTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Handle_WhenNoIntroSeeded_ReturnsEmptyDefault()
|
||||
{
|
||||
using var dbContext = InMemoryDbContextFactory.Create();
|
||||
var handler = new GetInstructionIntroQueryHandler(dbContext);
|
||||
|
||||
var result = await handler.Handle(new GetInstructionIntroQuery(), CancellationToken.None);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.Equal(string.Empty, result.Value.Body);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Handle_WhenIntroExists_ReturnsIt()
|
||||
{
|
||||
using var dbContext = InMemoryDbContextFactory.Create();
|
||||
var intro = InstructionIntro.Create("Привет, это инструкция.");
|
||||
dbContext.InstructionIntros.Add(intro);
|
||||
await dbContext.SaveChangesAsync(CancellationToken.None);
|
||||
|
||||
var handler = new GetInstructionIntroQueryHandler(dbContext);
|
||||
|
||||
var result = await handler.Handle(new GetInstructionIntroQuery(), CancellationToken.None);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.Equal("Привет, это инструкция.", result.Value.Body);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
using PnvPanel.Application.Instructions;
|
||||
using PnvPanel.Application.Tests.TestSupport;
|
||||
using PnvPanel.Domain.Instructions;
|
||||
using Xunit;
|
||||
|
||||
namespace PnvPanel.Application.Tests.Instructions;
|
||||
|
||||
public class ListInstructionTabsQueryHandlerTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Handle_ReturnsTabsOrderedBySortOrder()
|
||||
{
|
||||
using var dbContext = InMemoryDbContextFactory.Create();
|
||||
dbContext.InstructionTabs.AddRange(
|
||||
InstructionTab.Create("Второй", "текст", 20),
|
||||
InstructionTab.Create("Первый", "текст", 10),
|
||||
InstructionTab.Create("Третий", "текст", 30)
|
||||
);
|
||||
await dbContext.SaveChangesAsync(CancellationToken.None);
|
||||
|
||||
var handler = new ListInstructionTabsQueryHandler(dbContext);
|
||||
|
||||
var result = await handler.Handle(new ListInstructionTabsQuery(), CancellationToken.None);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.Equal(["Первый", "Второй", "Третий"], result.Value.Select(t => t.Title));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Handle_WhenNoTabs_ReturnsEmptyList()
|
||||
{
|
||||
using var dbContext = InMemoryDbContextFactory.Create();
|
||||
var handler = new ListInstructionTabsQueryHandler(dbContext);
|
||||
|
||||
var result = await handler.Handle(new ListInstructionTabsQuery(), CancellationToken.None);
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.Empty(result.Value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user