Skip to content

Commit 4105a45

Browse files
Changes to compartment 5 and the calendar picker util
1 parent 8acd515 commit 4105a45

File tree

7 files changed

+56
-40
lines changed

7 files changed

+56
-40
lines changed

pages/communication_production/batch_list_page.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def __init__(self, page: Page):
2626
self.deadline_date_filter = self.page.get_by_role("cell", name="").get_by_role(
2727
"textbox"
2828
)
29+
self.deadline_date_filter_with_input = self.page.locator(
30+
"input.form-control.filter.filtering"
31+
)
2932
self.deadline_date_clear_button = self.page.get_by_role("cell", name="Clear")
3033

3134
def verify_batch_list_page_title(self, text) -> None:
@@ -74,6 +77,9 @@ def clear_deadline_filter_date(self) -> None:
7477
self.click(self.deadline_calendar_picker)
7578
self.click(self.deadline_date_clear_button)
7679

80+
def verify_deadline_date_filter_input(self, expected_text: str) -> None:
81+
expect(self.deadline_date_filter_with_input).to_have_value(expected_text)
82+
7783

7884
class ActiveBatchList(BatchList):
7985
def __init__(self, page):

pages/screening_subject_search/subject_screening_search_page.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from playwright.sync_api import Page
1+
from playwright.sync_api import Page, expect
22
from pages.base_page import BasePage
33
from enum import Enum
44
from utils.calendar_picker import CalendarPicker
@@ -123,6 +123,9 @@ def select_dob_using_calendar_picker(self, date) -> None:
123123
self.click(self.dob_calendar_picker)
124124
CalendarPicker(self.page).v1_calender_picker(date)
125125

126+
def verify_date_of_birth_filter_input(self, expected_text: str) -> None:
127+
expect(self.date_of_birth_filter).to_have_value(expected_text)
128+
126129

127130
class ScreeningStatusSearchOptions(Enum):
128131
CALL_STATUS = "4001"

tests/smokescreen/bcss_smokescreen_tests.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@
8585
# ----------------------------------
8686
# compartment 5
8787
# ----------------------------------
88-
c5_eng_number_of_screening_appts_to_attend=2
88+
c5_eng_number_of_screening_appts_to_attend=5
8989

9090
# ----------------------------------
9191
# compartment 6
9292
# ----------------------------------
93-
# c6_eng_number_of_normal_results_to_record=2
93+
# c6_eng_number_of_normal_results_to_record=1
9494
# c6_eng_number_of_lnpcp_results_to_record=1
9595
# c6_eng_number_of_high_risk_findings_results_to_record=1
9696
# c6_eng_number_of_lnpcp_results_over_74_to_record=1

tests/test_calendar_picker_methods.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,56 @@
1010
from pages.base_page import BasePage
1111
from utils.user_tools import UserTools
1212
from datetime import datetime
13+
from sys import platform
1314

1415

1516
@pytest.mark.smoke
1617
def test_calender_picker_v1(page: Page) -> None:
1718
"""
1819
This test is used to verify that the v1 calendar picker in utils/calendar_picker.py works as intended
1920
This uses the subject screening search page in order to do so
20-
NOTE: currently there is no validation that it has selected the correct date.
21-
This should be implemented after each date is selected however the locators on BCSS make this task difficult
2221
"""
2322
UserTools.user_login(page, "Hub Manager State Registered at BCS01")
2423
BasePage(page).go_to_screening_subject_search_page()
2524
SubjectScreeningPage(page).select_dob_using_calendar_picker(datetime(2021, 12, 1))
25+
SubjectScreeningPage(page).verify_date_of_birth_filter_input("01/12/2021")
2626
SubjectScreeningPage(page).click_clear_filters_button()
2727
SubjectScreeningPage(page).select_dob_using_calendar_picker(datetime(2020, 3, 30))
28+
SubjectScreeningPage(page).verify_date_of_birth_filter_input("30/03/2020")
2829
SubjectScreeningPage(page).click_clear_filters_button()
2930
SubjectScreeningPage(page).select_dob_using_calendar_picker(datetime(2020, 6, 15))
31+
SubjectScreeningPage(page).verify_date_of_birth_filter_input("15/06/2020")
3032
SubjectScreeningPage(page).click_clear_filters_button()
3133
SubjectScreeningPage(page).select_dob_using_calendar_picker(datetime.today())
34+
SubjectScreeningPage(page).verify_date_of_birth_filter_input(
35+
str(datetime.today().strftime("%d/%m/%Y"))
36+
)
3237

3338

