package com.tt.honeyDue.fixtures

import com.tt.honeyDue.models.TaskCreateRequest
import kotlin.random.Random

/**
 * Test task fixture mirroring `TestFixtures.TestTask` in Swift.
 *
 * The Go API requires a residenceId and assigns category/priority IDs from
 * DataManager lookups — callers pass the ID of a seeded test residence plus
 * optional lookup IDs after a prefetch.
 */
data class TestTask(
    val title: String,
    val description: String,
    val residenceId: Int,
    val priorityId: Int? = null,
    val categoryId: Int? = null,
    val estimatedCost: Double? = null,
) {
    fun toCreateRequest(): TaskCreateRequest = TaskCreateRequest(
        residenceId = residenceId,
        title = title,
        description = description,
        categoryId = categoryId,
        priorityId = priorityId,
        estimatedCost = estimatedCost,
    )

    companion object {
        fun basic(residenceId: Int, suffix: String = randomSuffix()): TestTask = TestTask(
            title = "Test Task $suffix",
            description = "A test task",
            residenceId = residenceId,
        )

        fun urgent(
            residenceId: Int,
            priorityId: Int? = null,
            suffix: String = randomSuffix(),
        ): TestTask = TestTask(
            title = "Urgent Task $suffix",
            description = "An urgent task",
            residenceId = residenceId,
            priorityId = priorityId,
        )

        private fun randomSuffix(): String =
            Random.nextInt(1000, 9999).toString()
    }
}
