Skip to content

Commit e1ad06c

Browse files
committed
worked on review comments
1 parent 39ea0b1 commit e1ad06c

File tree

10 files changed

+137
-237
lines changed

10 files changed

+137
-237
lines changed

conftest.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,3 @@ def smokescreen_properties() -> dict:
3838
@pytest.fixture
3939
def general_properties() -> dict:
4040
return PropertiesFile().get_general_properties()
41-
42-
43-
@pytest.fixture
44-
def login_as(page):
45-
"""Fixture to log in as a specific role."""
46-
47-
def _login(role: str):
48-
"""Log in to the application as a specific role.
49-
Args:
50-
role (str): The role to log in as, e.g., "ScreeningAssistant at BCS02".
51-
"""
52-
logging.info(f"Logging in as '{role}'.")
53-
UserTools.user_login(page, role)
54-
BasePage(page).go_to_screening_subject_search_page()
55-
56-
return _login

docs/utility-guides/SubjectNotes.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
The **Note Test Utility** module provides reusable helper functions for verifying and comparing note data during test automation of screening subjects in BCSS.
44
It includes helpers for:
55

6-
1. Searching for a subject by NHS number.
7-
2. Fetching supporting notes from the database.
8-
3. Verifying that a note matches expected values from the DB or UI.
9-
4. Confirming that a removed note is archived properly as obsolete.
6+
1. Fetching supporting notes from the database.
7+
2. Verifying that a note matches expected values from the DB or UI.
8+
3. Confirming that a removed note is archived properly as obsolete.
109

1110
## Table of Contents
1211

@@ -22,7 +21,6 @@ You can import functions into your test files like so:
2221

