From 7a236f7741dbd0c6a17a0386474c349619041362 Mon Sep 17 00:00:00 2001 From: ZGr3Y Date: Fri, 27 Nov 2026 12:18:45 +0100 Subject: [PATCH 1/2] test: add contact email scenario --- tests/features/contact.feature | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/features/contact.feature diff --git a/tests/features/contact.feature b/tests/features/contact.feature new file mode 100644 index 0000000..ddb2767 --- /dev/null +++ b/tests/features/contact.feature @@ -0,0 +1,8 @@ +Feature: Contact information + + Background: + Given I'm on the contact page + + Scenario: View the student office email + Then the student office email is visible + And the email is "student.office@example.com" \ No newline at end of file From a247ba18ffbd87b83ae6ea531ee0cb19a6d647db Mon Sep 17 00:00:00 2001 From: ZGr3Y Date: Fri, 27 Nov 2026 12:38:23 +0100 Subject: [PATCH 2/2] test: implement contact email scenario --- pages/contact_page.py | 10 ++++++++++ tests/test_contact_bdd.py | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 pages/contact_page.py create mode 100644 tests/test_contact_bdd.py diff --git a/pages/contact_page.py b/pages/contact_page.py new file mode 100644 index 0000000..56ad18a --- /dev/null +++ b/pages/contact_page.py @@ -0,0 +1,10 @@ +from playwright.sync_api import Page + + +class ContactPage: + def __init__(self, page: Page) -> None: + self.page = page + self.email = page.get_by_test_id("contact-email") + + def goto(self) -> None: + self.page.goto("/contact") diff --git a/tests/test_contact_bdd.py b/tests/test_contact_bdd.py new file mode 100644 index 0000000..0b12989 --- /dev/null +++ b/tests/test_contact_bdd.py @@ -0,0 +1,23 @@ +from playwright.sync_api import Page, expect +from pytest_bdd import given, parsers, scenarios, then + +from pages.contact_page import ContactPage + +scenarios("features/contact.feature") + + +@given("I'm on the contact page", target_fixture="contact_page") +def open_contact_page(page: Page) -> ContactPage: + contact_page = ContactPage(page) + contact_page.goto() + return contact_page + + +@then("the student office email is visible") +def email_is_visible(contact_page: ContactPage) -> None: + expect(contact_page.email).to_be_visible() + + +@then(parsers.parse('the email is "{email}"')) +def email_has_expected_text(contact_page: ContactPage, email: str) -> None: + expect(contact_page.email).to_have_text(email)