aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctrack/templates/account/login.html2
-rw-r--r--ctrack/users/tests/test_functional.py26
2 files changed, 25 insertions, 3 deletions
diff --git a/ctrack/templates/account/login.html b/ctrack/templates/account/login.html
index bb261f4..f395478 100644
--- a/ctrack/templates/account/login.html
+++ b/ctrack/templates/account/login.html
@@ -38,7 +38,7 @@ for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
{% endif %}
<a class="button secondaryAction" href="{% url 'account_reset_password' %}">{% trans "Forgot Password?" %}</a>
- <button class="primaryAction btn btn-primary" type="submit">{% trans "Sign In" %}</button>
+ <button class="primaryAction btn btn-primary" id="sign_in_button" type="submit">{% trans "Sign In" %}</button>
</form>
{% endblock %}
diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py
index 6403d0b..2ba5faf 100644
--- a/ctrack/users/tests/test_functional.py
+++ b/ctrack/users/tests/test_functional.py
@@ -1,12 +1,34 @@
+"""
+Functional tests. Are probably SLOW thanks to using Selenium to load a browser instance.
+
+The use case being tested here is related to a user being able to log in and hit
+the correct page, containing their details. Those details depend on whether they are
+a regular user or a stakeholder user.
+"""
+
+import time
+
import pytest
from ctrack.organisations.models import Stakeholder
+from ctrack.users.models import User
pytestmark = pytest.mark.django_db
-def test_profile_page_html(person, user, browser):
+def test_user_can_log_in(browser, live_server):
+ User.objects.create_user(username="toss", password="knob")
+ browser.get(live_server + "/accounts/login")
+ browser.find_element_by_id("id_login").send_keys("toss")
+ browser.find_element_by_id("id_password").send_keys("knob")
+ browser.find_element_by_id("sign_in_button").submit()
+ time.sleep(1)
+ current_url = browser.current_url
+ assert current_url == live_server + "/users/toss/"
+
+
+def test_profile_page_html(person, user, browser, live_server):
stakeholder = Stakeholder.objects.create(person=person)
user.stakeholder = stakeholder
user.save()
- browser.get(f"http://localhost:8000/users/{user.username}")
+ browser.get(live_server + f"/users/{user.username}/")