Skip to content

Commit 7b64e2a

Browse files
committed
Add appointment note system test
1 parent 0438c68 commit 7b64e2a

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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_save_the_note()
19+
self.then_i_see_a_validation_error()
20+
21+
self.when_i_enter_a_note()
22+
self.and_i_save_the_note()
23+
self.then_the_note_field_contains(self.initial_note_text)
24+
25+
self.when_i_update_the_note()
26+
self.and_i_save_the_note()
27+
self.then_the_note_field_contains(self.updated_note_text)
28+
29+
def and_there_is_an_appointment_for_my_provider(self):
30+
self.appointment = AppointmentFactory(
31+
clinic_slot__clinic__setting__provider=self.current_provider
32+
)
33+
34+
def and_i_am_on_the_appointment_note_page(self):
35+
self.page.goto(
36+
self.live_server_url
37+
+ reverse("mammograms:appointment_note", kwargs={"pk": self.appointment.pk})
38+
)
39+
self.expect_url("mammograms:appointment_note", pk=self.appointment.pk)
40+
41+
def then_i_see_a_validation_error(self):
42+
self.expect_validation_error(
43+
error_text="Enter a note",
44+
field_label="Note",
45+
)
46+
47+
def when_i_enter_a_note(self):
48+
self.page.get_by_label("Note").fill(self.initial_note_text)
49+
50+
def when_i_update_the_note(self):
51+
field = self.page.get_by_label("Note")
52+
expect(field).to_have_value(self.initial_note_text)
53+
field.fill(self.updated_note_text)
54+
55+
def and_i_save_the_note(self):
56+
self.page.get_by_role("button", name="Save note").click()
57+
self.expect_url("mammograms:appointment_note", pk=self.appointment.pk)
58+
59+
def when_i_save_the_note(self):
60+
self.and_i_save_the_note()
61+
62+
def then_the_note_field_contains(self, text):
63+
expect(self.page.get_by_label("Note")).to_have_value(text)

0 commit comments

Comments
 (0)