Commit 8b2f6cff authored by Birin Sanchez's avatar Birin Sanchez
Browse files

Add Selenium smoke test for Basic registration.


Signed-off-by: Birin Sanchez's avatarBirin Sanchez <birin.sanchez@puri.sm>
parent 31c58171
Pipeline #36665 passed with stage
in 30 seconds
......@@ -133,4 +133,8 @@ ENV/
dev_*
*.code-workspace
settings_dev.py
Pipfile.lock
\ No newline at end of file
Pipfile.lock
# Selenium smoke tests assets and reports
tests/assets
tests/*.html
[pytest]
sensitive_url = https://librem\.one
base_url = https://sandbox.librem.one/
import pytest
from datetime import datetime, timedelta
@pytest.fixture()
def chrome_options(chrome_options):
chrome_options.headless = True
return chrome_options
@pytest.fixture()
def username():
now = datetime.now()
return "test" + now.strftime("%y%m%d%H%M%S")
def test_basicregistration(username, base_url, selenium):
password = "RkqZBfA3hnBzDHMJ5Bum"
url = "accounts/register/basic/"
selenium.get(base_url+url)
selenium.find_element_by_id("id_username").send_keys(username)
selenium.find_element_by_id("id_email").send_keys(username+"@example.com")
selenium.find_element_by_id("id_password1").send_keys(password)
selenium.find_element_by_id("id_password2").send_keys(password)
selenium.find_element_by_xpath("/html/body/main/div/form/input[2]").click()
# Check that username is in profile page
log_state = selenium.find_element_by_id("log_state")
assert username in log_state.text
# Check that only Basic services are enabled
date = datetime.now() + timedelta(days=30)
date_str = date.strftime("%Y-%m-%d")
# Tuples with the expected values for the service when they are
# disabled and enabled
enabled_state = ("Yes", date_str, "30 days", "---", False)
disabled_state = ("No", "-", "-", "---", False)
services = {"Tunnel": disabled_state,
"Chat": enabled_state,
"Mail": disabled_state,
"Social": enabled_state,
"XMPP": disabled_state}
for (i, (k, v)) in enumerate(services.items(), 1):
xpath = "/html/body/main/article/table/tbody/tr[{}]/th".format(i)
srv_title = selenium.find_element_by_xpath(xpath).text
xpath = "/html/body/main/article/table/tbody/tr[{}]/td[1]".format(i)
srv_active = selenium.find_element_by_xpath(xpath).text
xpath = "/html/body/main/article/table/tbody/tr[{}]/td[2]".format(i)
srv_ren = selenium.find_element_by_xpath(xpath).text
xpath = "/html/body/main/article/table/tbody/tr[{}]/td[3]".format(i)
srv_cred = selenium.find_element_by_xpath(xpath).text
xpath = "/html/body/main/article/table/tbody/tr[{}]/td[4]/form/input[2]".format(i)
srv_actions = selenium.find_element_by_xpath(xpath)
assert srv_title == k
values = (
srv_active, srv_ren, srv_cred,
srv_actions.get_attribute(name='value'),
srv_actions.is_enabled()
)
assert values == v
Markdown is supported
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