From 0def9e9b9df4e33edb670d7ae57699aa0990b233 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 28 Apr 2026 21:39:13 +0200 Subject: [PATCH] test(transcription): mirror displayName length-cap regression on PUT endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sara #4 (PR #366 review). The 400-on-201-chars regression guard previously only covered POST /api/documents/{id}/transcription-blocks. The same @Valid cascade applies to PUT /api/documents/{id}/transcription-blocks/{blockId} via UpdateTranscriptionBlockDTO, but no test asserted it — meaning a silent removal of @Valid on the PUT @RequestBody parameter would slip past CI. Mirror the test for symmetry. Refs #362 #366 Co-Authored-By: Claude Opus 4.7 --- .../TranscriptionBlockControllerTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/src/test/java/org/raddatz/familienarchiv/controller/TranscriptionBlockControllerTest.java b/backend/src/test/java/org/raddatz/familienarchiv/controller/TranscriptionBlockControllerTest.java index 68ccacfb..0d39884a 100644 --- a/backend/src/test/java/org/raddatz/familienarchiv/controller/TranscriptionBlockControllerTest.java +++ b/backend/src/test/java/org/raddatz/familienarchiv/controller/TranscriptionBlockControllerTest.java @@ -251,6 +251,21 @@ class TranscriptionBlockControllerTest { .andExpect(jsonPath("$.label").value("Anrede")); } + @Test + @WithMockUser(authorities = "WRITE_ALL") + void updateBlock_returns400_whenMentionedPersonDisplayNameExceeds200Chars() throws Exception { + when(userService.findByEmail(any())).thenReturn(mockUser()); + String longName = "A".repeat(201); + String body = "{\"text\":\"x\",\"mentionedPersons\":[{\"personId\":\"" + + UUID.randomUUID() + "\",\"displayName\":\"" + longName + "\"}]}"; + + mockMvc.perform(put(URL_BLOCK) + .contentType(MediaType.APPLICATION_JSON) + .content(body)) + .andExpect(status().isBadRequest()) + .andExpect(jsonPath("$.code").value("VALIDATION_ERROR")); + } + @Test @WithMockUser(authorities = "WRITE_ALL") void updateBlock_returns404_whenBlockDoesNotExist() throws Exception {