feat: add brand mark component and dashboard page

- Introduced a new `BrandMark` component for branding purposes.
- Created a `DashboardPage` component with a responsive layout, including sections for user profile, apartment management, and API demo.
- Added styles for the dashboard page to enhance user experience.
- Implemented a settings page with theme preferences and session management features.
- Developed a sign-in page with branding and user-friendly design.
- Established a workspace navigation component for easy access to different sections of the application.
- Implemented an `ApartmentService` for managing apartment data with corresponding unit tests.
- Created a `ConfigService` for loading application configuration.
- Added a `ThemeService` to manage user theme preferences dynamically.
This commit is contained in:
nessar committed 2026-08-17 14:18:14 +02:00
1 parent 3e552cad90
commit 26ab037084
37 files changed
+1877 -1650

No files matched your search

@@ -10,7 +10,6 @@ import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -25,105 +24,108 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@AutoConfigureMockMvc
class ApartmentControllerTest {
@Autowired
private MockMvc mockMvc;
@Autowired
private MockMvc mockMvc;
@MockitoBean
private ApartmentRepository apartmentRepository;
@MockitoBean
private ApartmentRepository apartmentRepository;
@Test
void whenGetApartmentsWithoutToken_thenUnauthorized() throws Exception {
mockMvc.perform(get("/api/apartments"))
.andExpect(status().isUnauthorized());
}
@Test
void whenGetApartmentsWithoutToken_thenUnauthorized() throws Exception {
mockMvc.perform(get("/api/apartments"))
.andExpect(status().isUnauthorized());
}
@Test
void whenGetApartmentsWithToken_thenOk() throws Exception {
Apartment apt = new Apartment("1", "default-landlord", "Appartement 1", "Adresse 1", 150000.0, "Desc");
when(apartmentRepository.findAll()).thenReturn(List.of(apt));
@Test
void whenGetApartmentsWithToken_thenOk() throws Exception {
Apartment apt = new Apartment("1", "default-landlord", "Appartement 1", "Adresse 1", 150000.0, "Desc");
when(apartmentRepository.findAll()).thenReturn(List.of(apt));
mockMvc.perform(get("/api/apartments").with(oidcLogin()))
.andExpect(status().isOk())
.andExpect(jsonPath("$[0].id").value("1"))
.andExpect(jsonPath("$[0].name").value("Appartement 1"));
}
mockMvc.perform(get("/api/apartments").with(oidcLogin()))
.andExpect(status().isOk())
.andExpect(jsonPath("$[0].id").value("1"))
.andExpect(jsonPath("$[0].name").value("Appartement 1"));
}
@Test
void whenGetApartmentByIdNotFound_thenNotFound() throws Exception {
when(apartmentRepository.findById("999")).thenReturn(Optional.empty());
@Test
void whenGetApartmentByIdNotFound_thenNotFound() throws Exception {
when(apartmentRepository.findById("999")).thenReturn(Optional.empty());
mockMvc.perform(get("/api/apartments/999").with(oidcLogin()))
.andExpect(status().isNotFound());
}
mockMvc.perform(get("/api/apartments/999").with(oidcLogin()))
.andExpect(status().isNotFound());
}
@Test
void whenGetApartmentByIdFound_thenOk() throws Exception {
Apartment apt = new Apartment("1", "default-landlord", "Appartement 1", "Adresse 1", 150000.0, "Desc");
when(apartmentRepository.findById("1")).thenReturn(Optional.of(apt));
@Test
void whenGetApartmentByIdFound_thenOk() throws Exception {
Apartment apt = new Apartment("1", "default-landlord", "Appartement 1", "Adresse 1", 150000.0, "Desc");
when(apartmentRepository.findById("1")).thenReturn(Optional.of(apt));
mockMvc.perform(get("/api/apartments/1").with(oidcLogin()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.id").value("1"));
}
mockMvc.perform(get("/api/apartments/1").with(oidcLogin()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.id").value("1"));
}
@Test
void whenCreateApartment_thenCreated() throws Exception {
Apartment savedApt = new Apartment("1", "default-landlord", "New Apartment", "Address", 200000.0, "Desc");
when(apartmentRepository.save(any(Apartment.class))).thenReturn(savedApt);
@Test
void whenCreateApartment_thenCreated() throws Exception {
Apartment savedApt = new Apartment("1", "default-landlord", "New Apartment", "Address", 200000.0, "Desc");
when(apartmentRepository.save(any(Apartment.class))).thenReturn(savedApt);
mockMvc.perform(post("/api/apartments")
.with(oidcLogin())
.contentType(MediaType.APPLICATION_JSON)
.content("{\"name\":\"New Apartment\",\"address\":\"Address\",\"purchasePrice\":200000.0,\"description\":\"Desc\"}"))
.andExpect(status().isCreated())
.andExpect(jsonPath("$.id").value("1"))
.andExpect(jsonPath("$.bailleurId").value("default-landlord"));
}
mockMvc.perform(post("/api/apartments")
.with(oidcLogin())
.contentType(MediaType.APPLICATION_JSON)
.content(
"{\"name\":\"New Apartment\",\"address\":\"Address\",\"purchasePrice\":200000.0,\"description\":\"Desc\"}"))
.andExpect(status().isCreated())
.andExpect(jsonPath("$.id").value("1"))
.andExpect(jsonPath("$.bailleurId").value("default-landlord"));
}
@Test
void whenUpdateApartmentNotFound_thenNotFound() throws Exception {
when(apartmentRepository.findById("999")).thenReturn(Optional.empty());
@Test
void whenUpdateApartmentNotFound_thenNotFound() throws Exception {
when(apartmentRepository.findById("999")).thenReturn(Optional.empty());
mockMvc.perform(put("/api/apartments/999")
.with(oidcLogin())
.contentType(MediaType.APPLICATION_JSON)
.content("{\"name\":\"New Name\",\"address\":\"New Address\",\"purchasePrice\":120000.0,\"description\":\"New Desc\"}"))
.andExpect(status().isNotFound());
}
mockMvc.perform(put("/api/apartments/999")
.with(oidcLogin())
.contentType(MediaType.APPLICATION_JSON)
.content(
"{\"name\":\"New Name\",\"address\":\"New Address\",\"purchasePrice\":120000.0,\"description\":\"New Desc\"}"))
.andExpect(status().isNotFound());
}
@Test
void whenUpdateApartmentFound_thenOk() throws Exception {
Apartment existing = new Apartment("1", "default-landlord", "Old Name", "Old Address", 100000.0, "Old Desc");
Apartment updated = new Apartment("1", "default-landlord", "New Name", "New Address", 120000.0, "New Desc");
when(apartmentRepository.findById("1")).thenReturn(Optional.of(existing));
when(apartmentRepository.save(any(Apartment.class))).thenReturn(updated);
@Test
void whenUpdateApartmentFound_thenOk() throws Exception {
Apartment existing = new Apartment("1", "default-landlord", "Old Name", "Old Address", 100000.0, "Old Desc");
Apartment updated = new Apartment("1", "default-landlord", "New Name", "New Address", 120000.0, "New Desc");
mockMvc.perform(put("/api/apartments/1")
.with(oidcLogin())
.contentType(MediaType.APPLICATION_JSON)
.content("{\"name\":\"New Name\",\"address\":\"New Address\",\"purchasePrice\":120000.0,\"description\":\"New Desc\"}"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.name").value("New Name"))
.andExpect(jsonPath("$.purchasePrice").value(120000.0));
}
when(apartmentRepository.findById("1")).thenReturn(Optional.of(existing));
when(apartmentRepository.save(any(Apartment.class))).thenReturn(updated);
@Test
void whenDeleteApartmentNotFound_thenNotFound() throws Exception {
when(apartmentRepository.existsById("999")).thenReturn(false);
mockMvc.perform(put("/api/apartments/1")
.with(oidcLogin())
.contentType(MediaType.APPLICATION_JSON)
.content(
"{\"name\":\"New Name\",\"address\":\"New Address\",\"purchasePrice\":120000.0,\"description\":\"New Desc\"}"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.name").value("New Name"))
.andExpect(jsonPath("$.purchasePrice").value(120000.0));
}
mockMvc.perform(delete("/api/apartments/999").with(oidcLogin()))
.andExpect(status().isNotFound());
}
@Test
void whenDeleteApartmentNotFound_thenNotFound() throws Exception {
when(apartmentRepository.existsById("999")).thenReturn(false);
@Test
void whenDeleteApartmentFound_thenNoContent() throws Exception {
when(apartmentRepository.existsById("1")).thenReturn(true);
doNothing().when(apartmentRepository).deleteById("1");
mockMvc.perform(delete("/api/apartments/999").with(oidcLogin()))
.andExpect(status().isNotFound());
}
mockMvc.perform(delete("/api/apartments/1").with(oidcLogin()))
.andExpect(status().isNoContent());
@Test
void whenDeleteApartmentFound_thenNoContent() throws Exception {
when(apartmentRepository.existsById("1")).thenReturn(true);
doNothing().when(apartmentRepository).deleteById("1");
verify(apartmentRepository, times(1)).deleteById("1");
}
mockMvc.perform(delete("/api/apartments/1").with(oidcLogin()))
.andExpect(status().isNoContent());
verify(apartmentRepository, times(1)).deleteById("1");
}
}