Skip to content

Commit fb0904c

Browse files
authored
BB2-2379 Update Selenium tests for new perm screens (#1130)
* Update remote type tests for new perm screens * Update for cases for new perm screen * Update to force migrations true
1 parent 62f3b3f commit fb0904c

File tree

5 files changed

+62
-19
lines changed

5 files changed

+62
-19
lines changed

apps/integration_tests/selenium_cases.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
HOSTNAME_URL = os.environ['HOSTNAME_URL']
7+
USE_NEW_PERM_SCREEN = os.environ['USE_NEW_PERM_SCREEN']
78
PROD_URL = 'https://api.bluebutton.cms.gov'
89
USER_ACTIVATION_PATH_FMT = "{}/v1/accounts/activation-verify/{}"
910

@@ -126,7 +127,13 @@ class Action(Enum):
126127
# Demographic info access grant form
127128
BTN_ID_GRANT_DEMO_ACCESS = "approve"
128129
BTN_ID_DENY_DEMO_ACCESS = "deny"
129-
BTN_ID_RADIO_NOT_SHARE = "label:nth-child(5)"
130+
if USE_NEW_PERM_SCREEN == "true":
131+
# Below works for new auth screen
132+
BTN_ID_RADIO_NOT_SHARE = "radio_1"
133+
else:
134+
# Below works for old auth screen
135+
BTN_ID_RADIO_NOT_SHARE = "label:nth-child(5)"
136+
130137

131138
# API versions
132139
API_V2 = "v2"
@@ -170,9 +177,17 @@ class Action(Enum):
170177
CLICK_RADIO_NOT_SHARE = {
171178
"display": "Click 'Share healthcare data, but not your personal info' on DEMO info grant form",
172179
"action": Action.FIND_CLICK,
180+
# Below works for old auth screen
173181
"params": [20, By.CSS_SELECTOR, BTN_ID_RADIO_NOT_SHARE]
174182
}
175183

184+
CLICK_RADIO_NOT_SHARE_NEW_PERM_SCREEN = {
185+
"display": "Click 'Share healthcare data, but not your personal info' on DEMO info grant form (NEW PERM SCREEN)",
186+
"action": Action.FIND_CLICK,
187+
# Below works for new auth screen
188+
"params": [20, By.ID, BTN_ID_RADIO_NOT_SHARE]
189+
}
190+
176191
CLICK_AGREE_ACCESS = {
177192
"display": "Click 'Agree' on DEMO info grant form",
178193
"action": Action.FIND_CLICK,
@@ -475,6 +490,13 @@ class Action(Enum):
475490
CLICK_RADIO_NOT_SHARE,
476491
CLICK_AGREE_ACCESS,
477492
{"sequence": SEQ_QUERY_FHIR_RESOURCES_NO_DEMO}
493+
],
494+
"auth_grant_w_no_demo_new_perm_screen": [
495+
{"sequence": SEQ_AUTHORIZE_START},
496+
CALL_LOGIN,
497+
CLICK_RADIO_NOT_SHARE_NEW_PERM_SCREEN,
498+
CLICK_AGREE_ACCESS,
499+
{"sequence": SEQ_QUERY_FHIR_RESOURCES_NO_DEMO}
478500
]
479501
}
480502

apps/integration_tests/selenium_tests.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
import os
22
from .selenium_generic import SeleniumGenericTests
33
from .selenium_cases import (
44
API_V2,
@@ -7,6 +7,9 @@
77
)
88

99

