package com.example.tasks.screens

import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
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.firestore
import org.junit.Assert.*
import org.junit.Before
import org.junit.Rule
import org.junit.Test

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

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


        }
    }


    @Test
    fun testAddTask_fillingInTheFields() {

        testRule.onNodeWithTag("menu").performClick()
        testRule.onNodeWithTag("staff").performClick()
        testRule.onNodeWithTag("CustomText").performTextInput("1")
        testRule.onNodeWithText("Иванов И.И.").assertIsDisplayed()
        testRule.onNodeWithText("1").assertIsDisplayed()
        testRule.onNodeWithTag("date1").assertIsDisplayed()
        testRule.onNodeWithTag("date2").assertIsDisplayed()
    }
}