Init other tests, more rigs test faffery

This commit is contained in:
2020-05-21 21:19:53 +01:00
parent 5a3547ea74
commit c23d18cd45
8 changed files with 204 additions and 139 deletions

View File

@@ -17,7 +17,7 @@ from RIGS.tests import regions
import datetime
from datetime import date, time, timedelta
from django.utils import timezone
from selenium.webdriver.support.select import Select
class TestRigboard(AutoLoginTest):
def setUp(self):
@@ -105,6 +105,141 @@ class TestEventCreate(AutoLoginTest):
self.page.submit()
self.assertTrue(self.page.success)
# TODO
def test_modals(self):
self.wait.until(animation_is_finished())
self.assertFalse(self.page.is_expanded)
self.page.select_event_type("Rig")
self.wait.until(animation_is_finished())
self.assertTrue(self.page.is_expanded)
# Create new person
modal = self.page.add_person()
# animation_is_finished doesn't work for whatever reason...
self.wait.until(EC.visibility_of_element_located((By.ID, 'modal')))
self.assertTrue(modal.is_open)
self.assertIn("Add Person", modal.header)
# Fill person form out and submit
person_name = "Test Person"
modal.name = person_name
modal.submit()
self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal')))
self.assertFalse(modal.is_open)
# See new person selected
select_element = self.driver.find_element(By.ID,'id_person')
select_object = Select(select_element)
person1 = models.Person.objects.get(name=person_name)
self.assertEqual(person1.name, select_object.first_selected_option.text)
# and backend
# self.assertEqual(person1.pk, int(self.page.person_selector.get_attribute("value")))
# Change mind and add another
self.wait.until(animation_is_finished())
modal = self.page.add_person()
self.wait.until(EC.visibility_of_element_located((By.ID, 'modal')))
self.assertTrue(modal.is_open)
self.assertIn("Add Person", modal.header)
person_name = "Test Person 2"
modal.name = person_name
modal.submit()
self.wait.until(EC.invisibility_of_element_located((By.ID, 'modal')))
self.assertFalse(modal.is_open)
person2 = models.Person.objects.get(name=person_name)
options = list((x for x in self.page.person_selector.options if x.selected))
self.assertTrue(len(options) == 1)
self.assertEqual(person2.name, options[0].name)
# and backend
# self.assertEqual(person1.pk, int(self.page.person_selector.get_attribute("value")))
# Was right the first time, change it back
self.page.person_selector.search(person1.name)
# TODO Check multiple cannot be selected? Is that necessary?
self.page.person_selector.set_option(person1.name, True)
options = list((x for x in self.page.person_selector.options if x.selected))
self.assertTrue(len(options) == 1)
self.assertEqual(person2.name, options[0].name)
# and backend
# self.assertEqual(person1.pk, int(self.page.person_selector.get_attribute("value")))
pass
# Edit Person 1 to have a better name
form.find_element_by_xpath(
'//a[@data-target="#id_person" and contains(@href, "%s/edit/")]' % person1.pk).click()
wait.until(animation_is_finished())
self.assertTrue(modal.is_displayed())
self.assertIn("Edit Person", modal.find_element_by_tag_name('h3').text)
name = modal.find_element_by_xpath(
'//div[@id="modal"]//input[@id="id_name"]')
self.assertEqual(person1.name, name.get_attribute('value'))
name.clear()
name.send_keys('Rig ' + person1.name)
name.send_keys(Keys.ENTER)
wait.until(animation_is_finished())
self.assertFalse(modal.is_displayed())
person1 = models.Person.objects.get(pk=person1.pk)
self.assertEqual(person1.name, form.find_element_by_xpath(
'//button[@data-id="id_person"]/span').text)
# Create organisation
wait.until(animation_is_finished())
add_button = self.browser.find_element_by_xpath(
'//a[@data-target="#id_organisation" and contains(@href, "add")]')
add_button.click()
modal = self.browser.find_element_by_id('modal')
wait.until(animation_is_finished())
self.assertTrue(modal.is_displayed())
self.assertIn("Add Organisation", modal.find_element_by_tag_name('h3').text)
modal.find_element_by_xpath(
'//div[@id="modal"]//input[@id="id_name"]').send_keys("Test Organisation")
modal.find_element_by_xpath(
'//div[@id="modal"]//input[@type="submit"]').click()
# See it is selected
wait.until(animation_is_finished())
self.assertFalse(modal.is_displayed())
obj = models.Organisation.objects.get(name="Test Organisation")
self.assertEqual(obj.name, form.find_element_by_xpath(
'//button[@data-id="id_organisation"]/span').text)
# and backend
option = form.find_element_by_xpath(
'//select[@id="id_organisation"]//option[@selected="selected"]')
self.assertEqual(obj.pk, int(option.get_attribute("value")))
# Create venue
wait.until(animation_is_finished())
add_button = self.browser.find_element_by_xpath(
'//a[@data-target="#id_venue" and contains(@href, "add")]')
wait.until(animation_is_finished())
add_button.click()
wait.until(animation_is_finished())
modal = self.browser.find_element_by_id('modal')
wait.until(animation_is_finished())
self.assertTrue(modal.is_displayed())
self.assertIn("Add Venue", modal.find_element_by_tag_name('h3').text)
modal.find_element_by_xpath(
'//div[@id="modal"]//input[@id="id_name"]').send_keys("Test Venue")
modal.find_element_by_xpath(
'//div[@id="modal"]//input[@type="submit"]').click()
# See it is selected
wait.until(animation_is_finished())
self.assertFalse(modal.is_displayed())
obj = models.Venue.objects.get(name="Test Venue")
self.assertEqual(obj.name, form.find_element_by_xpath(
'//button[@data-id="id_venue"]/span').text)
# and backend
option = form.find_element_by_xpath(
'//select[@id="id_venue"]//option[@selected="selected"]')
self.assertEqual(obj.pk, int(option.get_attribute("value")))
# TODO Testing of internal rig (approval system interface)
def test_non_rig_creation(self):