feat(ui): integrate account pages with shared shell

This commit is contained in:
sechmachine
2026-08-15 00:53:45 +07:00
parent 69b81ddc71
commit 7dd61b9dd4
9 changed files with 236 additions and 28 deletions
@@ -0,0 +1,66 @@
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 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(AccountTemplateIntegrationTest.TemplateController.class)
@Import(AccountTemplateIntegrationTest.TemplateController.class)
class AccountTemplateIntegrationTest {
private final MockMvc mvc;
@Autowired
AccountTemplateIntegrationTest(MockMvc mvc) {
this.mvc = mvc;
}
@Test
void accountCreationUsesAuthenticatedShellAndRealAccountRoute() throws Exception {
mvc.perform(get("/template-contract/accounts/new")
.with(user("admin@example.test").roles("ADMIN")))
.andExpect(status().isOk())
.andExpect(content().string(containsString("class=\"app-shell\"")))
.andExpect(content().string(containsString("action=\"/admin/accounts\"")))
.andExpect(content().string(containsString("href=\"/admin/accounts/new\"")))
.andExpect(content().string(containsString("src=\"/assets/theme.js\"")));
}
@Test
void activationUsesPublicAuthShellAndLocalAssets() throws Exception {
mvc.perform(get("/template-contract/accounts/activate")
.with(user("pending@example.test")))
.andExpect(status().isOk())
.andExpect(content().string(containsString("class=\"auth-shell\"")))
.andExpect(content().string(containsString("action=\"/activate\"")))
.andExpect(content().string(containsString("value=\"raw-token\"")))
.andExpect(content().string(containsString("src=\"/assets/theme.js\"")))
.andExpect(content().string(containsString("href=\"/assets/app.css\"")));
}
@Controller
public static class TemplateController {
@GetMapping("/template-contract/accounts/new")
String accountCreation() {
return "accounts/new";
}
@GetMapping("/template-contract/accounts/activate")
String activation(Model model) {
model.addAttribute("token", "raw-token");
return "accounts/activate";
}
}
}