feat(ui): integrate attendance pages with shared shell

This commit is contained in:
sechmachine
2026-08-15 01:16:43 +07:00
parent f8db8a3e8b
commit 3064485007
7 changed files with 205 additions and 50 deletions
@@ -0,0 +1,73 @@
package com.lab.labtimesheet.feature.reporting.controller;
import static org.hamcrest.Matchers.containsString;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.time.LocalDate;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Controller;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@WebMvcTest(AttendanceTemplateIntegrationTest.TemplateController.class)
@Import(AttendanceTemplateIntegrationTest.TemplateController.class)
class AttendanceTemplateIntegrationTest {
private final MockMvc mvc;
@Autowired
AttendanceTemplateIntegrationTest(MockMvc mvc) {
this.mvc = mvc;
}
@Test
void internHistoryUsesSharedShellAndPreservesPunchActions() throws Exception {
mvc.perform(get("/template-contract/attendance/history")
.with(user("intern@example.test").roles("INTERN")))
.andExpect(status().isOk())
.andExpect(content().string(containsString("class=\"app-shell\"")))
.andExpect(content().string(containsString("action=\"/attendance/check-in\"")))
.andExpect(content().string(containsString("action=\"/attendance/check-out\"")))
.andExpect(content().string(containsString("No attendance records in this period")))
.andExpect(content().string(containsString("src=\"/assets/theme.js\"")));
}
@Test
void adminCalendarUsesSharedShellAndPreservesEventForm() throws Exception {
mvc.perform(get("/template-contract/attendance/calendar")
.with(user("admin@example.test").roles("ADMIN")))
.andExpect(status().isOk())
.andExpect(content().string(containsString("class=\"app-shell\"")))
.andExpect(content().string(containsString("action=\"/attendance/calendar\"")))
.andExpect(content().string(containsString("No upcoming calendar events")))
.andExpect(content().string(containsString("src=\"/assets/theme.js\"")));
}
@Controller
public static class TemplateController {
@GetMapping("/template-contract/attendance/history")
String history(Model model) {
model.addAttribute("ownHistory", true);
model.addAttribute("from", LocalDate.of(2026, 8, 1));
model.addAttribute("to", LocalDate.of(2026, 8, 31));
model.addAttribute("items", List.of());
return "attendance/history";
}
@GetMapping("/template-contract/attendance/calendar")
String calendar(Model model) {
model.addAttribute("today", LocalDate.of(2026, 8, 15));
model.addAttribute("events", List.of());
return "attendance/calendar";
}
}
}