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

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:
2026-08-02 16:23:09 +02:00
co-authored by Claude Sonnet 5
parent b6e9c07c06
commit cfb06b28b6
79 changed files with 4069 additions and 94 deletions
@@ -0,0 +1,186 @@
using FluentAssertions;
using Microsoft.EntityFrameworkCore;
using SlpModularCms.Modules.Offerings.Data;
using SlpModularCms.Modules.Offerings.Data.Entities;
using SlpModularCms.Modules.Offerings.Repositories;
namespace SlpModularCms.Modules.Offerings.Tests.Repositories;
public class OfferingRepositoryTests : IDisposable
{
private readonly OfferingsDbContext _context;
private readonly OfferingRepository _sut;
public OfferingRepositoryTests()
{
var options = new DbContextOptionsBuilder<OfferingsDbContext>()
.UseInMemoryDatabase(Guid.NewGuid().ToString())
.Options;
_context = new OfferingsDbContext(options);
_sut = new OfferingRepository(_context);
}
[Fact]
public async Task GetAllAsync_OrdersByDisplayOrder()
{
await _sut.AddAsync(Offering("B", displayOrder: 1));
await _sut.AddAsync(Offering("A", displayOrder: 0));
await _sut.SaveChangesAsync();
var result = await _sut.GetAllAsync();
result.Select(o => o.Title).Should().ContainInOrder("A", "B");
}
[Fact]
public async Task GetAllAsync_ExcludesSoftDeleted()
{
var deleted = Offering("Deleted", displayOrder: 0);
deleted.IsDeleted = true;
await _sut.AddAsync(deleted);
await _sut.AddAsync(Offering("Active", displayOrder: 1));
await _sut.SaveChangesAsync();
var result = await _sut.GetAllAsync();
result.Should().ContainSingle(o => o.Title == "Active");
}
[Fact]
public async Task GetByIdAsync_ReturnsNull_WhenSoftDeleted()
{
var offering = Offering("Deleted", displayOrder: 0);
offering.IsDeleted = true;
await _sut.AddAsync(offering);
await _sut.SaveChangesAsync();
var result = await _sut.GetByIdAsync(offering.Id);
result.Should().BeNull();
}
[Fact]
public async Task GetMaxDisplayOrderAsync_ReturnsMinusOne_WhenEmpty()
{
var result = await _sut.GetMaxDisplayOrderAsync();
result.Should().Be(-1);
}
[Fact]
public async Task GetMaxDisplayOrderAsync_ReturnsHighestValue()
{
await _sut.AddAsync(Offering("A", displayOrder: 3));
await _sut.AddAsync(Offering("B", displayOrder: 7));
await _sut.SaveChangesAsync();
var result = await _sut.GetMaxDisplayOrderAsync();
result.Should().Be(7);
}
[Fact]
public async Task GetFeaturedAsync_ReturnsFeaturedOffering()
{
var featured = Offering("Featured", displayOrder: 0);
featured.Featured = true;
await _sut.AddAsync(featured);
await _sut.AddAsync(Offering("Other", displayOrder: 1));
await _sut.SaveChangesAsync();
var result = await _sut.GetFeaturedAsync();
result.Should().NotBeNull();
result!.Title.Should().Be("Featured");
}
[Fact]
public async Task GetFeaturedAsync_ReturnsNull_WhenNoneFeatured()
{
await _sut.AddAsync(Offering("A", displayOrder: 0));
await _sut.SaveChangesAsync();
var result = await _sut.GetFeaturedAsync();
result.Should().BeNull();
}
[Fact]
public async Task GetPreviousAsync_ReturnsClosestLowerDisplayOrder()
{
await _sut.AddAsync(Offering("First", displayOrder: 0));
await _sut.AddAsync(Offering("Second", displayOrder: 1));
await _sut.AddAsync(Offering("Third", displayOrder: 2));
await _sut.SaveChangesAsync();
var result = await _sut.GetPreviousAsync(2);
result!.Title.Should().Be("Second");
}
[Fact]
public async Task GetPreviousAsync_ReturnsNull_WhenFirst()
{
await _sut.AddAsync(Offering("First", displayOrder: 0));
await _sut.SaveChangesAsync();
var result = await _sut.GetPreviousAsync(0);
result.Should().BeNull();
}
[Fact]
public async Task GetNextAsync_ReturnsClosestHigherDisplayOrder()
{
await _sut.AddAsync(Offering("First", displayOrder: 0));
await _sut.AddAsync(Offering("Second", displayOrder: 1));
await _sut.SaveChangesAsync();
var result = await _sut.GetNextAsync(0);
result!.Title.Should().Be("Second");
}
[Fact]
public async Task GetNextAsync_ReturnsNull_WhenLast()
{
await _sut.AddAsync(Offering("Last", displayOrder: 0));
await _sut.SaveChangesAsync();
var result = await _sut.GetNextAsync(0);
result.Should().BeNull();
}
[Fact]
public async Task Update_PersistsChanges()
{
var offering = Offering("Original", displayOrder: 0);
await _sut.AddAsync(offering);
await _sut.SaveChangesAsync();
offering.Title = "Updated";
_sut.Update(offering);
await _sut.SaveChangesAsync();
var result = await _sut.GetByIdAsync(offering.Id);
result!.Title.Should().Be("Updated");
}
private static Offering Offering(string title, int displayOrder) => new()
{
Id = Guid.NewGuid(),
Title = title,
Description = "Description",
Price = "€ 100",
PriceNote = "per month",
Features = ["Feature 1"],
CtaLabel = "Contact",
DisplayOrder = displayOrder,
CreatedAt = DateTimeOffset.UtcNow,
UpdatedAt = DateTimeOffset.UtcNow,
LastModifiedByUserId = Guid.NewGuid(),
};
public void Dispose() => _context.Dispose();
}