// // YearViewCollapseTests.swift // Tests iOS // // TC-037: Collapse/expand year stats section. // import XCTest final class YearViewCollapseTests: BaseUITestCase { override var seedFixture: String? { "week_of_moods" } override var bypassSubscription: Bool { true } /// TC-037: Tapping the year card header collapses and re-expands stats. func testYearView_CollapseExpand_StatsSection() { let tabBar = TabBarScreen(app: app) tabBar.tapYear() XCTAssertTrue(tabBar.yearTab.isSelected, "Year tab should be selected") // Stats section is visible by default (showStats = true) let statsSection = app.element(UITestID.Year.statsSection) XCTAssertTrue( statsSection.waitForExistence(timeout: 8), "Year stats section should be visible initially" ) // Find the current year's card header button let currentYear = Calendar.current.component(.year, from: Date()) let headerButton = app.element(UITestID.Year.cardHeader(year: currentYear)) XCTAssertTrue( headerButton.waitForExistence(timeout: 5), "Year card header for \(currentYear) should be visible" ) captureScreenshot(name: "year_stats_expanded") // Tap header to collapse stats headerButton.tap() // Stats section should disappear XCTAssertTrue( statsSection.waitForDisappearance(timeout: 3), "Stats section should collapse after tapping header" ) captureScreenshot(name: "year_stats_collapsed") // Tap header again to expand stats headerButton.tap() // Stats section should reappear XCTAssertTrue( statsSection.waitForExistence(timeout: 3), "Stats section should expand after tapping header again" ) captureScreenshot(name: "year_stats_re_expanded") } }