//
//  DataPersistenceTests.swift
//  Tests iOS
//
//  Data persistence tests — verify entries survive app relaunch.
//

import XCTest

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

    /// TC-156: Log a mood, force quit, relaunch → entry should persist.
    func testDataPersists_AcrossRelaunch() {
        let dayScreen = DayScreen(app: app)

        // Log a mood
        dayScreen.assertMoodHeaderVisible()
        dayScreen.logMood(.great)

        // Verify entry was created
        dayScreen.assertAnyEntryExists()

        captureScreenshot(name: "before_relaunch")

        let freshApp = relaunchPreservingState()

        // The entry should still exist after relaunch
        let entryRow = freshApp.firstEntryRow
        XCTAssertTrue(
            entryRow.waitForExistence(timeout: 8),
            "Entry should persist after force quit and relaunch"
        )

        captureScreenshot(name: "after_relaunch_data_persists")
    }
}
