# Path: functional_tests/base.py
# class FunctionalTest(StaticLiveServerTestCase):
#     def setUp(self):
#         self.browser = webdriver.Firefox()
#         User.objects.create_superuser("admin", "a@a.com", "sekrit")
#         User.objects._create_user(
#             "tech", "t@a.com", "password", is_staff=True, is_superuser=False
#         )
#         tech_test_computer = Computer(serial="TECHSERIAL")
#         tech_test_computer.username = "Daft Tech"
#         tech_test_computer.computername = "compy587"
#         tech_test_computer.save()
#         secret = Secret(
#             computer=tech_test_computer,
#             secret="SHHH-DONT-TELL",
#             date_escrowed=datetime.now(),
#         )
#         secret.save()
# 
#     def tearDown(self):
#         self.browser.quit()
# 
#     # currently doesn't work to find entered elements
#     # def check_for_row_in_list_table(self, row_value):
#     #     table = self.browser.find_element_by_id('id_list_table')
#     #     rows = table.find_elements_by_tag_name('tr')
#     #     value = rows.find_elements_by_tag_name('td')
#     #     self.assertIn(row_value, [value.text for row in rows])


import time
from .base import FunctionalTest
from selenium.webdriver.common.keys import Keys


class LoginAndBasicFunctionality(FunctionalTest):
    def test_admin_can_create_and_browse(self):
        # Admin goes to fv2 key mgmt site, sees it's named Crypt post-redirect to a login
        self.browser.get(self.live_server_url)
        self.assertIn("Crypt", self.browser.title)
        username_box = self.browser.find_element_by_id("id_username")
        password_box = self.browser.find_element_by_id("id_password")
        username_box.send_keys("admin")
        password_box.send_keys("sekrit")
        password_box.send_keys(Keys.ENTER)
        time.sleep(1)
        # After putting in creds, admin can create a computer from the hamburger menu, and is redirected to details
        self.browser.find_element_by_id("dLabel").click()

# Path: functional_tests/base.py
# class FunctionalTest(StaticLiveServerTestCase):
#     def setUp(self):
#         self.browser = webdriver.Firefox()
#         User.objects.create_superuser("admin", "a@a.com", "sekrit")
#         User.objects._create_user(
#             "tech", "t@a.com", "password", is_staff=True, is_superuser=False
#         )
#         tech_test_computer = Computer(serial="TECHSERIAL")
#         tech_test_computer.username = "Daft Tech"
#         tech_test_computer.computername = "compy587"
#         tech_test_computer.save()
#         secret = Secret(
#             computer=tech_test_computer,
#             secret="SHHH-DONT-TELL",
#             date_escrowed=datetime.now(),
#         )
#         secret.save()
# 
#     def tearDown(self):
#         self.browser.quit()
# 
#     # currently doesn't work to find entered elements
#     # def check_for_row_in_list_table(self, row_value):
#     #     table = self.browser.find_element_by_id('id_list_table')
#     #     rows = table.find_elements_by_tag_name('tr')
#     #     value = rows.find_elements_by_tag_name('td')
#     #     self.assertIn(row_value, [value.text for row in rows])


# Path: functional_tests/test_simple_site_functionality.py
import time
from .base import FunctionalTest
from selenium.webdriver.common.keys import Keys



class LoginAndBasicFunctionality(FunctionalTest):
    def test_admin_can_create_and_browse(self):
        # Admin goes to fv2 key mgmt site, sees it's named Crypt post-redirect to a login
        self.browser.get(self.live_server_url)
        self.assertIn("Crypt", self.browser.title)
        username_box = self.browser.find_element_by_id("id_username")
        password_box = self.browser.find_element_by_id("id_password")
        username_box.send_keys("admin")
        password_box.send_keys("sekrit")
        password_box.send_keys(Keys.ENTER)
        time.sleep(1)
        # After putting in creds, admin can create a computer from the hamburger menu, and is redirected to details
        self.browser.find_element_by_id("dLabel").click()

        self.browser.find_element_by_link_text("New computer").click()