//
//  PersonalityPackTests.swift
//  Tests iOS
//
//  TC-052: Select personality pack in Customize tab.
//

import XCTest

final class PersonalityPackTests: BaseUITestCase {
    override var seedFixture: String? { "single_mood" }
    override var bypassSubscription: Bool { true }

    /// TC-052: Selecting a different personality pack updates the checkmark.
    func testPersonalityPack_SelectCoach() {
        let tabBar = TabBarScreen(app: app)
        let settingsScreen = tabBar.tapSettings()
        settingsScreen.assertVisible()
        settingsScreen.tapCustomizeTab()

        let customizeScreen = CustomizeScreen(app: app)

        // Scroll down to personality pack section and select "Coach"
        customizeScreen.selectPersonalityPack("Coach")

        // Verify the Coach button is now selected — checkmark image should appear
        let checkmark = app.images.matching(
            NSPredicate(format: "label CONTAINS 'checkmark'")
        ).firstMatch

        // The Coach pack button should exist and the checkmark should be near it
        let coachButton = customizeScreen.personalityPackButton(named: "Coach")
        XCTAssertTrue(
            coachButton.exists,
            "Coach personality pack button should still be visible after selection"
        )

        captureScreenshot(name: "personality_pack_coach_selected")

        // Switch to a different pack to verify we can cycle
        customizeScreen.selectPersonalityPack("Zen")

        let zenButton = customizeScreen.personalityPackButton(named: "Zen")
        XCTAssertTrue(
            zenButton.exists,
            "Zen personality pack button should be visible after selection"
        )

        captureScreenshot(name: "personality_pack_zen_selected")
    }
}
