11import logging
22import pytest
33from playwright .sync_api import Page , expect
4- from pages import login , screening_subject_search
4+ from utils . user_tools import UserTools
55from 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
96from pages .screening_subject_search .subject_screening_search_page import (
107 SubjectScreeningPage ,
118)
1815 SubjectEventsNotes ,
1916 AdditionalCareNoteTypeOptions ,
2017)
21- from utils .user_tools import UserTools
22- from utils .table_util import TableUtils
2318from 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
2923from 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 ,
3831@pytest .mark .regression
3932@pytest .mark .note_tests
4033def 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
7970def 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
143133def 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
203192def 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
271260def 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
339327def 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
392381def 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