Skip to content

Commit

Permalink
Merge pull request #354 from dimagi/QA-6761-script-enhancement-implem…
Browse files Browse the repository at this point in the history
…ent-bha-user-login-changes-to-the-testsuite

QA-6761 BHA scripts updated with latest changes
  • Loading branch information
kbo001 committed Jul 10, 2024
2 parents 328b1ef + 5d3a717 commit f17602b
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/bha-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ jobs:
DIMAGIQA_USH_USER_PROD_AUTH_KEY: ${{ secrets.DIMAGIQA_PROD_AUTH_KEY }}
DIMAGIQA_MAIL_USERNAME: ${{ secrets.DIMAGIQA_MAIL_USERNAME }}
DIMAGIQA_MAIL_PASSWORD: ${{ secrets.DIMAGIQA_MAIL_PASSWORD }}
DIMAGIQA_LOGIN_USERNAME: ${{ secrets.DIMAGIQA_LOGIN_USERNAME }}
DIMAGIQA_LOGIN_PASSWORD: ${{ secrets.DIMAGIQA_LOGIN_PASSWORD }}
run: |
echo "client_payload: ${{ toJson(github.event.client_payload) }}"
echo "matrix environment: ${{ matrix.environment }}"
Expand Down
21 changes: 14 additions & 7 deletions Features/CaseSearch/test_pages/casesearch_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,20 @@ def search_against_property(self, search_property, input_value, property_type, i
print("Providing value: ", input_value)
if property_type == TEXT_INPUT:
self.search_property = self.get_element(self.search_against_text_property_format, search_property)
class_type = self.get_attribute(self.search_property, "class")
self.wait_to_click(self.search_property)
time.sleep(4)
if self.is_visible_and_displayed(self.date_picker_clear, 10):
self.js_click(self.date_picker_clear)
time.sleep(4)
self.send_keys(self.search_property, input_value+Keys.TAB)
time.sleep(5)
if self.is_visible_and_displayed(self.date_picker_close, 10):
self.js_click(self.date_picker_close)
print("class type ", class_type)
if "date" in class_type:
if self.is_visible_and_displayed(self.date_picker_clear, 10):
self.js_click(self.date_picker_clear)
time.sleep(4)
self.send_keys(self.search_property, input_value+Keys.TAB)
time.sleep(5)
if self.is_visible_and_displayed(self.date_picker_close, 10):
self.js_click(self.date_picker_close)
else:
self.send_keys(self.search_property, input_value + Keys.TAB)
self.wait_for_ajax()
elif property_type == COMBOBOX:
self.combox_select_element = self.get_element(self.combox_select, search_property)
Expand Down Expand Up @@ -279,6 +284,8 @@ def check_if_checkbox_selected(self, search_property, values):
def select_checkbox(self, search_property, values, select_by_value):
if select_by_value == text:
checkbox_xpath = (By.XPATH, self.checkbox_xpath.format(search_property, values))
self.wait_for_element(checkbox_xpath)
self.scroll_to_element(checkbox_xpath)
self.js_click(checkbox_xpath)
elif select_by_value == index:
for value in values:
Expand Down
11 changes: 6 additions & 5 deletions USH_Apps/CO_BHA/settings-sample.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[default]
url = https://staging.commcarehq.org/a/bha-auto-tests/cloudcare/apps/v2/#apps
bha_login_username =
bha_login_password =
ush_user_prod_auth_key =
url = https://staging.commcarehq.org/a/co-carecoordination-test/cloudcare/apps/v2/#apps
bha_username =
bha_password =
db =
ush_user_prod_auth_key =
login_username =
login_password =
db = https://staging.commcarehq.org/a/co-carecoordination-test/dashboard
7 changes: 5 additions & 2 deletions USH_Apps/CO_BHA/test_cases/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def environment_settings_bha():
for instructions on how to set them.
"""
settings = {}
for name in ["url", "bha_username", "bha_password", "ush_user_prod_auth_key", "db"]:

for name in ["url", "bha_username", "bha_password", "ush_user_prod_auth_key", "login_username", "login_password", "db"]:

var = f"DIMAGIQA_{name.upper()}"
if var in os.environ:
Expand All @@ -96,7 +97,9 @@ def settings(environment_settings_bha):
if os.environ.get("CI") == "true":
settings = environment_settings_bha
settings["CI"] = "true"
if any(x not in settings for x in ["url", "bha_username", "bha_password", "ush_user_prod_auth_key", "db"]):

if any(x not in settings for x in ["url", "bha_username", "bha_password", "ush_user_prod_auth_key", "login_username", "login_password", "db"]):

lines = environment_settings_bha.__doc__.splitlines()
vars_ = "\n ".join(line.strip() for line in lines if "DIMAGIQA_" in line)
raise RuntimeError(
Expand Down
7 changes: 4 additions & 3 deletions USH_Apps/CO_BHA/test_cases/test_01_admit_client_and_locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_case_03_lock_in_1_1(driver, settings):
casesearch = CaseSearchWorkflows(driver)
app = BhaWorkflows(driver)

webapps.bha_login_as(BhaUserInput.user_31, settings['bha_login_password'], settings['url'], settings['db'])
webapps.bha_login_as(BhaUserInput.user_31, settings['bha_password'], settings['url'], settings['db'])
webapps.open_app(BhaUserInput.bha_app_name)
webapps.open_menu(BhaUserInput.search_my_clients)
casesearch.search_against_property(search_property=BhaUserInput.first_name,
Expand Down Expand Up @@ -163,13 +163,13 @@ def test_case_04_lock_in_1_2(driver, settings):
casesearch.check_values_on_caselist(row_num=BhaUserInput.five,
expected_value=BhaUserInput.pending_status)

@pytest.mark.skip
def test_case_05_admit_case_7(driver, settings):
"""use case: match on inactive client"""
webapps = WebApps(driver, settings)
casesearch = CaseSearchWorkflows(driver)
app = BhaWorkflows(driver)

webapps.bha_login_as(BhaUserInput.clinic_level_user, settings['bha_password'], settings['url'], settings['db'])
webapps.open_app(BhaUserInput.bha_app_name)
webapps.open_menu(BhaUserInput.search_and_admit_client)
domain_url = driver.current_url
Expand Down Expand Up @@ -197,9 +197,10 @@ def test_case_05_admit_case_7(driver, settings):
input_value=BhaUserInput.refused_to_provide,
property_type=COMBOBOX)
casesearch.select_checkbox(BhaUserInput.consent, BhaUserInput.yes_small, select_by_value=text)
webapps.search_button_on_case_search_page()
webapps.search_button_on_case_search_page(case_list='yes')
webapps.submit_the_form()
"""Case List Report Check"""
webapps.bha_login_as(settings['login_username'], settings['login_password'], settings['url'], settings['db'])
if "staging" in domain_url:
app.check_property_on_case_list_report(case_link=BhaUserInput.staging_case_link,
case_property=BhaUserInput.potential_duplicate,
Expand Down
10 changes: 6 additions & 4 deletions USH_Apps/CO_BHA/test_pages/bha_app_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ def replace_one_char(self, original_string):
def select_radio(self, value):
time.sleep(4)
radio_value = self.get_element(self.radio_option_value, value)
self.wait_for_element(radio_value)
self.scroll_to_element(radio_value)
self.js_click(radio_value)
time.sleep(4)
if self.is_present_and_displayed(radio_value, 10):
self.scroll_to_element(radio_value)
self.js_click(radio_value)
time.sleep(4)
else:
print("Yes button is not present")

def check_search_properties_present(self, properties):
properties_labels = self.find_elements_texts(self.case_search_properties)
Expand Down
18 changes: 10 additions & 8 deletions USH_Apps/CO_BHA/user_inputs/bha_user_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class BhaUserInput:
prod_inactive_first_name = "PROD CLIENT1 FIRST NAME"
prod_inactive_last_name_with_typo = "PROD CLIENT1 LAST NAAA"
prod_inactive_dob = "01/01/2010"
all_status = "All"

yes = "Yes"
yes_small = "yes"
approve = "Approve"
Expand All @@ -102,20 +104,20 @@ class BhaUserInput:
no_potential_match_found = "No potential client matches. Proceed to admit new client."

# CLR staging
staging_case_link = "https://staging.commcarehq.org/a/bha-auto-tests/reports/case_data/604a9a80-a83c-4081-97d2-8dc74990ff0b/#properties"
staging_case_link = "https://staging.commcarehq.org/a/co-carecoordination-test/reports/case_data/b4d15f46-8f55-4630-ba33-6dcf267c22b0/"
potential_duplicate = "potential_duplicate_case_ids"
staging_potential_duplicate_case_id = "8d0dfeaf-c9d4-41fd-801b-18e44bfb6b4a"
staging_potential_duplicate_case_id = "b46e5cb0-0add-4ff9-8c8f-38c53df63847"

staging_duplicate_case_link = "https://staging.commcarehq.org/a/bha-auto-tests/reports/case_data/8d0dfeaf-c9d4-41fd-801b-18e44bfb6b4a/#properties"
staging_duplicate_case_link = "https://staging.commcarehq.org/a/co-carecoordination-test/reports/case_data/b46e5cb0-0add-4ff9-8c8f-38c53df63847/"
potential_duplicate_index = "potential_duplicate_index_case_ids"
staging_potential_duplicate_index_case_id = "604a9a80-a83c-4081-97d2-8dc74990ff0b"
staging_potential_duplicate_index_case_id = "b4d15f46-8f55-4630-ba33-6dcf267c22b0"

# CLR prod
prod_case_link = "https://www.commcarehq.org/a/bha-auto-tests/reports/case_data/a339335b-76cd-4763-82fc-8162d21e30d2/#properties"
prod_potential_duplicate_case_id = "7faed59b-2f09-40e2-8b59-f4acee0e5c39"
prod_case_link = "https://www.commcarehq.org/a/co-carecoordination-test/reports/case_data/93fddbd7-7376-4e18-a7dd-59338c89524d/"
prod_potential_duplicate_case_id = "71265f9a41e14841ae3fe4f2c6af338f"

prod_duplicate_case_link = "https://www.commcarehq.org/a/bha-auto-tests/reports/case_data/7faed59b-2f09-40e2-8b59-f4acee0e5c39/#properties"
prod_potential_duplicate_index_case_id = "a339335b-76cd-4763-82fc-8162d21e30d2"
prod_duplicate_case_link = "https://www.commcarehq.org/a/co-carecoordination-test/reports/case_data/71265f9a41e14841ae3fe4f2c6af338f/"
prod_potential_duplicate_index_case_id = "93fddbd7-7376-4e18-a7dd-59338c89524d"

# Messaging History
clinic_admission_request = "Clinic Admission Request"
Expand Down
11 changes: 7 additions & 4 deletions common_utilities/selenium/webapps.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def clear_selections_on_case_search_page(self):
self.wait_for_ajax()
time.sleep(5)

def search_button_on_case_search_page(self, enter_key=None):
def search_button_on_case_search_page(self, enter_key=None, case_list=None):
if enter_key == YES:
time.sleep(2)
ActionChains(self.driver).send_keys(Keys.ENTER).perform()
Expand All @@ -136,8 +136,11 @@ def search_button_on_case_search_page(self, enter_key=None):
self.scroll_to_element(self.submit_on_case_search_page)
self.js_click(self.submit_on_case_search_page)
time.sleep(10)
self.wait_for_ajax()
self.is_visible_and_displayed(self.case_list, timeout=500)
self.wait_for_ajax(60)
if case_list == None:
self.is_visible_and_displayed(self.case_list, timeout=500)
else:
print("Case List is not displayed")

def clear_and_search_all_cases_on_case_search_page(self):
self.clear_selections_on_case_search_page()
Expand Down Expand Up @@ -196,9 +199,9 @@ def select_case_and_continue(self, case_name):
return form_names

def submit_the_form(self):
time.sleep(3)
self.wait_for_element(self.form_submit)
self.js_click(self.form_submit)
self.wait_for_ajax(100)
time.sleep(5)
try:
assert self.is_visible_and_displayed(self.form_submission_successful, timeout=500)
Expand Down

0 comments on commit f17602b

Please sign in to comment.