//
//  MoodLoggingWithDataTests.swift
//  Tests iOS
//
//  Mood logging with existing seeded data tests.
//

import XCTest

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

    /// With a week of data seeded, the mood header should appear if today is missing a vote.
    /// Log a new mood and verify header disappears.
    func testLogMood_Average_WhenDataExists() {
        let dayScreen = DayScreen(app: app)

        // The seeded data includes today (offset 0 = great).
        // After reset + seed, today already has an entry, so header may be hidden.
        // If the header IS visible (i.e. vote logic says "needs vote"), tap it.
        if dayScreen.moodHeader.waitForExistence(timeout: 3) {
            dayScreen.logMood(.average)
            // After logging, header should disappear (today is now voted)
            dayScreen.assertMoodHeaderHidden()
        }

        // Regardless, verify at least one entry row is visible (seeded data)
        let anyEntry = app.firstEntryRow
        XCTAssertTrue(
            anyEntry.waitForExistence(timeout: 5),
            "At least one entry row should exist from seeded data"
        )

        captureScreenshot(name: "mood_logged_with_data")
    }
}