10+
USE_NEW_PERM_SCREEN = os.environ['USE_NEW_PERM_SCREEN']
11+
12+
1013
class TestBlueButtonAPI(SeleniumGenericTests):
1114
'''
1215
Test authorization and fhir flow through the built in testclient by
@@ -66,16 +69,23 @@ def test_auth_deny_fhir_calls_v2(self):
6669

6770
def test_auth_grant_w_no_demo_v1(self):
6871
step = [0]
69-
test_name = "auth_grant_w_no_demo"
72+
if USE_NEW_PERM_SCREEN == "true":
73+
test_name = "auth_grant_w_no_demo_new_perm_screen"
74+
else:
75+
test_name = "auth_grant_w_no_demo"
7076
api_ver = API_V1
77+
self._print_testcase_banner(self.driver.current_url, api_ver, step[0], self.use_mslsx, True)
7178
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
7279
self._play(TESTS[test_name], step, api_ver=api_ver)
7380
self._testclient_home()
7481
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, False)
7582

7683
def test_auth_grant_w_no_demo_v2(self):
7784
step = [0]
78-
test_name = "auth_grant_w_no_demo"
85+
if USE_NEW_PERM_SCREEN == "true":
86+
test_name = "auth_grant_w_no_demo_new_perm_screen"
87+
else:
88+
test_name = "auth_grant_w_no_demo"
7989
api_ver = API_V2
8090
self._print_testcase_banner(test_name, api_ver, step[0], self.use_mslsx, True)
8191
self._play(TESTS[test_name], step, api_ver=api_ver)

docker-compose.selenium.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ services:
6464
build: .
6565
command: ./docker-compose/bluebutton_server_start.sh
6666
env_file:
67+
# local devel specific variables go here!
68+
- .env
6769
- docker-compose/web-env-vars.env
6870
- docker-compose/slsx-env-vars.env
6971
- docker-compose/selenium-env-vars.env
70-
# local devel specific variables go here!
71-
- .env
7272
volumes:
7373
- .:/code
7474
ports:

docker-compose/run_selenium_tests_remote.sh

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ display_usage() {
2020
echo "Usage:"
2121
echo "------------------"
2222
echo
23-
echo "Syntax: run_selenium_tests_remote.sh [-h|d] [SBX|PROD|TEST|<bb2 server url>]"
23+
echo "Syntax: run_selenium_tests_remote.sh [-h|d|p] [SBX|PROD|TEST|<bb2 server url>]"
2424
echo
2525
echo "Options:"
2626
echo
2727
echo "-h Print this Help."
2828
echo "-d Run tests in selenium debug mode (vnc view web UI interaction at http://localhost:5900)."
29+
echo "-p Test for newer permissions screen. Defaults to older screen."
2930
echo
3031
echo "Examples:"
3132
echo
3233
echo "run_selenium_tests_remote.sh https://sandbox.bluebutton.cms.gov/ (or SBX)"
3334
echo
34-
echo "run_selenium_tests_remote.sh https://api.bluebutton.cms.gov/ (or PROD)"
35+
echo "run_selenium_tests_remote.sh -d https://api.bluebutton.cms.gov/ (or PROD)"
3536
echo
36-
echo "run_selenium_tests_remote.sh https://test.bluebutton.cms.gov/ (or TEST)"
37+
echo "run_selenium_tests_remote.sh -d -p https://test.bluebutton.cms.gov/ (or TEST)"
3738
echo
3839
echo "<bb2 server url> default to SBX (https://sandbox.bluebutton.cms.gov/)"
3940
echo
@@ -49,29 +50,33 @@ echo_msg
4950
set -e -u -o pipefail
5051

5152
export USE_DEBUG=false
53+
export USE_NEW_PERM_SCREEN=false
5254
export SERVICE_NAME="selenium-tests-remote"
5355
export TESTS_LIST="./apps/integration_tests/selenium_tests.py"
5456
# BB2 service end point default (SBX)
5557
export HOSTNAME_URL="https://sandbox.bluebutton.cms.gov/"
56-
export USE_DEBUG=false
5758

58-
while getopts "hd" option; do
59+
60+
while getopts "hdp" option; do
5961
case $option in
6062
h)
6163
display_usage;
6264
exit;;
6365
d)
64-
export USE_DEBUG=true;
65-
shift;break;;
66+
export USE_DEBUG=true;;
67+
p)
68+
export USE_NEW_PERM_SCREEN=true;;
6669
\?)
6770
display_usage;
6871
exit;;
6972
esac
7073
done
7174

72-
if [[ -n ${1-''} ]]
75+
eval last_arg=\$$#
76+
77+
if [[ -n ${last_arg} ]]
7378
then
74-
case "$1" in
79+
case "${last_arg}" in
7580
SBX)
7681
export HOSTNAME_URL="https://sandbox.bluebutton.cms.gov/"
7782
;;
@@ -82,11 +87,11 @@ then
8287
export HOSTNAME_URL="https://test.bluebutton.cms.gov/"
8388
;;
8489
*)
85-
if [[ $1 == 'http*' ]]
90+
if [[ ${last_arg} == 'http*' ]]
8691
then
87-
export HOSTNAME_URL=$1
92+
export HOSTNAME_URL=${last_arg}
8893
else
89-
echo "Invalid argument: " $1
94+
echo "Invalid argument: " ${last_arg}
9095
display_usage
9196
exit 1
9297
fi
@@ -98,9 +103,11 @@ fi
98103
SYSTEM=$(uname -s)
99104

100105
echo "USE_DEBUG=" ${USE_DEBUG}
106+
echo "USE_NEW_PERM_SCREEN=" ${USE_NEW_PERM_SCREEN}
101107
echo "BB2 Server URL=" ${HOSTNAME_URL}
102108

103109
export USE_DEBUG
110+
export USE_NEW_PERM_SCREEN
104111
export USE_MSLSX=false
105112

106113
# stop all before run selenium remote tests

docker-compose/selenium-env-vars.env

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
HOSTNAME_URL=${HOSTNAME_URL}
33
USE_MSLSX=${USE_MSLSX}
44
USE_DEBUG=${USE_DEBUG}
5-
DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE}
5+
USE_NEW_PERM_SCREEN=${USE_NEW_PERM_SCREEN}
6+
DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE}
7+
8+
# Force to true in case false in .env
9+
DB_MIGRATIONS=true

0 commit comments

Comments
 (0)