Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions manage_breast_screening/clinics/jinja2/clinics/show.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% block beforeContent %}
{{ backLink({
"href": url('clinics:index'),
"text": "Go back"
"text": "Clinics"
}) }}
{% endblock beforeContent %}

Expand Down Expand Up @@ -50,7 +50,7 @@
<p class="nhsuk-u-margin-bottom-1 nhsuk-u-font-weight-bold">
{{ presented_appointment.participant.full_name }}
</p>
<p class="nhsuk-u-secondary-text-color nhsuk-u-margin-bottom-0">
<p class="nhsuk-u-secondary-text-colour">
NHS: {{ presented_appointment.participant.nhs_number }}
</p>
{% endset %}
Expand All @@ -70,7 +70,7 @@
app_appointment_status(presented_appointment)
}}
{% if presented_appointment.status_attribution %}
<span class="app-text-grey app-nowrap nhsuk-body-s nhsuk-u-margin-bottom-0">{{ presented_appointment.status_attribution }}</span>
<p class="nhsuk-u-secondary-text-colour">{{ presented_appointment.status_attribution }} {{presented_appointment.attribution_user_check(request.user)}}</p>
{% endif %}
<p class="nhsuk-u-margin-top-2 nhsuk-u-margin-bottom-0 app-u-nowrap">
<a href="{{ url('mammograms:show_appointment', kwargs={"pk": presented_appointment.pk}) }}" class="nhsuk-link">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ def status_attribution(self):
else:
return None

def attribution_user_check(self, user):
if user.pk == self._appointment.current_status.created_by.pk:
return " (you)"
else:
return ""

@cached_property
def note(self):
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.urls import reverse
from playwright.sync_api import expect

from manage_breast_screening.auth.models import Role
from manage_breast_screening.clinics.models import Clinic
from manage_breast_screening.clinics.tests.factories import ClinicFactory
from manage_breast_screening.core.utils.date_formatting import format_date, format_time
Expand Down Expand Up @@ -64,12 +65,13 @@ def test_accessibility(self):
self.then_the_accessibility_baseline_is_met()

def test_status_attribution_display(self):
self.given_i_am_logged_in_as_a_clinical_user()
self.given_i_am_logged_in_as_a_user_with_appointment_in_progress()
self.and_a_clinic_exists_that_is_run_by_my_provider()
self.and_there_are_appointments_in_various_statuses_with_attributed_users()
self.and_i_am_on_the_clinic_show_page()
self.when_i_click_on_all()
self.then_i_can_see_status_attribution_for_relevant_appointments()
self.then_i_can_see_you_in_status_attribution()

def and_a_clinic_exists_that_is_run_by_my_provider(self):
user_assignment = self.current_user.assignments.first()
Expand Down Expand Up @@ -266,7 +268,6 @@ def then_i_can_see_the_special_appointment_banner(self):

def and_there_are_appointments_in_various_statuses_with_attributed_users(self):
# Create users for attribution
user_in_progress = UserFactory(first_name="Alice", last_name="User")
user_screened = UserFactory(first_name="Bob", last_name="User")
user_cancelled = UserFactory(first_name="Charlie", last_name="User")

Expand All @@ -286,7 +287,7 @@ def and_there_are_appointments_in_various_statuses_with_attributed_users(self):
)
self.in_progress_appointment.statuses.create(
name=AppointmentStatus.STARTED,
created_by=user_in_progress,
created_by=self.user_in_progress,
)

# SCREENED status
Expand Down Expand Up @@ -320,10 +321,24 @@ def then_i_can_see_status_attribution_for_relevant_appointments(self):
in_progress_row = self.page.locator("tr").filter(
has_text="Participant InProgress"
)
expect(in_progress_row).to_contain_text("with A. User")
expect(in_progress_row).to_contain_text("with A. InProgress (you)")

screened_row = self.page.locator("tr").filter(has_text="Participant Screened")
expect(screened_row).to_contain_text("by B. User")

cancelled_row = self.page.locator("tr").filter(has_text="Participant Cancelled")
expect(cancelled_row).to_contain_text("by C. User")

def given_i_am_logged_in_as_a_user_with_appointment_in_progress(self):
# Create and log in the user who will be attributed with the IN_PROGRESS status
self.user_in_progress = self.create_user_with_role(
first_name="Alice", last_name="InProgress", role=Role.CLINICAL
)
self.login_as_user(self.user_in_progress)

def then_i_can_see_you_in_status_attribution(self):
# Check that the "(you)" indicator is present for the in-progress attribution
in_progress_row = self.page.locator("tr").filter(
has_text="Participant InProgress"
)
expect(in_progress_row).to_contain_text("(you)")
12 changes: 11 additions & 1 deletion manage_breast_screening/tests/system/system_test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def login_as_user(self, user: User):
Emulate logging in as a particular user, without needing
to visit a login page.
"""

self.current_user = user

# Fake a login
client = Client()
client.force_login(user)
Expand Down Expand Up @@ -75,12 +78,19 @@ def login_as_role(self, role: Role):
without needing to visit a login page.
"""
user = UserFactory.create()

UserAssignmentFactory.create(user=user, roles=[role.value])

self.current_user = user
self.current_provider = user.assignments.first().provider
self.login_as_user(user)

def create_user_with_role(
self, first_name: str, last_name: str, role: Role
) -> User:
user = UserFactory.create(first_name=first_name, last_name=last_name)
UserAssignmentFactory.create(user=user, roles=[role.value])
return user

def expect_validation_error(
self,
error_text: str,
Expand Down