From c665857ce8f626b40970539e23a3e33db650e49d Mon Sep 17 00:00:00 2001 From: AliceDarkest Date: Mon, 13 Jul 2026 22:45:37 +0200 Subject: [PATCH] Fix progress template rendering --- src/main/resources/templates/progress.html | 6 ++++-- .../com/example/mindflux/SecurityRulesTest.java | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/resources/templates/progress.html b/src/main/resources/templates/progress.html index 262fea0..6d359e3 100644 --- a/src/main/resources/templates/progress.html +++ b/src/main/resources/templates/progress.html @@ -87,6 +87,8 @@ const track = css.getPropertyValue('--surface-2').trim() || '#2c2c2c'; const tick = css.getPropertyValue('--text').trim() || '#f1f1f1'; const grid = css.getPropertyValue('--border').trim() || '#333'; + const xpPercentage = /*[[${xpPercentage}]]*/ 0; + const weeklyMinutes = /*[[${weekly.minutes}]]*/ [0, 0, 0, 0, 0, 0, 0]; // Kreisdiagramm const ctx = document.getElementById('progressCircle').getContext('2d'); @@ -94,7 +96,7 @@ type: 'doughnut', data: { datasets: [{ - data: [/*[[${xpPercentage}]]*/ 0, 100 - /*[[${xpPercentage}]]*/ 0], + data: [xpPercentage, 100 - xpPercentage], backgroundColor: [accent, track], borderWidth: 0 }] @@ -115,7 +117,7 @@ labels: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'], datasets: [{ label: 'Spielzeit (Minuten)', - data: /*[[${weekly.minutes}]]*/ [0, 0, 0, 0, 0, 0, 0], + data: weeklyMinutes, backgroundColor: accent, borderRadius: 6 }] diff --git a/src/test/java/com/example/mindflux/SecurityRulesTest.java b/src/test/java/com/example/mindflux/SecurityRulesTest.java index e301d1e..3593415 100644 --- a/src/test/java/com/example/mindflux/SecurityRulesTest.java +++ b/src/test/java/com/example/mindflux/SecurityRulesTest.java @@ -3,7 +3,9 @@ package com.example.mindflux; import com.example.mindflux.config.SecurityConfig; import com.example.mindflux.controller.AdminUserController; import com.example.mindflux.controller.DashboardController; +import com.example.mindflux.controller.ProgressController; import com.example.mindflux.dto.ProgressData; +import com.example.mindflux.dto.WeeklyActivity; import com.example.mindflux.repository.UserRepository; import com.example.mindflux.service.LoginAttemptService; import com.example.mindflux.service.ProgressService; @@ -18,13 +20,14 @@ import org.springframework.test.web.servlet.MockMvc; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; +import java.util.List; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; /** Absichert die zentralen Security-Regeln: Login-Zwang, Admin-Schutz, gelöschter Legacy-Endpunkt. */ -@WebMvcTest(controllers = {DashboardController.class, AdminUserController.class}) +@WebMvcTest(controllers = {DashboardController.class, ProgressController.class, AdminUserController.class}) @Import(SecurityConfig.class) class SecurityRulesTest { @@ -57,6 +60,18 @@ class SecurityRulesTest { .andExpect(status().isOk()); } + @Test + @WithMockUser(username = "alice") + void eingeloggteNutzerSehenDieFortschrittsseite() throws Exception { + when(progressService.getOverallProgress(anyString())).thenReturn(new ProgressData()); + when(progressService.getGameProgress(anyString())).thenReturn(List.of()); + when(progressService.getCurrentWeekActivity(anyString())).thenReturn( + new WeeklyActivity(List.of(0, 0, 0, 0, 0, 0, 0), List.of(0, 0, 0, 0, 0, 0, 0), 0, 0)); + + mockMvc.perform(get("/progress")) + .andExpect(status().isOk()); + } + @Test @WithMockUser(username = "alice", roles = "USER") void adminBereichIstFuerNormaleNutzerGesperrt() throws Exception {