UPD: improved tests.

This commit is contained in:
2019-03-14 11:15:05 +01:00
parent 848db26516
commit 3f68579b78
4 changed files with 87 additions and 39 deletions

View File

@@ -36,7 +36,7 @@ class TestCase(ScreenshotTestCase):
link = c.find_element_by_css_selector('#login-widget a')
link.click()
self.wait_on_presence(c, (By.ID, 'id_username'))
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('empty_login_form', sequence=sequence_name)
# Fill in a password -> Save dots in password field
username_field = c.find_element_by_id('id_username')
@@ -45,7 +45,7 @@ class TestCase(ScreenshotTestCase):
password_field = c.find_element_by_id('id_password')
password_field.clear()
password_field.send_keys(self.test_password)
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('filled_login_form', sequence=sequence_name)
# Wrong username -> save error message
username_field = c.find_element_by_id('id_username')
@@ -56,7 +56,7 @@ class TestCase(ScreenshotTestCase):
password_field.send_keys(self.test_password)
password_field.send_keys(Keys.RETURN)
alert_button = self.wait_on_presence(c, (By.CSS_SELECTOR, 'form .alert-danger button.close'))
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('error_wrong_username', sequence=sequence_name)
alert_button.click()
# Wrong password -> save error message
@@ -68,7 +68,7 @@ class TestCase(ScreenshotTestCase):
password_field.send_keys(self.test_password[::-1])
password_field.send_keys(Keys.RETURN)
alert_button = self.wait_on_presence(c, (By.CSS_SELECTOR, 'form .alert-danger button.close'))
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('error_wrong_password', sequence=sequence_name)
alert_button.click()
# Login of inactive user -> save error message
@@ -82,7 +82,7 @@ class TestCase(ScreenshotTestCase):
password_field.send_keys(self.test_password)
password_field.send_keys(Keys.RETURN)
alert_button = self.wait_on_presence(c, (By.CSS_SELECTOR, 'form .alert-danger button.close'))
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('error_inactive_user', sequence=sequence_name)
alert_button.click()
# Reactivate test user again
self.user.is_active = True
@@ -97,40 +97,39 @@ class TestCase(ScreenshotTestCase):
password_field.send_keys(self.test_password)
password_field.send_keys(Keys.RETURN)
alert_button = self.wait_on_presence(c, (By.CSS_SELECTOR, '#messages .alert-success button.close'))
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('login_succeed', sequence=sequence_name)
alert_button.click()
# Open user dropdown menu -> save menu
dropdown_button = self.wait_on_presence(c, (By.ID, 'user_dropdown_button'))
dropdown_button.click()
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('user_menu', sequence=sequence_name)
# Click on 'set password' -> save set password page
user_menu = c.find_element_by_css_selector('#login-widget ul')
link = user_menu.find_element_by_partial_link_text(ugettext(u'Passwort ändern'))
link.click()
self.wait_on_presence(c, (By.ID, 'id_new_password'))
self.save_screenshot(sequence=sequence_name)
password_field = self.wait_on_presence(c, (By.ID, 'id_new_password'))
self.save_screenshot('empty_set_password_form', sequence=sequence_name)
# Fill in a password -> Save dots in password field
password_field = c.find_element_by_id('id_new_password')
send_mail_field = c.find_element_by_id('id_send_password_mail')
send_mail_field.click()
password_field.clear()
password_field.send_keys(self.test_password)
password2_field = c.find_element_by_id('id_new_password_repeat')
password2_field.clear()
password2_field.send_keys(self.test_password)
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('filled_set_password_form', sequence=sequence_name)
# New passwords mismatch -> save error message
password_field = c.find_element_by_id('id_new_password')
password_field.clear()
password_field.send_keys(self.test_password)
password2_field = c.find_element_by_id('id_new_password_repeat')
password2_field.clear()
password2_field.send_keys(self.test_password[::-1])
password2_field.send_keys(Keys.RETURN)
self.wait_until_stale(c, password2_field)
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('error_mismatch', sequence=sequence_name)
# New passwords too common and too short -> save error message
password = 'abcdef'
@@ -142,7 +141,7 @@ class TestCase(ScreenshotTestCase):
password2_field.send_keys(password)
password2_field.send_keys(Keys.RETURN)
self.wait_until_stale(c, password2_field)
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('errors_too_common_too_short', sequence=sequence_name)
# New passwords entirely_numeric -> save error message
password = '9126735804'
@@ -154,7 +153,7 @@ class TestCase(ScreenshotTestCase):
password2_field.send_keys(password)
password2_field.send_keys(Keys.RETURN)
self.wait_until_stale(c, password2_field)
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('error_numeric', sequence=sequence_name)
# New passwords too similar -> save error message
password = self.test_username
@@ -166,7 +165,7 @@ class TestCase(ScreenshotTestCase):
password2_field.send_keys(password)
password2_field.send_keys(Keys.RETURN)
self.wait_until_stale(c, password2_field)
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('error_too_similar', sequence=sequence_name)
# Change password -> save success message
password = self.test_password[::-1]
@@ -178,7 +177,15 @@ class TestCase(ScreenshotTestCase):
password2_field.send_keys(password)
password2_field.send_keys(Keys.RETURN)
self.wait_until_stale(c, password2_field)
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('set_password_succeed', sequence=sequence_name)
# Get password reset page -> since we are logged in, it should
# redirect to set password page again -> save
html = c.find_element_by_tag_name('html')
c.get(self.complete_url(reverse('dav_auth:reset_password')))
self.wait_until_stale(c, html)
self.wait_on_presence(c, (By.ID, 'id_new_password'))
self.save_screenshot('empty_set_password_form', sequence=sequence_name)
# Click on 'logout' -> save page
dropdown_button = self.wait_on_presence(c, (By.ID, 'user_dropdown_button'))
@@ -187,4 +194,32 @@ class TestCase(ScreenshotTestCase):
link = user_menu.find_element_by_partial_link_text(ugettext(u'Logout'))
link.click()
self.wait_until_stale(c, user_menu)
self.save_screenshot(sequence=sequence_name)
self.save_screenshot('logout_succeed', sequence=sequence_name)
# Click on 'login' to access password reset link
link = c.find_element_by_css_selector('#login-widget a')
link.click()
self.wait_on_presence(c, (By.ID, 'id_username'))
# Locate password reset link, click it -> save password reset form
link = c.find_element_by_partial_link_text(ugettext(u'Passwort vergessen'))
link.click()
username_field = self.wait_on_presence(c, (By.ID, 'id_username'))
self.save_screenshot('empty_reset_password_form', sequence=sequence_name)
# Enter invalid username -> save result (login form, no message)
username_field.send_keys(self.test_username[::-1])
username_field.send_keys(Keys.RETURN)
self.wait_until_stale(c, username_field)
self.save_screenshot('reset_password_invalid_user', sequence=sequence_name)
# Locate password reset link, click it
link = c.find_element_by_partial_link_text(ugettext(u'Passwort vergessen'))
link.click()
username_field = self.wait_on_presence(c, (By.ID, 'id_username'))
# Enter valid username -> save result (login page, success message)
username_field.send_keys(self.test_username)
username_field.send_keys(Keys.RETURN)
self.wait_until_stale(c, username_field)
self.save_screenshot('reset_password_valid_user', sequence=sequence_name)