|
| 1 | +import pytest |
| 2 | +from django.urls import reverse |
| 3 | +from playwright.sync_api import expect |
| 4 | + |
| 5 | +from manage_breast_screening.core.system_test_setup import SystemTestCase |
| 6 | +from manage_breast_screening.participants.models import AppointmentStatus |
| 7 | +from manage_breast_screening.participants.tests.factories import ( |
| 8 | + AppointmentFactory, |
| 9 | + ParticipantFactory, |
| 10 | + ScreeningEpisodeFactory, |
| 11 | +) |
| 12 | + |
| 13 | + |
| 14 | +class TestViewingACompletedAppointment(SystemTestCase): |
| 15 | + @pytest.fixture(autouse=True) |
| 16 | + def before(self): |
| 17 | + self.participant = ParticipantFactory(first_name="Janet", last_name="Williams") |
| 18 | + self.screening_episode = ScreeningEpisodeFactory(participant=self.participant) |
| 19 | + self.appointment = AppointmentFactory( |
| 20 | + screening_episode=self.screening_episode, |
| 21 | + current_status=AppointmentStatus.SCREENED, |
| 22 | + ) |
| 23 | + |
| 24 | + def test_viewing_a_completed_appointment(self): |
| 25 | + """ |
| 26 | + The appointment page includes appointment details, medical information, and images tabs. |
| 27 | + Only the first one is implemented yet. |
| 28 | + """ |
| 29 | + self.given_i_am_on_the_appointment_show_page() |
| 30 | + self.then_i_should_see_the_demographic_banner() |
| 31 | + self.and_i_should_see_the_participant_details() |
| 32 | + self.and_i_should_not_see_a_form() |
| 33 | + |
| 34 | + def test_accessibility(self): |
| 35 | + self.given_i_am_on_the_appointment_show_page() |
| 36 | + self.then_the_accessibility_baseline_is_met() |
| 37 | + |
| 38 | + def given_i_am_on_the_appointment_show_page(self): |
| 39 | + self.page.goto( |
| 40 | + self.live_server_url |
| 41 | + + reverse( |
| 42 | + "mammograms:show_appointment", |
| 43 | + kwargs={"pk": self.appointment.pk}, |
| 44 | + ) |
| 45 | + ) |
| 46 | + |
| 47 | + def then_i_should_see_the_demographic_banner(self): |
| 48 | + expect(self.page.get_by_text("NHS Number")).to_be_visible() |
| 49 | + |
| 50 | + def and_i_should_see_the_participant_details(self): |
| 51 | + expect( |
| 52 | + self.page.locator(".nhsuk-summary-list__row", has_text="Full name") |
| 53 | + ).to_contain_text("Janet Williams") |
| 54 | + |
| 55 | + def and_i_should_not_see_a_form(self): |
| 56 | + expect(self.page.get_by_role("form")).not_to_be_attached() |
0 commit comments