feat: Anhänge je Stunde, Klausur-Sitzplan mischen, Gefährdungsbeurteilungs-Assistent
Lesson bekommt dieselbe Anhang-Infrastruktur wie Documentation (Material, Arbeitsblätter, Experimentunterlagen), samt Fix einer Sync-Lücke, die Anhang- Dateibytes bisher nur für Documentation statt generisch übertragen hat (IHasAttachments). Sitzplan-Tab bekommt einen "Plätze mischen"-Button für Klausursitzpläne. Neu: mehrschrittiger Gefährdungsbeurteilungs-Assistent mit optionalem KI-Entwurf (ai-backend/gbu.php) und PDF-Export, Format bewusst als JSON-Anhang statt eigener Datenbank-Entität. Details und Architekturentscheidungen in TODO.md (4.2, 7.1.5, 10.1.8). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -180,6 +180,32 @@ public sealed class EventApplierTests
|
||||
Assert.Empty(handler.Requests);
|
||||
}
|
||||
|
||||
/// Regressionstest für die Verallgemeinerung von "nur Documentation" auf
|
||||
/// <see cref="IHasAttachments"/> — Anhänge an einer <see cref="Lesson"/> (Material,
|
||||
/// Gefährdungsbeurteilung) müssen genauso nachgeladen werden.
|
||||
[Fact]
|
||||
public async Task ApplyAsync_LessonMitFehlendemAnhang_LaedtIhnUeberHttpNach()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var storageId = Guid.NewGuid().ToString("N");
|
||||
var handler = new FakeHttpMessageHandler(req =>
|
||||
{
|
||||
Assert.Equal($"/api/sync/attachments/{storageId}", req.RequestUri!.AbsolutePath);
|
||||
var encrypted = SyncCrypto.Encrypt([9, 8, 7], Key);
|
||||
return new HttpResponseMessage(System.Net.HttpStatusCode.OK)
|
||||
{ Content = new ByteArrayContent(encrypted) };
|
||||
});
|
||||
var http = new HttpClient(handler) { BaseAddress = new Uri("https://example.invalid") };
|
||||
var applier = new EventApplier(db, Key, http);
|
||||
var lesson = new Lesson { UnitId = Guid.NewGuid(), GroupId = Guid.NewGuid(), Topic = "Brechung" };
|
||||
lesson.Attachments.Add(new DocumentAttachment { StorageId = storageId, FileName = "gbu.pdf", SizeBytes = 3 });
|
||||
|
||||
await applier.ApplyAsync(MakeEvent(nameof(Lesson), lesson.Id.ToString(), "Save", lesson));
|
||||
|
||||
Assert.Single(handler.Requests);
|
||||
Assert.True(db.Attachments.Exists(storageId));
|
||||
}
|
||||
|
||||
private static SyncEvent MakeEvent(string entityType, string entityId, string operation, object? payload) => new()
|
||||
{
|
||||
DeviceId = "companion-1",
|
||||
|
||||
Reference in New Issue
Block a user