Skip to content
Merged
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
5 changes: 3 additions & 2 deletions manage_breast_screening/clinics/jinja2/clinics/show.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{% block beforeContent %}
{{ backLink({
"href": url('clinics:index'),
"text": "Clinics"
}) }}
{% endblock beforeContent %}

Expand Down Expand Up @@ -49,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 @@ -69,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 @@ -66,10 +66,11 @@ def test_accessibility(self):
def test_status_attribution_display(self):
self.given_i_am_logged_in_as_a_clinical_user()
self.and_a_clinic_exists_that_is_run_by_my_provider()
self.and_i_have_an_appointment_in_progress()
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_status_attribution_for_these_appointments()

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 +267,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 @@ -278,17 +278,6 @@ def and_there_are_appointments_in_various_statuses_with_attributed_users(self):
last_name="Confirmed",
)

# STARTED status
self.in_progress_appointment = AppointmentFactory(
clinic_slot__clinic=self.clinic,
first_name="Participant",
last_name="InProgress",
)
self.in_progress_appointment.statuses.create(
name=AppointmentStatus.STARTED,
created_by=user_in_progress,
)

# SCREENED status
self.screened_appointment = AppointmentFactory(
clinic_slot__clinic=self.clinic,
Expand All @@ -311,7 +300,7 @@ def and_there_are_appointments_in_various_statuses_with_attributed_users(self):
created_by=user_cancelled,
)

def then_i_can_see_status_attribution_for_relevant_appointments(self):
def then_i_can_see_status_attribution_for_these_appointments(self):
confirmed_row = self.page.locator("tr").filter(has_text="Participant Confirmed")

expect(confirmed_row).not_to_contain_text("with")
Expand All @@ -320,10 +309,26 @@ 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(
f"with {self.current_user.get_short_name()} (you)"
)

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

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

def and_i_have_an_appointment_in_progress(self):
self.in_progress_appointment = AppointmentFactory(
clinic_slot__clinic=self.clinic,
first_name="Participant",
last_name="InProgress",
)
self.in_progress_appointment.statuses.create(
name=AppointmentStatus.STARTED,
created_by=self.current_user,
)
5 changes: 4 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,9 +78,9 @@ 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)

Expand Down