Skip to content

Commit cb43f8f

Browse files
committed
Test for appointment status bar
1 parent e198883 commit cb43f8f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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.appointment import AppointmentStatus
46
from manage_breast_screening.participants.models.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):
@@ -81,6 +88,13 @@ def then_i_see_the_add_benign_lump_history_form(self):
8188
expect(self.page.get_by_text("Add details of benign lumps")).to_be_visible()
8289
self.assert_page_title_contains("Add details of benign lumps")
8390

91+
def and_i_see_the_appointment_status_bar(self):
92+
status_bar = self.page.locator("div.app-status-bar")
93+
expect(status_bar).to_contain_text(
94+
format_nhs_number(self.participant.nhs_number)
95+
)
96+
expect(status_bar).to_contain_text(self.participant.full_name)
97+
8498
def when_i_try_to_save_without_entering_benign_lump_details(self):
8599
self.page.get_by_role("button", name="Save").click()
86100

0 commit comments

Comments
 (0)