3439
@pytest.mark.smoke
3540
def test_calender_picker_v2(page: Page) -> None:
3641
"""
3742
This test is used to verify that the v2 calendar picker in utils/calendar_picker.py works as intended
3843
This uses the active batch list page in order to do so
39-
NOTE: currently there is no validation that it has selected the correct date.
40-
This should be implemented after each date is selected however the locators on BCSS make this task difficult
4144
"""
4245
UserTools.user_login(page, "Hub Manager State Registered at BCS01")
4346
BasePage(page).go_to_communications_production_page()
4447
CommunicationsProduction(page).go_to_active_batch_list_page()
4548
ActiveBatchList(page).enter_deadline_date_filter(datetime(1961, 12, 30))
49+
ActiveBatchList(page).verify_deadline_date_filter_input("30 Nov 1961")
4650
ActiveBatchList(page).clear_deadline_filter_date()
4751
ActiveBatchList(page).enter_deadline_date_filter(datetime(2026, 12, 1))
52+
ActiveBatchList(page).verify_deadline_date_filter_input("1 Dec 2026")
4853
ActiveBatchList(page).clear_deadline_filter_date()
4954
ActiveBatchList(page).enter_deadline_date_filter(datetime(1989, 6, 15))
55+
ActiveBatchList(page).verify_deadline_date_filter_input("15 Jun 1989")
5056
ActiveBatchList(page).clear_deadline_filter_date()
5157
ActiveBatchList(page).enter_deadline_date_filter(datetime.today())
58+
if platform == "win32": # Windows
59+
ActiveBatchList(page).verify_deadline_date_filter_input(
60+
str(datetime.today().strftime("%#d %b %Y"))
61+
)
62+
else: # Linux or Mac
63+
ActiveBatchList(page).verify_deadline_date_filter_input(
64+
str(datetime.today().strftime("%-d %b %Y"))
65+
)

