WIP: bulkbalk boven de lijst, definitief verwijderen en prullenbak legen, uitsnede direct zonder opslaan, teller per batch
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using FluentAssertions;
|
||||
using SlpModularCms.Modules.Hero.Models;
|
||||
using SlpModularCms.Modules.Hero.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace SlpModularCms.Modules.Hero.Tests;
|
||||
|
||||
/// <summary>A new crop works at once, without saving the hero (Bryan, 2026-11-17).</summary>
|
||||
public class HeroSetFocusTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task A_new_crop_starts_processing_at_once_and_goes_live_without_saving_the_hero()
|
||||
{
|
||||
using var rig = new HeroTestRig();
|
||||
var uploaded = await rig.Upload(HeroTestRig.Photo());
|
||||
var id = Guid.Parse(uploaded.Id);
|
||||
var before = rig.Db.HeroImages.Single(i => i.Id == id).SetHash;
|
||||
|
||||
var answer = await rig.Images.SetFocusAsync(id, new HeroFocusRequest(new FocusDto(0.2, 0.3, 1.5)), HeroTestRig.Admin, CancellationToken.None);
|
||||
|
||||
answer.Should().NotBeNull();
|
||||
answer!.Processing.Should().BeTrue("the new variants still have to be cut");
|
||||
answer.Focus.Should().Be(new FocusDto(0.2, 0.3, 1.5));
|
||||
rig.Db.HeroImages.Single(i => i.Id == id).SetHash.Should().Be(before, "the old set stays live until the new one is complete");
|
||||
|
||||
(await rig.RenderPending()).Should().Be(1);
|
||||
|
||||
var after = (await rig.Images.GetImageAsync(id, CancellationToken.None))!;
|
||||
after.Processing.Should().BeFalse();
|
||||
rig.Db.HeroImages.Single(i => i.Id == id).SetHash.Should().NotBe(before);
|
||||
rig.Db.Heroes.Should().BeEmpty("the hero itself was never saved");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task An_unknown_image_gives_null_and_a_trashed_image_cannot_be_cropped()
|
||||
{
|
||||
using var rig = new HeroTestRig();
|
||||
var uploaded = await rig.Upload(HeroTestRig.Photo());
|
||||
await new HeroMediaUsageProvider(rig.Repository, rig.Images).TrashAsync(Guid.Parse(uploaded.Id), HeroTestRig.Admin, CancellationToken.None);
|
||||
var request = new HeroFocusRequest(new FocusDto(0.5, 0.5, 1));
|
||||
|
||||
(await rig.Images.SetFocusAsync(Guid.NewGuid(), request, HeroTestRig.Admin, CancellationToken.None)).Should().BeNull();
|
||||
(await rig.Images.SetFocusAsync(Guid.Parse(uploaded.Id), request, HeroTestRig.Admin, CancellationToken.None)).Should().BeNull();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user