package com.example.tasks.screens

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.example.tasks.model.Task
import com.example.tasks.navigation.Screen
import com.example.tasks.ui.theme.TasksTheme
import com.google.firebase.Firebase
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.firestore
import dagger.hilt.android.HiltAndroidApp
import dagger.hilt.android.testing.HiltAndroidRule
import io.mockk.every
import io.mockk.mockk
import org.junit.Before
import org.junit.Rule
import org.junit.Test


class TaskChiefTest {
    @get:Rule(order = 0)
    var testRule = createComposeRule()

    @Before
    fun setup() {
        testRule.setContent {
            val navController = rememberNavController()
            TasksTheme {
                NavHost(navController = navController, startDestination = Screen.TasksChief.route) {
                    composable(route = Screen.TasksChief.route){
                        TasksChief(
                            surname = "Бобарик",
                            name = "Кристина",
                            patronymic = "Евгеньевна",
                            division = "Отдел информационных технологий",
                            navController2 = navController
                        )
                    }
                }
            }


        }
    }


    @Test
    fun testTasksChiefDisplaysTasks() {
        val fs = Firebase.firestore

        val task = Task(
            surname = "Иванов",
            name = "Иван",
            patronymic = "Иванович",
            start_date = "2024-06-28",
            end_date = "2024-07-28",
            task = "Сделать отчёт",
            author = "Бобарик Кристина Евгеньевна",
            number = 0,
            done = "Новая"
        )
        fs.collection("tasks").document().set(task)
        testRule.onNodeWithText("Исполнитель: Иванов И.И.").assertIsDisplayed()
        testRule.onNodeWithText("Дата начала: 2024-06-28").assertIsDisplayed()
        testRule.onNodeWithText("Дата конца: 2024-07-28").assertIsDisplayed()
        testRule.onNodeWithText("Задание: Сделать отчёт").assertIsDisplayed()
    }

}