2322
```python
2423
from utils.note_test_util import (
25-
search_subject_by_nhs,
2624
fetch_supporting_notes_from_db,
2725
verify_note_content_matches_expected,
2826
verify_note_content_ui_vs_db,

pages/screening_subject_search/subject_events_notes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from playwright.sync_api import Page, expect, Locator
1+
from playwright.sync_api import Page, Locator
22
from pages.base_page import BasePage
33
from enum import StrEnum
44
import logging

pages/screening_subject_search/subject_screening_search_page.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ def click_nhs_number_filter(self) -> None:
8282
"""Click the 'NHS Number' filter."""
8383
self.click(self.nhs_number_filter)
8484

85-
def fill_nhs_number(self, nhs_no: str) -> None:
86-
"""
87-
Fills the NHS Number field with the provided NHS number.
88-
89-
Args:
90-
nhs_no (str): The NHS number to fill in the input field.
91-
"""
92-
self.nhs_number_input.fill(nhs_no)
93-
9485
def click_surname_filter(self) -> None:
9586
"""Click the 'Surname' filter."""
9687
self.click(self.surname_filter)

pytest.ini

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ markers =
3939
vpn_required: for tests that require a VPN connection
4040
regression: tests that are part of the regression test suite
4141
call_and_recall: tests that are part of the call and recall test suite
42-
notes_tests: tests that are part of the notes test suite
42+
note_tests: tests that are part of the notes test suite
4343
subject_tests: tests that are part of the subject tests suite
4444
subject_search: tests that are part of the subject search test suite
45-
wip2: tests that are currently in progress
46-

tests/regression/notes/test_additional_care_notes.py

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import logging
22
import pytest
33
from playwright.sync_api import Page, expect
4-
from pages import login, screening_subject_search
4+
from utils.user_tools import UserTools
55
from pages.base_page import BasePage
6-
from pages.screening_subject_search import subject_screening_search_page
7-
from pages.screening_subject_search import subject_screening_summary_page
8-
from pages.screening_subject_search import subject_events_notes
96
from pages.screening_subject_search.subject_screening_search_page import (
107
SubjectScreeningPage,
118
)
@@ -18,16 +15,12 @@
1815
SubjectEventsNotes,
1916
AdditionalCareNoteTypeOptions,
2017
)
21-
from utils.user_tools import UserTools
22-
from utils.table_util import TableUtils
2318
from utils.oracle.oracle_specific_functions import (
2419
get_subjects_by_note_count,
2520
get_subjects_with_multiple_notes,
26-
get_supporting_notes,
2721
)
28-
import pandas as pd
22+
from utils.screening_subject_page_searcher import search_subject_episode_by_nhs_number
2923
from utils.subject_notes import (
30-
search_subject_by_nhs,
3124
fetch_supporting_notes_from_db,
3225
verify_note_content_matches_expected,
3326
verify_note_content_ui_vs_db,
@@ -38,16 +31,16 @@
3831
@pytest.mark.regression
3932
@pytest.mark.note_tests
4033
def test_subject_does_not_have_an_additional_care_note(
41-
page: Page, general_properties: dict, login_as
34+
page: Page, general_properties: dict
4235
) -> None:
4336
"""
4437
Test to check if I can identify if a subject does not have a Additional Care note
4538
"""
4639
logging.info(
4740
f"Starting test: Verify subject does not have a '{general_properties["additional_care_note_name"]}'."
4841
)
49-
# Use the login fixture
50-
login_as("ScreeningAssistant at BCS02")
42+
UserTools.user_login(page, "ScreeningAssistant at BCS02")
43+
BasePage(page).go_to_screening_subject_search_page()
5144

5245
# Search for the subject by NHS Number.")
5346
subjects_df = get_subjects_by_note_count(
@@ -61,9 +54,7 @@ def test_subject_does_not_have_an_additional_care_note(
6154
)
6255

6356
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
64-
SubjectScreeningPage(page).fill_nhs_number(nhs_no)
65-
SubjectScreeningPage(page).select_search_area_option("07")
66-
SubjectScreeningPage(page).click_search_button()
57+
search_subject_episode_by_nhs_number(page, nhs_no)
6758
# Verify no additional care notes are present
6859
logging.info(
6960
f"Verified that no '{general_properties['additional_care_note_name']}' link is visible for the subject."
@@ -77,16 +68,16 @@ def test_subject_does_not_have_an_additional_care_note(
7768
@pytest.mark.regression
7869
@pytest.mark.note_tests
7970
def test_add_an_additional_care_note_for_a_subject_without_a_note(
80-
page: Page, general_properties: dict, login_as
71+
page: Page, general_properties: dict
8172
) -> None:
8273
"""
8374
Test to add a note for a subject without an additional care note.
8475
"""
8576
logging.info(
8677
"Starting test: Add a '{general_properties['additional_care_note_name']}' for a subject without a note."
8778
)
88-
# Use the login fixture
89-
login_as("Team Leader at BCS01")
79+
UserTools.user_login(page, "Team Leader at BCS01")
80+
BasePage(page).go_to_screening_subject_search_page()
9081

9182
# Get a subject with no notes of the specified type
9283
subjects_df = get_subjects_by_note_count(
@@ -99,7 +90,8 @@ def test_add_an_additional_care_note_for_a_subject_without_a_note(
9990
f"No subjects found for note type {general_properties["additional_care_note_type_value"]}."
10091
)
10192
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
102-
search_subject_by_nhs(page, nhs_no)
93+
search_subject_episode_by_nhs_number(page, nhs_no)
94+
# search_subject_by_nhs(page, nhs_no)
10395

10496
# Navigate to Subject Events & Notes
10597
logging.info("Navigating to 'Subject Events & Notes' for the selected subject.")
@@ -128,9 +120,7 @@ def test_add_an_additional_care_note_for_a_subject_without_a_note(
128120
subjects_df, nhs_no, general_properties["note_status_active"]
129121
)
130122

131-
verify_note_content_matches_expected(
132-
notes_df, note_title, note_text, type_id
133-
)
123+
verify_note_content_matches_expected(notes_df, note_title, note_text, type_id)
134124

135125
logging.info(
136126
f"Verification successful: Additional care note added for the subject with NHS Number: {nhs_no}. "
@@ -141,7 +131,7 @@ def test_add_an_additional_care_note_for_a_subject_without_a_note(
141131
@pytest.mark.regression
142132
@pytest.mark.note_tests
143133
def test_add_additional_care_note_for_subject_with_existing_note(
144-
page: Page, general_properties: dict, login_as
134+
page: Page, general_properties: dict
145135
) -> None:
146136
"""
147137
Test to add an additional care note for a subject who already has an existing note.
@@ -150,7 +140,8 @@ def test_add_additional_care_note_for_subject_with_existing_note(
150140
logging.info(
151141
"Starting test: Add an additional care note for a subject who already has additional care note."
152142
)
153-
login_as("Team Leader at BCS01")
143+
UserTools.user_login(page, "Team Leader at BCS01")
144+
BasePage(page).go_to_screening_subject_search_page()
154145

155146
# Get a subject with existing additional care notes
156147
subjects_df = get_subjects_by_note_count(
@@ -159,7 +150,7 @@ def test_add_additional_care_note_for_subject_with_existing_note(
159150
1,
160151
)
161152
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
162-
search_subject_by_nhs(page, nhs_no)
153+
search_subject_episode_by_nhs_number(page, nhs_no)
163154
# Navigate to Subject Events & Notes
164155
logging.info("Navigating to 'Subject Events & Notes' for the selected subject.")
165156
SubjectScreeningSummaryPage(page).click_subjects_events_notes()
@@ -188,9 +179,7 @@ def test_add_additional_care_note_for_subject_with_existing_note(
188179
subjects_df, nhs_no, general_properties["note_status_active"]
189180
)
190181

191-
verify_note_content_matches_expected(
192-
notes_df, note_title, note_text, type_id
193-
)
182+
verify_note_content_matches_expected(notes_df, note_title, note_text, type_id)
194183

195184
logging.info(
196185
f"Verification successful: Additional care note added for the subject with NHS Number: {nhs_no}. "
@@ -201,13 +190,14 @@ def test_add_additional_care_note_for_subject_with_existing_note(
201190
@pytest.mark.regression
202191
@pytest.mark.note_tests
203192
def test_identify_subject_with_additional_care_note(
204-
page: Page, general_properties: dict, login_as
193+
page: Page, general_properties: dict
205194
) -> None:
206195
"""
207196
Test to identify if a subject has an Additional Care note.
208197
"""
209198
logging.info("Starting test: Verify subject has an additional care note.")
210-
login_as("ScreeningAssistant at BCS02")
199+
UserTools.user_login(page, "ScreeningAssistant at BCS02")
200+
BasePage(page).go_to_screening_subject_search_page()
211201

212202
# Search for the subject by NHS Number.")
213203
subjects_df = get_subjects_by_note_count(
@@ -216,9 +206,9 @@ def test_identify_subject_with_additional_care_note(
216206
1,
217207
)
218208
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
219-
search_subject_by_nhs(page, nhs_no)
209+
search_subject_episode_by_nhs_number(page, nhs_no)
220210
# Verify subject has additional care notes present
221-
logging.info("Verified: Aadditional care notes are present for the subject.")
211+
logging.info("Verified: Additional care notes are present for the subject.")
222212
# logging.info("Verifying that additional care notes are present for the subject.")
223213
SubjectScreeningSummaryPage(page).verify_note_link_present(
224214
general_properties["additional_care_note_name"]
@@ -227,23 +217,22 @@ def test_identify_subject_with_additional_care_note(
227217

228218
@pytest.mark.regression
229219
@pytest.mark.note_tests
230-
def test_view_active_additional_care_note(
231-
page: Page, general_properties: dict, login_as
232-
) -> None:
220+
def test_view_active_additional_care_note(page: Page, general_properties: dict) -> None:
233221
"""
234222
Test to verify if an active Additional Care note is visible for a subject.
235223
"""
236224
logging.info("Starting test: Verify subject has an additional care note.")
237-
login_as("ScreeningAssistant at BCS02")
225+
UserTools.user_login(page, "ScreeningAssistant at BCS02")
226+
BasePage(page).go_to_screening_subject_search_page()
238227

239228
# Search for the subject by NHS Number.")
240229
subjects_df = get_subjects_by_note_count(
241230
general_properties["additional_care_note_type_value"], 1
242231
)
243232
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
244-
search_subject_by_nhs(page, nhs_no)
233+
search_subject_episode_by_nhs_number(page, nhs_no)
245234
# Verify subject has additional care notes present
246-
logging.info("Verified: Aadditional care notes are present for the subject.")
235+
logging.info("Verified: Additional care notes are present for the subject.")
247236
# logging.info("Verifying that additional care notes are present for the subject.")
248237
logging.info(
249238
f"Verifying that the Additional Care Note is visible for the subject with NHS Number: {nhs_no}."
@@ -269,21 +258,22 @@ def test_view_active_additional_care_note(
269258
@pytest.mark.regression
270259
@pytest.mark.note_tests
271260
def test_update_existing_additional_care_note(
272-
page: Page, general_properties: dict, login_as
261+
page: Page, general_properties: dict
273262
) -> None:
274263
"""
275264
Test to verify if an existing Additional Care note can be updated successfully.
276265
"""
277266
logging.info("Starting test: Verify subject has an additional care note.")
278-
login_as("Team Leader at BCS01")
267+
UserTools.user_login(page, "Team Leader at BCS01")
268+
BasePage(page).go_to_screening_subject_search_page()
279269
# Search for the subject by NHS Number.")
280270
subjects_df = get_subjects_by_note_count(
281271
general_properties["additional_care_note_type_value"],
282272
general_properties["note_status_active"],
283273
1,
284274
)
285275
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
286-
search_subject_by_nhs(page, nhs_no)
276+
search_subject_episode_by_nhs_number(page, nhs_no)
287277
# Verify subject has additional care notes present
288278
logging.info(
289279
f"Verifying that the Additional Care Note is visible for the subject with NHS Number: {nhs_no}."
@@ -324,9 +314,7 @@ def test_update_existing_additional_care_note(
324314
)
325315

326316
# Verify title and note match the provided values
327-
verify_note_content_matches_expected(
328-
notes_df, note_title, note_text, type_id
329-
)
317+
verify_note_content_matches_expected(notes_df, note_title, note_text, type_id)
330318

331319
logging.info(
332320
f"Verification successful: Additional care note added for the subject with NHS Number: {nhs_no}. "
@@ -337,15 +325,16 @@ def test_update_existing_additional_care_note(
337325
@pytest.mark.regression
338326
@pytest.mark.note_tests
339327
def test_remove_existing_additional_care_note(
340-
page: Page, general_properties: dict, login_as
328+
page: Page, general_properties: dict
341329
) -> None:
342330
"""
343331
Test to verify if an existing Additional Care note can be removed for a subject with one Additional Care note.
344332
"""
345333
logging.info(
346334
"Starting test: Verify if an existing Additional Care note can be removed for a subject with one Additional Care note"
347335
)
348-
login_as("Team Leader at BCS01")
336+
UserTools.user_login(page, "Team Leader at BCS01")
337+
BasePage(page).go_to_screening_subject_search_page()
349338

350339
# Search for the subject by NHS Number.")
351340
subjects_df = get_subjects_by_note_count(
@@ -354,7 +343,7 @@ def test_remove_existing_additional_care_note(
354343
1,
355344
)
356345
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
357-
search_subject_by_nhs(page, nhs_no)
346+
search_subject_episode_by_nhs_number(page, nhs_no)
358347
# Verify subject has additional care notes present
359348
logging.info(
360349
f"Verifying that the Additional Care Note is visible for the subject with NHS Number: {nhs_no}."
@@ -373,7 +362,7 @@ def test_remove_existing_additional_care_note(
373362
)
374363
logging.info("Verifying that the subject does not have any Additional Care Notes.")
375364

376-
_,_, notes_df = fetch_supporting_notes_from_db(
365+
_, _, notes_df = fetch_supporting_notes_from_db(
377366
subjects_df, nhs_no, general_properties["note_status_active"]
378367
)
379368
# Verify that the DataFrame is not empty
@@ -390,7 +379,7 @@ def test_remove_existing_additional_care_note(
390379
@pytest.mark.regression
391380
@pytest.mark.note_tests
392381
def test_remove_existing_additional_care_note_for_subject_with_multiple_notes(
393-
page: Page, general_properties: dict, login_as
382+
page: Page, general_properties: dict
394383
) -> None:
395384
"""
396385
Test to verify if an existing Additional Care note can be removed for a subject with multiple Additional Care notes.
@@ -399,7 +388,8 @@ def test_remove_existing_additional_care_note_for_subject_with_multiple_notes(
399388
logging.info(
400389
"Starting test: Remove an additional care note for a subject who already has multiple additional care note."
401390
)
402-
login_as("Team Leader at BCS01")
391+
UserTools.user_login(page, "Team Leader at BCS01")
392+
BasePage(page).go_to_screening_subject_search_page()
403393

404394
# Get a subject with multiple additional care notes
405395
subjects_df = get_subjects_with_multiple_notes(
@@ -410,7 +400,7 @@ def test_remove_existing_additional_care_note_for_subject_with_multiple_notes(
410400
pytest.fail("No subjects found with multiple Additional Care Notes.")
411401
nhs_no = subjects_df["subject_nhs_number"].iloc[0]
412402
logging.info(f"Searching for subject with NHS Number: {nhs_no}")
413-
search_subject_by_nhs(page, nhs_no)
403+
search_subject_episode_by_nhs_number(page, nhs_no)
414404
# Navigate to Subject Events & Notes
415405
logging.info("Navigating to 'Subject Events & Notes' for the selected subject.")
416406
SubjectScreeningSummaryPage(page).click_subjects_events_notes()

0 commit comments

Comments
 (0)