//
//  HighContrastTests.swift
//  Tests iOS
//
//  TC-144: App remains functional in High Contrast mode.
//

import XCTest

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

    override func setUp() {
        // Do NOT call super — we need custom accessibility launch args
        continueAfterFailure = false

        let application = XCUIApplication()
        let args: [String] = [
            "--ui-testing", "--disable-animations",
            "--reset-state",
            "--bypass-subscription",
            "--skip-onboarding",
            "-AppleLanguages", "(en)",
            "-AppleLocale", "en_US",
            "-UIAccessibilityDarkerSystemColorsEnabled", "YES"
        ]
        application.launchArguments = args
        application.launchEnvironment = ["UI_TEST_FIXTURE": "single_mood"]
        application.launch()
        app = application
    }

    /// TC-144: App is navigable with High Contrast mode enabled.
    func testHighContrast_AppRemainsNavigable() {
        // Day tab should have content
        assertDayContentVisible()

        captureScreenshot(name: "high_contrast_day")

        let tabBar = TabBarScreen(app: app)

        // Navigate through tabs
        tabBar.tapMonth()
        XCTAssertTrue(
            tabBar.monthTab.waitForExistence(timeout: 5),
            "Month tab should work with High Contrast"
        )

        tabBar.tapYear()
        XCTAssertTrue(
            tabBar.yearTab.waitForExistence(timeout: 5),
            "Year tab should work with High Contrast"
        )

        let settingsScreen = tabBar.tapSettings()
        settingsScreen.assertVisible()

        captureScreenshot(name: "high_contrast_settings")
    }
}