tests_utils/test_calendar_picker_util.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ def test_calculate_v2_calendar_variables(page: Page):
1414
month_short,
1515
current_year,
1616
year,
17-
end_of_current_decade,
1817
current_decade,
1918
decade,
20-
end_of_current_century,
2119
current_century,
2220
century,
2321
) = calendar_picker.calculate_v2_calendar_variables(
@@ -29,10 +27,8 @@ def test_calculate_v2_calendar_variables(page: Page):
2927
assert month_short == "Apr"
3028
assert current_year == 2020
3129
assert year == 2025
32-
assert end_of_current_decade == "2029"
3330
assert current_decade == 2020
3431
assert decade == 2020
35-
assert end_of_current_century == "2090"
3632
assert current_century == 2000
3733
assert century == 2000
3834

utils/calendar_picker.py

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from playwright.sync_api import Page, Locator
44
from pages.base_page import BasePage
55
from sys import platform
6-
import logging
76
import pytest
87

98

@@ -16,6 +15,13 @@ def __init__(self, page: Page):
1615
self.v1_prev_month = self.page.get_by_role("cell", name="‹").locator("div")
1716
self.v1_next_month = self.page.get_by_role("cell", name="›").locator("div")
1817
self.v1_next_year = self.page.get_by_role("cell", name="»").locator("div")
18+
self.v1_calendar_current_date = self.page.locator(
19+
'td.title[colspan="5"][style="cursor: move;"]'
20+
)
21+
# V2 Calendar picker locators
22+
self.v2date_picker_switch = self.page.locator(
23+
'th.datepicker-switch[colspan="5"]:visible'
24+
)
1925
# Book Appointment picker locators
2026
self.appointments_prev_month = self.page.get_by_role(
2127
"link", name="<-", exact=True
@@ -98,23 +104,32 @@ def select_day(self, date: datetime) -> None:
98104
"cell", name=day_to_select
99105
).count()
100106

107+
all_days = self.page.locator(".day").all()
108+
109+
matching_days = [
110+
day
111+
for day in all_days
112+
if day.evaluate("el => el.textContent.trim()") == day_to_select
113+
]
114+
101115
if int(day_to_select) < 15 and number_of_cells_with_day > 1:
102-
self.click(self.page.locator(".day", has_text=day_to_select).first)
116+
self.click(matching_days[0].first)
103117
elif int(day_to_select) > 15 and number_of_cells_with_day > 1:
104-
self.click(self.page.locator(".day", has_text=day_to_select).last)
118+
self.click(matching_days[0].last)
105119
else:
106-
self.click(self.page.locator(".day", has_text=day_to_select))
120+
self.click(matching_days[0])
107121

108122
def v1_calender_picker(self, date: datetime) -> None:
109123
"""
110124
This is the main method used to traverse the v1 calendar picker (e.g. the one on the subject screening search page)
111125
You provide it with a date and it will call the necessary functions to calculate how to navigate to the specified date
112126
"""
113-
current_date = datetime.today()
127+
current_date = datetime.strptime(
128+
self.v1_calendar_current_date.inner_text(), "%B, %Y"
129+
)
114130
years_to_traverse, months_to_traverse = (
115131
self.calculate_years_and_months_to_traverse(date, current_date)
116132
)
117-
118133
self.traverse_years_in_v1_calendar(years_to_traverse)
119134

120135
self.traverse_months_in_v1_calendar(months_to_traverse)
@@ -132,21 +147,17 @@ def calculate_v2_calendar_variables(
132147
month_short: the wanted month is short format (e.g. Jun)
133148
current_year: the current year in yyyy format (e.g. 2025)
134149
year: the wanted year in yyyy format (e.g. 1983)
135-
end_of_current_decade: the end of the current decade in yyyy format (e.g. 2029)
136150
current_decade: the current decade in yyyy format (e.g. 2020)
137151
decade: the wanted decade in yyyy format (e.g. 1980)
138-
end_of_current_century: 10 years before the end of the current century in yyyy format (e.g. 2090)
139152
current_century: the current century in yyyy format (e.g. 2000/2100)
140153
century: the wanted century in yyyy format (e.g. 1900)
141154
"""
142155
current_month_long = str(current_date.strftime("%B"))
143156
current_year = int(current_date.strftime("%Y"))
144157
current_century = (current_year // 100) * 100
145-
end_of_current_century = str(current_century + 90)
146158
current_decade = (
147159
((current_year - current_century) // 10) * 10
148160
) + current_century
149-
end_of_current_decade = str(current_decade + 9)
150161

151162
year = int(date.strftime("%Y"))
152163
century = (year // 100) * 100
@@ -160,10 +171,8 @@ def calculate_v2_calendar_variables(
160171
month_short,
161172
current_year,
162173
year,
163-
end_of_current_decade,
164174
current_decade,
165175
decade,
166-
end_of_current_century,
167176
current_century,
168177
century,
169178
)
@@ -174,10 +183,8 @@ def v2_calendar_picker_traverse_back(
174183
month_long: str,
175184
current_year: int,
176185
year: int,
177-
end_of_current_decade: str,
178186
current_decade: int,
179187
decade: int,
180-
end_of_current_century: str,
181188
current_century: int,
182189
century: int,
183190
) -> tuple[bool, bool, bool, bool]:
@@ -193,22 +200,16 @@ def v2_calendar_picker_traverse_back(
193200
click_century = False
194201

195202
if current_month_long != month_long:
196-
self.click(self.page.get_by_role("cell", name=current_month_long))
203+
self.click(self.v2date_picker_switch)
197204
click_month = True
198205
if current_year != year:
199-
self.click(
200-
self.page.get_by_role("cell", name=str(current_year), exact=True)
201-
)
206+
self.click(self.v2date_picker_switch)
202207
click_year = True
203208
if current_decade != decade:
204-
self.click(
205-
self.page.get_by_role("cell", name=("-" + str(end_of_current_decade)))
206-
)
209+
self.click(self.v2date_picker_switch)
207210
click_decade = True
208211
if current_century != century:
209-
self.click(
210-
self.page.get_by_role("cell", name=("-" + str(end_of_current_century)))
211-
)
212+
self.click(self.v2date_picker_switch)
212213
click_century = True
213214

214215
return click_month, click_year, click_decade, click_century
@@ -250,10 +251,8 @@ def v2_calendar_picker(self, date: datetime) -> None:
250251
month_short,
251252
current_year,
252253
year,
253-
end_of_current_decade,
254254
current_decade,
255255
decade,
256-
end_of_current_century,
257256
current_century,
258257
century,
259258
) = self.calculate_v2_calendar_variables(date, current_date)
@@ -264,10 +263,8 @@ def v2_calendar_picker(self, date: datetime) -> None:
264263
month_long,
265264
current_year,
266265
year,
267-
end_of_current_decade,
268266
current_decade,
269267
decade,
270-
end_of_current_century,
271268
current_century,
272269
century,
273270
)

utils/oracle/oracle_specific_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def get_subjects_with_booked_appointments(subjects_to_retrieve: int) -> pd.DataF
289289
and a.cancel_dna_reason_id is null
290290
and a.appointment_date <= sysdate
291291
and tk.tk_type_id = 2
292-
and tk.datestamp > add_months(sysdate,-24)
292+
--and tk.datestamp > add_months(sysdate,-24)
293293
order by a.appointment_date desc
294294
fetch first {subjects_to_retrieve} rows only
295295
"""

0 commit comments

Comments
 (0)