Aanbod: RESTful routes zonder /admin, één OfferingDto en herordenen via PUT /offerings/order
Admin en bezoeker gebruiken dezelfde resource; alleen GET is anoniem, de rest vereist AdminOnly. OfferingAdminDto vervalt (displayOrder zit nu in OfferingDto), move-up/move-down zijn vervangen door de order-route die een onbekende of onvolledige lijst met 400 afwijst. De admin-frontend en alle tests zijn mee aangepast. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -267,96 +267,4 @@ public class OfferingsServiceTests
|
||||
offering.DeletedAt.Should().NotBeNull();
|
||||
}
|
||||
|
||||
// --- ReorderAsync / BR-OFF-03 ---
|
||||
|
||||
[Fact]
|
||||
public async Task ReorderAsync_ReassignsDisplayOrderSequentially()
|
||||
{
|
||||
var first = ExistingOffering(displayOrder: 5);
|
||||
var second = ExistingOffering(displayOrder: 2);
|
||||
_repo.GetByIdAsync(first.Id).Returns(first);
|
||||
_repo.GetByIdAsync(second.Id).Returns(second);
|
||||
|
||||
await CreateSut().ReorderAsync([first.Id, second.Id], Guid.NewGuid());
|
||||
|
||||
first.DisplayOrder.Should().Be(0);
|
||||
second.DisplayOrder.Should().Be(1);
|
||||
}
|
||||
|
||||
// --- MoveUpAsync / MoveDownAsync / BR-OFF-03 boundaries ---
|
||||
|
||||
[Fact]
|
||||
public async Task MoveUpAsync_IsNoOp_WhenAlreadyFirst()
|
||||
{
|
||||
var offering = ExistingOffering(displayOrder: 0);
|
||||
_repo.GetByIdAsync(offering.Id).Returns(offering);
|
||||
_repo.GetPreviousAsync(0).Returns((Offering?)null);
|
||||
|
||||
await CreateSut().MoveUpAsync(offering.Id, Guid.NewGuid());
|
||||
|
||||
await _repo.DidNotReceive().BeginTransactionAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MoveUpAsync_SwapsDisplayOrder_WithPrevious()
|
||||
{
|
||||
var offering = ExistingOffering(displayOrder: 1);
|
||||
var previous = ExistingOffering(displayOrder: 0);
|
||||
_repo.GetByIdAsync(offering.Id).Returns(offering);
|
||||
_repo.GetPreviousAsync(1).Returns(previous);
|
||||
|
||||
await CreateSut().MoveUpAsync(offering.Id, Guid.NewGuid());
|
||||
|
||||
offering.DisplayOrder.Should().Be(0);
|
||||
previous.DisplayOrder.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MoveDownAsync_IsNoOp_WhenAlreadyLast()
|
||||
{
|
||||
var offering = ExistingOffering(displayOrder: 0);
|
||||
_repo.GetByIdAsync(offering.Id).Returns(offering);
|
||||
_repo.GetNextAsync(0).Returns((Offering?)null);
|
||||
|
||||
await CreateSut().MoveDownAsync(offering.Id, Guid.NewGuid());
|
||||
|
||||
await _repo.DidNotReceive().BeginTransactionAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MoveDownAsync_SwapsDisplayOrder_WithNext()
|
||||
{
|
||||
var offering = ExistingOffering(displayOrder: 0);
|
||||
var next = ExistingOffering(displayOrder: 1);
|
||||
_repo.GetByIdAsync(offering.Id).Returns(offering);
|
||||
_repo.GetNextAsync(0).Returns(next);
|
||||
|
||||
await CreateSut().MoveDownAsync(offering.Id, Guid.NewGuid());
|
||||
|
||||
offering.DisplayOrder.Should().Be(1);
|
||||
next.DisplayOrder.Should().Be(0);
|
||||
}
|
||||
|
||||
// --- GetPublicOfferingsAsync / GetAllForAdminAsync ---
|
||||
|
||||
[Fact]
|
||||
public async Task GetPublicOfferingsAsync_MapsToPublicDto()
|
||||
{
|
||||
_repo.GetAllAsync().Returns([ExistingOffering()]);
|
||||
|
||||
var result = await CreateSut().GetPublicOfferingsAsync();
|
||||
|
||||
result.Should().ContainSingle();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetAllForAdminAsync_IncludesDisplayOrder()
|
||||
{
|
||||
var offering = ExistingOffering(displayOrder: 3);
|
||||
_repo.GetAllAsync().Returns([offering]);
|
||||
|
||||
var result = await CreateSut().GetAllForAdminAsync();
|
||||
|
||||
result[0].DisplayOrder.Should().Be(3);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user