Hero-admin: foto klikbaar voor de uitsnede, direct voorbeeld na Toepassen, Opslaan uitgegrijsd zonder wijzigingen
- De thumbnail is de knop 'Uitsnede aanpassen' (hint bij hover/focus, kleine crop-icoon altijd zichtbaar voor touch); losse focusknop vervalt - Na Toepassen toont de thumbnail direct de nieuwe uitsnede (zelfde rekenlogica als de host) met 'Focus gewijzigd, nog niet opgeslagen' - Opslaan is uitgeschakeld (aria-disabled) zolang er niets te bewaren is, bezig-indicator tijdens opslaan, weer uit na opslaan - Test van de keten: Toepassen, Opslaan (imageFocus in de PUT), 'Nieuwe uitsnede wordt gemaakt', 'Verwerking afgerond'; backend: PUT-body bindt, status direct pending, renderer klaar - Logregel 'recut superseded' als een nieuwere focus de lopende uitsnede overneemt Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -372,4 +372,51 @@ public class HeroFocusSaveTests
|
||||
done.Variants.Should().NotBeEmpty();
|
||||
(await rig.Images.GetImageAsync(Guid.NewGuid(), default)).Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task APutWithAChangedFocus_ShowsTheImageAsBeingRecut_InTheNextAdminRead_AndAsReadyAfterTheRenderer()
|
||||
{
|
||||
using var rig = new HeroTestRig();
|
||||
var image = await rig.Upload(HeroTestRig.Photo(2400, 1600));
|
||||
var id = Guid.Parse(image.Id);
|
||||
await rig.Service.SaveAsync(Save(id, null), HeroTestRig.Admin, default);
|
||||
(await rig.Service.GetAsync(default)).Slides[0].Image.Processing.Should().BeFalse();
|
||||
|
||||
// The body of the PUT as the admin sends it (camelCase JSON), bound the way the controller binds it.
|
||||
var json = $$"""
|
||||
{"title":"Andrea Slop","tagline":null,"lead":null,"display":"single","buttons":[],"isActive":true,"startsAt":null,"endsAt":null,
|
||||
"slides":[{"id":null,"imageId":"{{id}}","alt":"foto","decorative":false,"isActive":true}],
|
||||
"imageFocus":[{"imageId":"{{id}}","focus":{"x":0.2,"y":0.3,"zoom":1.5},"wide":null,"tall":null}]}
|
||||
""";
|
||||
var request = System.Text.Json.JsonSerializer.Deserialize<HeroSaveRequest>(json, new System.Text.Json.JsonSerializerOptions(System.Text.Json.JsonSerializerDefaults.Web))!;
|
||||
request.ImageFocus.Should().ContainSingle().Which.Focus.Should().Be(new FocusDto(0.2, 0.3, 1.5));
|
||||
|
||||
var response = await rig.Service.SaveAsync(request, HeroTestRig.Admin, default);
|
||||
|
||||
response.Slides.Single(s => s.ImageId == image.Id).Image.Processing.Should().BeTrue("the answer of the PUT already says the new crop is being made");
|
||||
var read = (await rig.Service.GetAsync(default)).Slides.Single(s => s.ImageId == image.Id).Image;
|
||||
read.Processing.Should().BeTrue();
|
||||
read.Variants.Should().NotBeEmpty("the old crop stays published meanwhile");
|
||||
|
||||
(await rig.RenderPending()).Should().Be(1);
|
||||
|
||||
var done = (await rig.Service.GetAsync(default)).Slides.Single(s => s.ImageId == image.Id).Image;
|
||||
done.Processing.Should().BeFalse();
|
||||
done.Focus.Should().Be(new FocusDto(0.2, 0.3, 1.5));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AHigherZoom_GivesASmallerSet_BecauseNoVariantIsMadeLargerThanItsCrop()
|
||||
{
|
||||
using var rig = new HeroTestRig();
|
||||
var image = await rig.Upload(HeroTestRig.Photo(2400, 1600));
|
||||
var id = Guid.Parse(image.Id);
|
||||
await rig.Service.SaveAsync(Save(id, null), HeroTestRig.Admin, default);
|
||||
var normal = rig.Db.HeroImages.Single().Variants.Count;
|
||||
|
||||
await rig.Service.SaveAsync(Save(id, [new HeroImageFocusRequest(id, new FocusDto(0.5, 0.5, 3))]), HeroTestRig.Admin, default);
|
||||
await rig.RenderPending();
|
||||
|
||||
rig.Db.HeroImages.Single().Variants.Count.Should().BeLessThan(normal, "a zoomed crop is smaller, so the wide sizes above it are left out");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ public class HeroImageService(
|
||||
var current = await repository.GetImageFreshAsync(image.Id, cancellationToken);
|
||||
if (current is null || HeroMapping.TargetSetHash(current) != target)
|
||||
{
|
||||
logger.LogInformation("Hero image {ImageId}: the focus changed while its variants were cut; cutting again.", image.Id);
|
||||
logger.LogInformation("Hero image {ImageId}: recut superseded, the focus changed while its variants were being cut; the finished set is dropped and the image is cut again at the newest focus.", image.Id);
|
||||
return image.Id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user