Hero: een gewijzigd focuspunt geldt pas bij het opslaan van de hero (Bryan); het focus-venster houdt de wijziging lokaal
Het eindpunt PUT /hero/images/{id}/focus is vervallen; de focus gaat mee in de opslag (imageFocus) en de varianten worden dan in nieuwe bestanden opnieuw gesneden.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -96,20 +96,21 @@ public class HeroAsfSiteE2ETests : IClassFixture<AsfSiteFactory>
|
||||
{
|
||||
var seed = JsonDocument.Parse(File.ReadAllText(Path.Combine(web, "contract", "host-injection", "hero", "seed.json"))).RootElement;
|
||||
var slides = new List<HeroSlideRequest>();
|
||||
var focusEdits = new List<HeroImageFocusRequest>();
|
||||
foreach (var slide in seed.GetProperty("slides").EnumerateArray())
|
||||
{
|
||||
var photo = File.ReadAllBytes(Path.Combine(web, "src", "assets", slide.GetProperty("file").GetString()!));
|
||||
var image = await InScope(sp => sp.GetRequiredService<IHeroImageService>().UploadAsync(new MemoryStream(photo), photo.Length, caller, default));
|
||||
var focus = slide.GetProperty("focus");
|
||||
await InScope(sp => sp.GetRequiredService<IHeroImageService>().SetFocusAsync(
|
||||
Guid.Parse(image.Id), new HeroFocusRequest(new FocusDto(focus.GetProperty("x").GetDouble(), focus.GetProperty("y").GetDouble(), 1)), caller, default));
|
||||
// The focus travels with the save of the hero, like the admin does it.
|
||||
focusEdits.Add(new HeroImageFocusRequest(Guid.Parse(image.Id), new FocusDto(focus.GetProperty("x").GetDouble(), focus.GetProperty("y").GetDouble(), 1)));
|
||||
slides.Add(new HeroSlideRequest(null, Guid.Parse(image.Id), slide.GetProperty("alt").GetString()));
|
||||
}
|
||||
|
||||
await InScope(sp => sp.GetRequiredService<IHeroService>().SaveAsync(
|
||||
new HeroSaveRequest(seed.GetProperty("title").GetString(), seed.GetProperty("tagline").GetString(), null, seed.GetProperty("display").GetString(),
|
||||
seed.GetProperty("buttons").EnumerateArray().Select(b => new HeroButtonRequest(b.GetProperty("label").GetString(), b.GetProperty("target").GetString())).ToList(),
|
||||
true, null, null, slides), caller, default));
|
||||
true, null, null, slides, focusEdits), caller, default));
|
||||
|
||||
var response = await client.GetAsync("/");
|
||||
var page = await response.Content.ReadAsStringAsync();
|
||||
|
||||
@@ -46,7 +46,6 @@ public class HeroOnTheMasterHostTests : IClassFixture<ApiWebApplicationFactory>
|
||||
[InlineData("PUT", "/api/v1/hero")]
|
||||
[InlineData("POST", "/api/v1/hero/images")]
|
||||
[InlineData("DELETE", "/api/v1/hero/images/11111111-2222-3333-4444-555555555555")]
|
||||
[InlineData("PUT", "/api/v1/hero/images/11111111-2222-3333-4444-555555555555/focus")]
|
||||
public async Task Management_RequiresAnAdministrator(string method, string url)
|
||||
{
|
||||
var request = new HttpRequestMessage(new HttpMethod(method), url);
|
||||
|
||||
Reference in New Issue
Block a user