Skip to content

Commit 6efc53c

Browse files
committed
Add appointment note system test
1 parent 5b1f0c7 commit 6efc53c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from django.urls import reverse
2+
from playwright.sync_api import expect
3+
4+
from manage_breast_screening.participants.tests.factories import AppointmentFactory
5+
6+
from ..system_test_setup import SystemTestCase
7+
8+
9+
class TestAppointmentNote(SystemTestCase):
10+
def test_clinical_user_adds_and_updates_an_appointment_note(self):
11+
self.initial_note_text = "Participant prefers an evening appointment."
12+
self.updated_note_text = "Participant prefers morning appointments only."
13+
14+
self.given_i_am_logged_in_as_a_clinical_user()
15+
self.and_there_is_an_appointment_for_my_provider()
16+
self.and_i_am_on_the_appointment_note_page()
17+
18+
self.when_i_enter_a_note()
19+
self.and_i_save_the_note()
20+
self.then_the_note_field_contains(self.initial_note_text)
21+
22+
self.when_i_update_the_note()
23+
self.and_i_save_the_note()
24+
self.then_the_note_field_contains(self.updated_note_text)
25+
26+
def and_there_is_an_appointment_for_my_provider(self):
27+
self.appointment = AppointmentFactory(
28+
clinic_slot__clinic__setting__provider=self.current_provider
29+
)
30+
31+
def and_i_am_on_the_appointment_note_page(self):
32+
self.page.goto(
33+
self.live_server_url
34+
+ reverse("mammograms:appointment_note", kwargs={"pk": self.appointment.pk})
35+
)
36+
self.expect_url("mammograms:appointment_note", pk=self.appointment.pk)
37+
38+
def when_i_enter_a_note(self):
39+
self.page.get_by_label("Note").fill(self.initial_note_text)
40+
41+
def when_i_update_the_note(self):
42+
field = self.page.get_by_label("Note")
43+
expect(field).to_have_value(self.initial_note_text)
44+
field.fill(self.updated_note_text)
45+
46+
def and_i_save_the_note(self):
47+
self.page.get_by_role("button", name="Save note").click()
48+
self.expect_url("mammograms:appointment_note", pk=self.appointment.pk)
49+
50+
def then_the_note_field_contains(self, text):
51+
expect(self.page.get_by_label("Note")).to_have_value(text)

0 commit comments

Comments
 (0)