Adds the Offerings module and retargets the CI/CD pipeline to Api.SlpSoftware
Continuous Integration / config (pull_request) Successful in 12s
Continuous Integration / changes (pull_request) Successful in 22s
Continuous Integration / backend-build (pull_request) Successful in 5m53s
Continuous Integration / vulnerability-scan (pull_request) Successful in 5m46s
Continuous Integration / frontend-prepare (pull_request) Successful in 1m54s
Continuous Integration / backend-test (pull_request) Successful in 7m37s
Continuous Integration / frontend-build (pull_request) Successful in 2m14s
Continuous Integration / frontend-test (pull_request) Successful in 4m59s
Continuous Integration / frontend-lint (pull_request) Successful in 2m2s
Continuous Integration / publish-production (pull_request) Skipped
Continuous Integration / deploy-production (pull_request) Skipped
Continuous Integration / publish-test (pull_request) Successful in 7m34s
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / config (pull_request) Successful in 12s
Continuous Integration / changes (pull_request) Successful in 22s
Continuous Integration / backend-build (pull_request) Successful in 5m53s
Continuous Integration / vulnerability-scan (pull_request) Successful in 5m46s
Continuous Integration / frontend-prepare (pull_request) Successful in 1m54s
Continuous Integration / backend-test (pull_request) Successful in 7m37s
Continuous Integration / frontend-build (pull_request) Successful in 2m14s
Continuous Integration / frontend-test (pull_request) Successful in 4m59s
Continuous Integration / frontend-lint (pull_request) Successful in 2m2s
Continuous Integration / publish-production (pull_request) Skipped
Continuous Integration / deploy-production (pull_request) Skipped
Continuous Integration / publish-test (pull_request) Successful in 7m34s
Continuous Integration / deploy-test (pull_request) Skipped
Implements Unit 2 "Offerings" (backend module, admin CRUD UI with drag-and-drop reordering, public GET /api/v1/offerings endpoint) and executes the feature's D-15 CI/CD cutover, switching the deploy pipeline's build/publish target from SlpModularCms.Api to SlpModularCms.Api.SlpSoftware. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWyStNL2ZsjrS7FLd7xvvN
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
using System.Security.Claims;
|
||||
using FluentAssertions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NSubstitute;
|
||||
using SlpModularCms.Modules.Offerings.Controllers;
|
||||
using SlpModularCms.Modules.Offerings.Models;
|
||||
using SlpModularCms.Modules.Offerings.Services;
|
||||
|
||||
namespace SlpModularCms.Modules.Offerings.Tests.Controllers;
|
||||
|
||||
public class OfferingsControllerTests
|
||||
{
|
||||
private readonly IOfferingsService _service = Substitute.For<IOfferingsService>();
|
||||
|
||||
private OfferingsController CreateSut()
|
||||
{
|
||||
var httpContext = new DefaultHttpContext
|
||||
{
|
||||
User = new ClaimsPrincipal(new ClaimsIdentity(
|
||||
[new Claim(ClaimTypes.NameIdentifier, Guid.NewGuid().ToString())], "TestAuth")),
|
||||
};
|
||||
return new OfferingsController(_service) { ControllerContext = new ControllerContext { HttpContext = httpContext } };
|
||||
}
|
||||
|
||||
private static OfferingDto PublicDto() => new(
|
||||
Guid.NewGuid().ToString(), "Title", "Description", "€ 100", "per month", ["Feature 1"], "Contact", false);
|
||||
|
||||
private static OfferingAdminDto AdminDto(int displayOrder = 0) => new(
|
||||
Guid.NewGuid().ToString(), "Title", "Description", "€ 100", "per month", ["Feature 1"], "Contact", false, displayOrder);
|
||||
|
||||
private static CreateOfferingRequest CreateRequest() => new(
|
||||
"Title", "Description", "€ 100", "per month", ["Feature 1"], "Contact");
|
||||
|
||||
private static UpdateOfferingRequest UpdateRequest() => new(
|
||||
"Title", "Description", "€ 100", "per month", ["Feature 1"], "Contact");
|
||||
|
||||
// --- GetOfferings (public) ---
|
||||
|
||||
[Fact]
|
||||
public async Task GetOfferings_Returns200_WithList()
|
||||
{
|
||||
_service.GetPublicOfferingsAsync().Returns([PublicDto()]);
|
||||
|
||||
var result = await CreateSut().GetOfferings();
|
||||
|
||||
result.Should().BeOfType<OkObjectResult>().Which.StatusCode.Should().Be(200);
|
||||
}
|
||||
|
||||
// --- GetAllForAdmin ---
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllForAdmin_Returns200_WithList()
|
||||
{
|
||||
_service.GetAllForAdminAsync().Returns([AdminDto()]);
|
||||
|
||||
var result = await CreateSut().GetAllForAdmin();
|
||||
|
||||
result.Should().BeOfType<OkObjectResult>().Which.StatusCode.Should().Be(200);
|
||||
}
|
||||
|
||||
// --- Create ---
|
||||
|
||||
[Fact]
|
||||
public async Task Create_Returns201Created()
|
||||
{
|
||||
_service.CreateAsync(Arg.Any<CreateOfferingRequest>(), Arg.Any<Guid>()).Returns(AdminDto());
|
||||
|
||||
var result = await CreateSut().Create(CreateRequest());
|
||||
|
||||
result.Should().BeOfType<CreatedAtActionResult>().Which.StatusCode.Should().Be(201);
|
||||
}
|
||||
|
||||
// --- Update ---
|
||||
|
||||
[Fact]
|
||||
public async Task Update_Returns200_WhenFound()
|
||||
{
|
||||
_service.UpdateAsync(Arg.Any<Guid>(), Arg.Any<UpdateOfferingRequest>(), Arg.Any<Guid>()).Returns(AdminDto());
|
||||
|
||||
var result = await CreateSut().Update(Guid.NewGuid(), UpdateRequest());
|
||||
|
||||
result.Should().BeOfType<OkObjectResult>().Which.StatusCode.Should().Be(200);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Update_Returns404_WhenNotFound()
|
||||
{
|
||||
_service.UpdateAsync(Arg.Any<Guid>(), Arg.Any<UpdateOfferingRequest>(), Arg.Any<Guid>())
|
||||
.Returns((OfferingAdminDto?)null);
|
||||
|
||||
var result = await CreateSut().Update(Guid.NewGuid(), UpdateRequest());
|
||||
|
||||
result.Should().BeOfType<NotFoundResult>();
|
||||
}
|
||||
|
||||
// --- Delete ---
|
||||
|
||||
[Fact]
|
||||
public async Task Delete_Returns204_WhenDeleted()
|
||||
{
|
||||
_service.DeleteAsync(Arg.Any<Guid>(), Arg.Any<Guid>()).Returns(true);
|
||||
|
||||
var result = await CreateSut().Delete(Guid.NewGuid());
|
||||
|
||||
result.Should().BeOfType<NoContentResult>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Delete_Returns404_WhenNotFound()
|
||||
{
|
||||
_service.DeleteAsync(Arg.Any<Guid>(), Arg.Any<Guid>()).Returns(false);
|
||||
|
||||
var result = await CreateSut().Delete(Guid.NewGuid());
|
||||
|
||||
result.Should().BeOfType<NotFoundResult>();
|
||||
}
|
||||
|
||||
// --- Reorder / MoveUp / MoveDown ---
|
||||
|
||||
[Fact]
|
||||
public async Task Reorder_Returns204()
|
||||
{
|
||||
var result = await CreateSut().Reorder(new ReorderOfferingsRequest([Guid.NewGuid()]));
|
||||
|
||||
result.Should().BeOfType<NoContentResult>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MoveUp_Returns204()
|
||||
{
|
||||
var result = await CreateSut().MoveUp(Guid.NewGuid());
|
||||
|
||||
result.Should().BeOfType<NoContentResult>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MoveDown_Returns204()
|
||||
{
|
||||
var result = await CreateSut().MoveDown(Guid.NewGuid());
|
||||
|
||||
result.Should().BeOfType<NoContentResult>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user