//
//  CustomizationTests.swift
//  Tests iOS
//
//  Customization tests: theme modes, voting layouts, day view styles.
//

import XCTest

final class CustomizationTests: BaseUITestCase {
    override var seedFixture: String? { "single_mood" }
    override var bypassSubscription: Bool { true }

    /// TC-071: Switch between all 4 theme modes without crashing.
    func testThemeModes_AllSelectable() {
        let tabBar = TabBarScreen(app: app)
        let settingsScreen = tabBar.tapSettings()
        settingsScreen.assertVisible()
        settingsScreen.tapCustomizeTab()
        let customizeScreen = CustomizeScreen(app: app)

        // Should already be on Customize sub-tab
        // Theme buttons are: System, iFeel, Dark, Light
        let themeNames = ["System", "iFeel", "Dark", "Light"]

        for themeName in themeNames {
            customizeScreen.selectTheme(themeName)
        }

        captureScreenshot(name: "theme_modes_cycled")
    }

    /// TC-073: Switch between all 6 voting layouts without crashing.
    func testVotingLayouts_AllSelectable() {
        let tabBar = TabBarScreen(app: app)
        let settingsScreen = tabBar.tapSettings()
        settingsScreen.assertVisible()
        settingsScreen.tapCustomizeTab()
        let customizeScreen = CustomizeScreen(app: app)

        // Voting layout names (from VotingLayoutStyle enum)
        let layouts = ["Horizontal", "Cards", "Stacked", "Aura", "Orbit", "Neon"]

        for layout in layouts {
            customizeScreen.selectVotingLayout(layout)
        }

        captureScreenshot(name: "voting_layouts_cycled")

        // Navigate to Day tab to verify the voting layout renders
        tabBar.tapDay()
        assertDayContentVisible()
        captureScreenshot(name: "day_view_after_layout_change")
    }

    /// TC-074: Switch between several day view styles without crashing.
    func testDayViewStyles_MultipleSelectable() {
        let tabBar = TabBarScreen(app: app)
        let settingsScreen = tabBar.tapSettings()
        settingsScreen.assertVisible()
        settingsScreen.tapCustomizeTab()
        let customizeScreen = CustomizeScreen(app: app)

        // Test a representative sample of day view styles (testing all 20+ would be slow)
        let styles = ["Classic", "Minimal", "Compact", "Bubble", "Grid", "Neon"]

        for style in styles {
            customizeScreen.selectDayViewStyle(style)
        }

        captureScreenshot(name: "day_styles_cycled")

        // Navigate to Day tab to verify the style renders with data
        tabBar.tapDay()
        assertDayContentVisible()

        captureScreenshot(name: "day_view_after_style_change")
    }
}
