package dev.lions.user.manager.client.view;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
 * Tests unitaires pour GuestPreferences
 */
class GuestPreferencesTest {

    private GuestPreferences guestPreferences;

    @BeforeEach
    void setUp() {
        guestPreferences = new GuestPreferences();
    }

    @Test
    void testDefaultValues() {
        assertEquals("blue-light", guestPreferences.getTheme());
        assertEquals("light", guestPreferences.getLayout());
        assertEquals("blue-light", guestPreferences.getComponentTheme());
        assertEquals("light", guestPreferences.getDarkMode());
        assertEquals("layout-sidebar", guestPreferences.getMenuMode());
        assertEquals("light", guestPreferences.getTopbarTheme());
        assertEquals("light", guestPreferences.getMenuTheme());
        assertEquals("outlined", guestPreferences.getInputStyle());
        assertFalse(guestPreferences.isLightLogo());
    }

    @Test
    void testThemeSetterAndGetter() {
        guestPreferences.setTheme("green-light");
        assertEquals("green-light", guestPreferences.getTheme());
    }

    @Test
    void testLayoutSetterAndGetter() {
        guestPreferences.setLayout("dark");
        assertEquals("dark", guestPreferences.getLayout());
    }

    @Test
    void testComponentThemeSetterAndGetter() {
        guestPreferences.setComponentTheme("purple-light");
        assertEquals("purple-light", guestPreferences.getComponentTheme());
    }

    @Test
    void testDarkModeSetterAndGetter() {
        guestPreferences.setDarkMode("dark");
        assertEquals("dark", guestPreferences.getDarkMode());
        assertTrue(guestPreferences.isLightLogo());
    }

    @Test
    void testDarkModeLight() {
        guestPreferences.setDarkMode("light");
        assertEquals("light", guestPreferences.getDarkMode());
        assertFalse(guestPreferences.isLightLogo());
    }

    @Test
    void testMenuModeSetterAndGetter() {
        guestPreferences.setMenuMode("layout-horizontal");
        assertEquals("layout-horizontal", guestPreferences.getMenuMode());
    }

    @Test
    void testTopbarThemeSetterAndGetter() {
        guestPreferences.setTopbarTheme("dark");
        assertEquals("dark", guestPreferences.getTopbarTheme());
    }

    @Test
    void testMenuThemeSetterAndGetter() {
        guestPreferences.setMenuTheme("dark");
        assertEquals("dark", guestPreferences.getMenuTheme());
    }

    @Test
    void testInputStyleSetterAndGetter() {
        guestPreferences.setInputStyle("filled");
        assertEquals("filled", guestPreferences.getInputStyle());
    }

    @Test
    void testLightLogoSetterAndGetter() {
        guestPreferences.setLightLogo(true);
        assertTrue(guestPreferences.isLightLogo());
        
        guestPreferences.setLightLogo(false);
        assertFalse(guestPreferences.isLightLogo());
    }

    @Test
    void testGetInputStyleClass() {
        guestPreferences.setInputStyle("outlined");
        assertEquals("p-input-outlined", guestPreferences.getInputStyleClass());
        
        guestPreferences.setInputStyle("filled");
        assertEquals("p-input-filled", guestPreferences.getInputStyleClass());
    }

    @Test
    void testGetLayoutClass() {
        guestPreferences.setLayout("light");
        guestPreferences.setTheme("blue-light");
        assertEquals("layout-light layout-theme-blue-light", guestPreferences.getLayoutClass());
        
        guestPreferences.setLayout("dark");
        guestPreferences.setTheme("green-light");
        assertEquals("layout-dark layout-theme-green-light", guestPreferences.getLayoutClass());
    }

    @Test
    void testGetComponentThemes() {
        var themes = guestPreferences.getComponentThemes();
        assertNotNull(themes);
        assertFalse(themes.isEmpty());
        assertEquals(8, themes.size());
        
        // Vérifier le premier thème
        var firstTheme = themes.get(0);
        assertEquals("blue-light", firstTheme.getFile());
        assertEquals("Blue", firstTheme.getName());
        assertEquals("#007ad9", firstTheme.getColor());
        
        // Vérifier le dernier thème
        var lastTheme = themes.get(themes.size() - 1);
        assertEquals("cyan-light", lastTheme.getFile());
        assertEquals("Cyan", lastTheme.getName());
        assertEquals("#17a2b8", lastTheme.getColor());
    }

    @Test
    void testOnMenuTypeChange() {
        // Cette méthode ne fait rien, on vérifie juste qu'elle ne lance pas d'exception
        assertDoesNotThrow(() -> guestPreferences.onMenuTypeChange());
    }

    @Test
    void testComponentThemeClass() {
        var theme = new GuestPreferences.ComponentTheme("test-file", "Test Name", "#FF0000");
        assertEquals("test-file", theme.getFile());
        assertEquals("Test Name", theme.getName());
        assertEquals("#FF0000", theme.getColor());
    }
}

