//
//  SecondaryTabTests.swift
//  Tests iOS
//
//  Month, Year, and Insights tab navigation tests.
//

import XCTest

final class SecondaryTabTests: BaseUITestCase {
    override var seedFixture: String? { "week_of_moods" }

    /// Navigate to Month tab and verify content loads.
    func testMonthTab_LoadsContent() {
        let tabBar = TabBarScreen(app: app)
        tabBar.tapMonth()

        // Month view should have some content loaded — look for the "Month" header text
        // or the month grid area. The tab should at minimum be selected.
        XCTAssertTrue(tabBar.monthTab.isSelected, "Month tab should be selected")

        captureScreenshot(name: "month_tab")
    }

    /// Navigate to Year tab and verify content loads.
    func testYearTab_LoadsContent() {
        let tabBar = TabBarScreen(app: app)
        tabBar.tapYear()

        XCTAssertTrue(tabBar.yearTab.isSelected, "Year tab should be selected")

        captureScreenshot(name: "year_tab")
    }

    /// Navigate to Insights tab and verify the header is visible.
    func testInsightsTab_ShowsHeader() {
        let tabBar = TabBarScreen(app: app)
        tabBar.tapInsights()

        XCTAssertTrue(tabBar.insightsTab.isSelected, "Insights tab should be selected")

        // Verify the Insights header text is visible
        let insightsHeader = app.element(UITestID.Insights.header)
        XCTAssertTrue(
            insightsHeader.waitForExistence(timeout: 5),
            "Insights header should be visible"
        )

        captureScreenshot(name: "insights_tab")
    }
}
