update e2 tests
This commit is contained in:
parent
866a4480c1
commit
251225b8b1
@ -1,4 +1,9 @@
|
||||
from .utils import TEST_URL, assert_navbar, login_valid_user
|
||||
from .utils import (
|
||||
TEST_URL,
|
||||
assert_navbar,
|
||||
login_valid_user,
|
||||
register_valid_user_and_logout,
|
||||
)
|
||||
|
||||
URL = f'{TEST_URL}/login'
|
||||
|
||||
@ -31,11 +36,7 @@ class TestLogin:
|
||||
assert 'Forgot password?' in links[1].text
|
||||
|
||||
def test_user_can_log_in(self, selenium):
|
||||
user = {
|
||||
'username': 'admin',
|
||||
'email': 'admin@example.com',
|
||||
'password': 'mpwoadmin',
|
||||
}
|
||||
user = register_valid_user_and_logout(selenium)
|
||||
|
||||
login_valid_user(selenium, user)
|
||||
|
||||
|
@ -4,6 +4,7 @@ from .utils import (
|
||||
random_string,
|
||||
register,
|
||||
register_valid_user,
|
||||
register_valid_user_and_logout,
|
||||
)
|
||||
|
||||
URL = f'{TEST_URL}/register'
|
||||
@ -57,30 +58,20 @@ class TestRegistration:
|
||||
def test_user_can_not_register_if_username_is_already_taken(
|
||||
self, selenium
|
||||
):
|
||||
user_name = random_string()
|
||||
user_infos = {
|
||||
'username': 'admin',
|
||||
'email': f'{user_name}@example.com',
|
||||
'password': 'p@ssw0rd',
|
||||
'password_conf': 'p@ssw0rd',
|
||||
}
|
||||
user = register_valid_user_and_logout(selenium)
|
||||
user['email'] = f'{random_string()}@example.com'
|
||||
|
||||
register(selenium, user_infos)
|
||||
register(selenium, user)
|
||||
|
||||
assert selenium.current_url == URL
|
||||
errors = selenium.find_element_by_class_name('error-message').text
|
||||
assert 'Sorry, that user already exists.' in errors
|
||||
|
||||
def test_user_can_not_register_if_email_is_already_taken(self, selenium):
|
||||
user_name = random_string()
|
||||
user_infos = {
|
||||
'username': user_name,
|
||||
'email': 'admin@example.com',
|
||||
'password': 'p@ssw0rd',
|
||||
'password_conf': 'p@ssw0rd',
|
||||
}
|
||||
user = register_valid_user_and_logout(selenium)
|
||||
user['username'] = random_string()
|
||||
|
||||
register(selenium, user_infos)
|
||||
register(selenium, user)
|
||||
|
||||
assert selenium.current_url == URL
|
||||
errors = selenium.find_element_by_class_name('error-message').text
|
||||
|
18
e2e/utils.py
18
e2e/utils.py
@ -54,6 +54,24 @@ def register_valid_user(selenium):
|
||||
return user
|
||||
|
||||
|
||||
def register_valid_user_and_logout(selenium):
|
||||
user_name = random_string()
|
||||
user = {
|
||||
'username': user_name,
|
||||
'email': f'{user_name}@example.com',
|
||||
'password': 'p@ssw0rd',
|
||||
'password_conf': 'p@ssw0rd',
|
||||
}
|
||||
register(selenium, user)
|
||||
WebDriverWait(selenium, 15).until(EC.url_changes(f"{TEST_URL}/register"))
|
||||
|
||||
user_menu = selenium.find_element_by_class_name('nav-items-user-menu')
|
||||
logout_link = user_menu.find_elements_by_class_name('nav-item')[2]
|
||||
logout_link.click()
|
||||
selenium.implicitly_wait(1)
|
||||
return user
|
||||
|
||||
|
||||
def login_valid_user(selenium, user):
|
||||
login(selenium, user)
|
||||
WebDriverWait(selenium, 10).until(EC.url_changes(f"{TEST_URL}/login"))
|
||||
|
Loading…
Reference in New Issue
Block a user