|
| 1 | +from datetime import datetime, timezone |
| 2 | +from zoneinfo import ZoneInfo |
| 3 | + |
| 4 | +from django.urls import reverse |
| 5 | +from playwright.sync_api import expect |
| 6 | + |
| 7 | +from manage_breast_screening.clinics.tests.factories import ClinicFactory |
| 8 | +from manage_breast_screening.participants.models import AppointmentStatus |
| 9 | +from manage_breast_screening.participants.tests.factories import AppointmentFactory |
| 10 | + |
| 11 | +from ..system_test_setup import SystemTestCase |
| 12 | + |
| 13 | + |
| 14 | +class TestJavascriptLoadsInSystemTests(SystemTestCase): |
| 15 | + def test_check_in_component_initialised(self): |
| 16 | + self.given_i_am_logged_in_as_a_clinical_user() |
| 17 | + self.and_there_is_an_appointment() |
| 18 | + self.when_i_visit_the_clinic_page() |
| 19 | + self.then_the_check_in_component_is_initialised() |
| 20 | + |
| 21 | + def and_there_is_an_appointment(self): |
| 22 | + assignment = self.current_user.assignments.first() |
| 23 | + self.clinic = ClinicFactory( |
| 24 | + starts_at=datetime.now(timezone.utc).replace(hour=9, minute=0), |
| 25 | + setting__provider=assignment.provider, |
| 26 | + ) |
| 27 | + tzinfo = ZoneInfo("Europe/London") |
| 28 | + self.appointment = AppointmentFactory( |
| 29 | + clinic_slot__clinic=self.clinic, |
| 30 | + clinic_slot__starts_at=datetime.now(timezone.utc).replace( |
| 31 | + hour=9, minute=0, tzinfo=tzinfo |
| 32 | + ), |
| 33 | + current_status=AppointmentStatus.CONFIRMED, |
| 34 | + ) |
| 35 | + |
| 36 | + def when_i_visit_the_clinic_page(self): |
| 37 | + self.page.goto( |
| 38 | + self.live_server_url |
| 39 | + + reverse("clinics:show", kwargs={"pk": self.clinic.pk}) |
| 40 | + ) |
| 41 | + |
| 42 | + def then_the_check_in_component_is_initialised(self): |
| 43 | + component = self.page.locator('[data-module="app-check-in"]').first |
| 44 | + expect(component).to_have_attribute("data-app-check-in-init", "") |
0 commit comments