As a user I want the dashboard resume strip to show the actual document thumbnail so I recognize what I was working on at a glance #314
@@ -1,5 +1,7 @@
|
|||||||
package org.raddatz.familienarchiv.model;
|
package org.raddatz.familienarchiv.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -58,4 +60,26 @@ class DocumentTest {
|
|||||||
String expected = "/api/documents/" + id + "/thumbnail?v=2026-04-23T14%3A30%3A45";
|
String expected = "/api/documents/" + id + "/thumbnail?v=2026-04-23T14%3A30%3A45";
|
||||||
assertThat(doc.getThumbnailUrl()).isEqualTo(expected);
|
assertThat(doc.getThumbnailUrl()).isEqualTo(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void thumbnailUrl_isSerialisedToJson_soFrontendReceivesIt() throws Exception {
|
||||||
|
UUID id = UUID.fromString("99999999-aaaa-bbbb-cccc-111122223333");
|
||||||
|
Document doc = Document.builder()
|
||||||
|
.id(id)
|
||||||
|
.title("Brief")
|
||||||
|
.originalFilename("brief.pdf")
|
||||||
|
.status(DocumentStatus.UPLOADED)
|
||||||
|
.thumbnailKey("thumbnails/" + id + ".jpg")
|
||||||
|
.thumbnailGeneratedAt(LocalDateTime.of(2026, 4, 23, 9, 0, 0))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper().registerModule(new JavaTimeModule());
|
||||||
|
String json = mapper.writeValueAsString(doc);
|
||||||
|
|
||||||
|
// Locks the wire contract, not just the Java API: every Document JSON must carry
|
||||||
|
// `thumbnailUrl`. Protects against silent breakage if the getter gets renamed,
|
||||||
|
// hidden behind @JsonIgnore, or visibility-reduced — any of which would leave the
|
||||||
|
// frontend rendering the fallback icon on every surface.
|
||||||
|
assertThat(json).contains("\"thumbnailUrl\":\"" + doc.getThumbnailUrl() + "\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user