Skip to content

Commit b0a5909

Browse files
committed
Update appointment note system spec to cover deletion
1 parent 482b4c4 commit b0a5909

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

manage_breast_screening/tests/system/clinical/test_appointment_note.py

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,24 @@ def test_clinical_user_adds_and_updates_an_appointment_note(self):
2121
self.when_i_enter_a_note()
2222
self.and_i_save_the_note()
2323
self.then_i_see_a_message_confirming_the_save()
24-
self.then_the_note_field_contains(self.initial_note_text)
24+
self.and_the_note_field_contains(self.initial_note_text)
2525
self.and_the_appointment_details_tab_shows_the_note(self.initial_note_text)
2626

2727
self.when_i_update_the_note()
2828
self.and_i_save_the_note()
2929
self.then_i_see_a_message_confirming_the_save()
30-
self.then_the_note_field_contains(self.updated_note_text)
30+
self.and_the_note_field_contains(self.updated_note_text)
3131
self.and_the_appointment_details_tab_shows_the_note(self.updated_note_text)
3232

33+
self.when_i_click_the_note_change_link()
34+
self.and_i_click_delete_note()
35+
self.and_i_click_cancel()
36+
self.then_the_note_is_not_deleted()
37+
38+
self.when_i_click_delete_note()
39+
self.and_i_confirm_deletion()
40+
self.then_the_note_is_deleted()
41+
3342
def and_there_is_an_appointment_for_my_provider(self):
3443
self.appointment = AppointmentFactory(
3544
clinic_slot__clinic__setting__provider=self.current_provider
@@ -67,7 +76,7 @@ def and_i_save_the_note(self):
6776
def when_i_save_the_note(self):
6877
self.and_i_save_the_note()
6978

70-
def then_the_note_field_contains(self, text):
79+
def and_the_note_field_contains(self, text):
7180
expect(self.page.get_by_label("Note")).to_have_value(text)
7281

7382
def then_i_see_a_message_confirming_the_save(self):
@@ -86,3 +95,38 @@ def and_the_appointment_details_tab_shows_the_note(self, text):
8695
)
8796
expect(note_container).to_be_visible()
8897
expect(note_container).to_contain_text(text)
98+
99+
def when_i_click_the_note_change_link(self):
100+
note_container = self.page.locator(
101+
".nhsuk-warning-callout", has_text="Appointment note"
102+
)
103+
expect(note_container).to_be_visible()
104+
change_link = note_container.get_by_role("link", name="Change")
105+
change_link.click()
106+
107+
def and_i_click_delete_note(self):
108+
delete_link = self.page.get_by_role("link", name="Delete appointment note")
109+
expect(delete_link).to_be_visible()
110+
delete_link.click()
111+
112+
def when_i_click_delete_note(self):
113+
self.and_i_click_delete_note()
114+
115+
def and_i_click_cancel(self):
116+
cancel_link = self.page.get_by_role("link", name="Cancel")
117+
expect(cancel_link).to_be_visible()
118+
cancel_link.click()
119+
120+
def then_the_note_is_not_deleted(self):
121+
expect(self.page.get_by_label("Note")).to_have_value(self.updated_note_text)
122+
123+
def and_i_confirm_deletion(self):
124+
delete_button = self.page.get_by_role("button", name="Delete appointment note")
125+
expect(delete_button).to_be_visible()
126+
delete_button.click()
127+
128+
def then_the_note_is_deleted(self):
129+
banner = self.page.locator(".nhsuk-notification-banner--success")
130+
expect(banner).to_be_visible()
131+
expect(banner).to_contain_text("Appointment note deleted")
132+
expect(self.page.get_by_label("Note")).to_have_value("")

0 commit comments

Comments
 (0)