Commit 716c480d authored by Johannes Tomren Røsvik's avatar Johannes Tomren Røsvik
Browse files

Merge branch '2-dark-mode' into 'dev'

Resolve "Dark mode"

See merge request !4
parents d7ab23e2 99a85884
Pipeline #74304 passed with stage
in 1 minute and 5 seconds
......@@ -3,3 +3,5 @@ django-bootstrap4==1.1.1
django-icons==0.1.0
pytz==2018.4
django-heroku
chromedriver
selenium
\ No newline at end of file
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import os
url = "http://127.0.0.1:8000/"
class AgreelanceDarkMode(unittest.TestCase):
def setUp(self):
if os.name == "nt":
self.driver = webdriver.Chrome("./bin/chromedriver.exe")
else:
self.driver = webdriver.Chrome("./bin/chromedriver")
#Checks that toggleelement should be availeble through togglebar
def test_dark_mode_in_toggle(self):
driver = self.driver
driver.get(url)
self.assertNotIn(driver.find_element_by_class_name("custom-control-label"), driver.find_elements_by_class_name("navbar navbar-expand-lg navbar-light bg-light"))
#Find the darkmode elements
def test_dark_mode_elements(self):
driver = self.driver
driver.get(url)
darkmode_control_label = driver.find_element_by_class_name("custom-control-label")
darkmode_control_input = driver.find_element_by_class_name("custom-control-input")
self.assertTrue(darkmode_control_label)
self.assertTrue(darkmode_control_input)
#Checks if CSS changes if button is clicked
def test_dark_mode_clicked(self):
driver = self.driver
driver.get(url)
try:
toggler = driver.find_element_by_class_name("navbar-toggler")
toggler.click()
time.sleep(1)
finally:
darkmode_click = driver.find_element_by_class_name("custom-control-label")
darkmode_click.click()
time.sleep(1)
self.assertEqual(driver.find_element_by_tag_name("body").value_of_css_property("background-color"), "rgba(0, 0, 0, 1)")
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment