//
//  MonthViewTests.swift
//  Tests iOS
//
//  Month view navigation and empty-state tests.
//

import XCTest

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

    /// TC-030: Navigate to Month view and verify content is visible.
    func testMonthView_ContentLoads() {
        let tabBar = TabBarScreen(app: app)
        tabBar.tapMonth()

        XCTAssertTrue(tabBar.monthTab.isSelected, "Month tab should be selected")

        // Wait for month view content to load - look for any visible content
        // Month cards should have mood color cells or month headers
        let monthContent = app.scrollViews.firstMatch
        XCTAssertTrue(
            monthContent.waitForExistence(timeout: 5),
            "Month view should have scrollable content"
        )

        captureScreenshot(name: "month_view_with_data")
    }
}

final class MonthViewEmptyTests: BaseUITestCase {
    override var seedFixture: String? { "empty" }

    /// TC-031: Navigate to Month view with no data - should not crash.
    func testMonthView_EmptyState_NoCrash() {
        let tabBar = TabBarScreen(app: app)
        tabBar.tapMonth()

        XCTAssertTrue(tabBar.monthTab.isSelected, "Month tab should be selected")

        // The view should load without crashing, even with no data.
        // Give it a moment to render.
        let monthTabStillSelected = tabBar.monthTab.waitForExistence(timeout: 3)
        XCTAssertTrue(monthTabStillSelected, "App should not crash on empty month view")

        captureScreenshot(name: "month_view_empty")
    }
}
