import Foundation

/// Reusable test data builders for UI tests.
///
/// Each fixture generates unique names using random numbers or UUIDs
/// to ensure test isolation and prevent cross-test interference.
enum TestFixtures {

    // MARK: - Users

    struct TestUser {
        let firstName: String
        let lastName: String
        let email: String
        let password: String

        /// Standard test user with unique email.
        static let standard = TestUser(
            firstName: "Test",
            lastName: "User",
            email: "uitest_\(UUID().uuidString.prefix(8))@test.com",
            password: "TestPassword123!"
        )

        /// Secondary test user for multi-user scenarios.
        static let secondary = TestUser(
            firstName: "Second",
            lastName: "Tester",
            email: "uitest2_\(UUID().uuidString.prefix(8))@test.com",
            password: "TestPassword456!"
        )

        /// Pre-existing test user with known credentials (must exist on backend).
        static let existing = TestUser(
            firstName: "Test",
            lastName: "User",
            email: "testuser",
            password: "TestPass123!"
        )
    }

    // MARK: - Residences

    struct TestResidence {
        let name: String
        let address: String
        let type: String

        static let house = TestResidence(
            name: "Test House \(Int.random(in: 1000...9999))",
            address: "123 Test St",
            type: "House"
        )

        static let apartment = TestResidence(
            name: "Test Apt \(Int.random(in: 1000...9999))",
            address: "456 Mock Ave",
            type: "Apartment"
        )
    }

    // MARK: - Tasks

    struct TestTask {
        let title: String
        let description: String
        let priority: String
        let category: String

        static let basic = TestTask(
            title: "Test Task \(Int.random(in: 1000...9999))",
            description: "A test task",
            priority: "Medium",
            category: "Cleaning"
        )

        static let urgent = TestTask(
            title: "Urgent Task \(Int.random(in: 1000...9999))",
            description: "An urgent task",
            priority: "High",
            category: "Repair"
        )
    }

    // MARK: - Documents

    struct TestDocument {
        let title: String
        let description: String
        let type: String

        static let basic = TestDocument(
            title: "Test Doc \(Int.random(in: 1000...9999))",
            description: "A test document",
            type: "Manual"
        )

        static let warranty = TestDocument(
            title: "Test Warranty \(Int.random(in: 1000...9999))",
            description: "A test warranty",
            type: "Warranty"
        )
    }

    // MARK: - Contractors

    struct TestContractor {
        let name: String
        let phone: String
        let email: String
        let specialty: String

        static let basic = TestContractor(
            name: "Test Contractor \(Int.random(in: 1000...9999))",
            phone: "555-0100",
            email: "contractor@test.com",
            specialty: "Plumber"
        )
    }
}
