Skip to content

Commit 7a38a4b

Browse files
committed
Test for appointment status bar
1 parent b0e21b2 commit 7a38a4b

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

manage_breast_screening/mammograms/presenters/appointment_presenters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def note(self):
120120
except AppointmentNote.DoesNotExist:
121121
return None
122122

123+
@cached_property
123124
def status_bar(self):
124125
return StatusBarPresenter(self)
125126

manage_breast_screening/participants/tests/factories.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ def current_status(obj, create, extracted, **kwargs):
160160
AppointmentStatusFactory.create(state=extracted, appointment=obj)
161161
)
162162

163+
# Allow passing an explicit status and created_by user
164+
# e.g. `current_status_params={'state': AppointmentStatus.IN_PROGRESS, 'created_by': self.current_user}`
165+
@post_generation
166+
def current_status_params(obj, create, extracted, **kwargs):
167+
if not create or not extracted:
168+
return
169+
obj.statuses.add(AppointmentStatusFactory.create(appointment=obj, **extracted))
170+
163171

164172
class AppointmentNoteFactory(DjangoModelFactory):
165173
class Meta:

manage_breast_screening/tests/system/clinical/test_benign_lump_history.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from django.urls import reverse
22
from playwright.sync_api import expect
33

4+
from manage_breast_screening.core.utils.string_formatting import format_nhs_number
5+
from manage_breast_screening.participants.models import AppointmentStatus
46
from manage_breast_screening.participants.models.medical_history.benign_lump_history_item import (
57
BenignLumpHistoryItem,
68
)
@@ -21,6 +23,7 @@ def test_adding_a_benign_lump_history_item(self):
2123
self.and_i_am_on_the_record_medical_information_page()
2224
self.when_i_click_on_benign_lumps()
2325
self.then_i_see_the_add_benign_lump_history_form()
26+
self.and_i_see_the_appointment_status_bar()
2427
self.when_i_try_to_save_without_entering_benign_lump_details()
2528
self.then_i_see_validation_errors_for_missing_benign_lump_details()
2629

@@ -63,6 +66,10 @@ def and_there_is_an_appointment(self):
6366
self.appointment = AppointmentFactory(
6467
screening_episode=self.screening_episode,
6568
clinic_slot__clinic__setting__provider=self.current_provider,
69+
current_status_params={
70+
"state": AppointmentStatus.IN_PROGRESS,
71+
"created_by": self.current_user,
72+
},
6673
)
6774

6875
def and_i_am_on_the_record_medical_information_page(self):
@@ -74,6 +81,13 @@ def and_i_am_on_the_record_medical_information_page(self):
7481
)
7582
)
7683

84+
def and_i_see_the_appointment_status_bar(self):
85+
status_bar = self.page.locator("div.app-status-bar")
86+
expect(status_bar).to_contain_text(
87+
format_nhs_number(self.participant.nhs_number)
88+
)
89+
expect(status_bar).to_contain_text(self.participant.full_name)
90+
7791
def when_i_click_on_benign_lumps(self):
7892
self.page.get_by_role("button").filter(has_text="Benign lumps").click()
7993

0 commit comments

Comments
 (0)