Skip to content

Commit

Permalink
Header Element ID's added
Browse files Browse the repository at this point in the history
- IDs added to all elements to aid testing
  • Loading branch information
ojusharma committed Apr 9, 2024
1 parent 1d422f8 commit 6898f8d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
18 changes: 9 additions & 9 deletions Django/communicado/pages/templates/pages/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@
</head>
<body>

<header>
<a href="{% url 'home' %}">
<img src="{% static 'logo.jpg' %}" alt="Logo">
<header id="main-header">
<a href="{% url 'home' %}" id="logo-link">
<img src="{% static 'logo.jpg' %}" alt="Logo" id="logo-image">
</a>

<nav>
<nav id="main-nav">
{% if not request.session.userID %}
<a href="{% url 'login' %}">Login</a>
<a href="{% url 'login' %}" id="login-link">Login</a>
{% else %}
<a href="{% url 'useracc' %}">{{ request.session.userName}}'s Account</a>
<a href="{% url 'useracc' %}" id="user-account-link">{{ request.session.userName}}'s Account</a>
{% endif %}

<a href="#">View Cart</a>
<a href="#" id="view-cart-link">View Cart</a>

{% if request.session.userRole == 'Admin' %}
<a href="admin">Admin Panel</a>
<a href="admin" id="admin-panel-link">Admin Panel</a>
{% endif %}

{% if request.session.userID %}
<a href="{% url 'logout' %}">Log Out</a>
<a href="{% url 'logout' %}" id="logout-link">Log Out</a>
{% endif %}
</nav>
</header>
Expand Down
30 changes: 13 additions & 17 deletions Django/communicado/pages/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,10 @@
from django.test import LiveServerTestCase
from django.contrib.auth.hashers import make_password
from django.shortcuts import render
#from selenium import webdriver
#from selenium.webdriver.common.keys import Keys
#from selenium.webdriver.chrome.options import Options
import time

# Example 1

#class Hosttest(LiveServerTestCase):

# def testhomepage(self):
# options = Options()
# options.headless = True
# driver = webdriver.Chrome(options=options)
# driver.get(self.live_server_url)
# try driver.get(self.live_server_url) if driver.get('http://127.0.0.1:8000/') does not work
# assert "Hello, world!" in driver.title
from django.test import TestCase, RequestFactory
from django.contrib.auth.models import User
from django.urls import reverse
from django.contrib.sessions.middleware import SessionMiddleware

class UsersTestCase(TestCase):

Expand Down Expand Up @@ -679,4 +667,12 @@ def test_xyz_page_contains_expected_paragraphs(self):
"Join us in this exhilarating adventure as we redefine the way events are experienced and enjoyed. Welcome aboard!"
]
for paragraph in expected_paragraphs:
self.assertContains(response, paragraph, html=True)
self.assertContains(response, paragraph, html=True)

def test_header_not_logged_in(self):
response = self.client.get(reverse('xyz'))

self.assertEqual(response.status_code, 200)

self.assertContains(response, "View Cart")
self.assertContains(response, "Login")

0 comments on commit 6898f8d

Please sign in to comment.