package com.ponzischeme89.memby.ui.search

import android.graphics.BitmapFactory
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
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

@RunWith(RobolectricTestRunner::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
@Config(sdk = [34], qualifiers = "w960dp-h540dp-television-xhdpi")
class RecommendationRequestScreenshotTest {
    @get:Rule
    val compose = createComposeRule()

    @Test
    fun `recommendation request panel`() {
        val artwork = requireNotNull(javaClass.getResourceAsStream("/home_hero_preview_art.png"))
            .use(BitmapFactory::decodeStream)
            .asImageBitmap()

        compose.setContent { RecommendationRequestPreview(previewArtwork = artwork) }
        compose.onNodeWithText("Request something new").fetchSemanticsNode()
        compose.onRoot().captureRoboImage(
            "build/screenshots/recommendation-request/recommendation-request-panel.png",
        )
    }
}
