package ru.forbion.f7cloud.core.designsystem

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.unit.dp
import com.github.takahirom.roborazzi.captureRoboImage
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode

/**
 * Пилот Roborazzi: рендер Compose designsystem в PNG на JVM (без эмулятора).
 * Каркас Fd-сверки: экран → PNG → сравнение с веб-мобильной forbion.
 */
@RunWith(RobolectricTestRunner::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
@Config(sdk = [34], qualifiers = "w360dp-h800dp-xxhdpi")
class ScreenshotProofTest {

    @get:Rule
    val composeRule = createComposeRule()

    @Test
    fun designsystem_primary_button() {
        composeRule.setContent {
            F7Theme {
                Column(
                    modifier = Modifier.fillMaxSize().background(Color.White).padding(16.dp),
                    verticalArrangement = Arrangement.spacedBy(12.dp),
                ) {
                    Text("F7 design proof — Roborazzi")
                    F7PrimaryButton(text = "Сохранить", onClick = {})
                    F7SecondaryButton(text = "Отмена", onClick = {})
                }
            }
        }
        composeRule.onRoot().captureRoboImage("src/test/screenshots/proof-primary-button.png")
    }
}
