//
//  ReduceMotionTests.swift
//  Tests iOS
//
//  TC-143: App remains functional with Reduce Motion enabled.
//

import XCTest

final class ReduceMotionTests: 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",
            "-UIReduceMotionPreference", "YES"
        ]
        application.launchArguments = args
        application.launchEnvironment = ["UI_TEST_FIXTURE": "single_mood"]
        application.launch()
        app = application
    }

    /// TC-143: App is navigable with Reduce Motion enabled.
    func testReduceMotion_AppRemainsNavigable() {
        // Day tab should have content
        assertDayContentVisible()

        captureScreenshot(name: "reduce_motion_day")

        let tabBar = TabBarScreen(app: app)

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

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

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

        captureScreenshot(name: "reduce_motion_settings")
    }
}
