Skip to content

Commit

Permalink
Add NME e2e test (stripe#9055)
Browse files Browse the repository at this point in the history
* [skip ci] Start PR

* Adds tests.

* Updates for auto selection.

* Updates for auto selection.

* Excludes non edge tests.

* Remove edge from NME merchant.

* Remove edge from NME merchant.

* Removes tag mutation.

* Updates condition.

* Run the check just if maestro tags includes edge.
  • Loading branch information
carlosmuvi-stripe authored Sep 12, 2024
1 parent 3524348 commit 1109395
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 16 deletions.
13 changes: 13 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ stages:
- run-example-instrumentation-tests: { }
- run-financial-connections-instrumentation-tests: { }
- run-connections-e2e-payments-tests-on-push: { }
- run-connections-e2e-token-tests-on-push: { }
- run-connections-e2e-data-tests-on-push: { }
- run-cardscan-instrumentation-tests: { }
- run-paymentsheet-end-to-end-tests: { }
Expand All @@ -50,6 +51,7 @@ stages:
workflows:
- run-connections-e2e-payments-tests: { }
- run-connections-e2e-data-tests: { }
- run-connections-e2e-token-tests: { }
- run-connections-e2e-livemode-tests: { }
stage-notify-connections-e2e-failure:
should_always_run: true
Expand Down Expand Up @@ -115,6 +117,11 @@ workflows:
- MAESTRO_TAGS: testmode-data
before_run:
- _run-connections-e2e-tests
run-connections-e2e-token-tests:
envs:
- MAESTRO_TAGS: testmode-token
before_run:
- _run-connections-e2e-tests
run-connections-e2e-payments-tests-on-push:
envs:
- MAESTRO_TAGS: testmode-payments
Expand All @@ -127,6 +134,12 @@ workflows:
before_run:
- _build-connections
- _run-connections-e2e-tests
run-connections-e2e-token-tests-on-push:
envs:
- MAESTRO_TAGS: testmode-token
before_run:
- _build-connections
- _run-connections-e2e-tests
run-connections-e2e-livemode-tests:
envs:
- MAESTRO_TAGS: livemode-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ appId: com.stripe.android.financialconnections.example
tags:
- all
- edge
- testmode-data
- testmode-token
---
- startRecording: ${'/tmp/test_results/testmode-token_manualentry-' + new Date().getTime()}
- clearState
Expand Down
68 changes: 68 additions & 0 deletions maestro/financial-connections/Testmode-Token-NME.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
##
## This tests Networks a manually entered account
## and reuses the same account on the bank account token flow.
##
appId: com.stripe.android.financialconnections.example
tags:
- all
- testmode-token
---
- startRecording: ${'/tmp/test_results/testmode-nme-' + new Date().getTime()}
- clearState
- openLink: stripeconnectionsexample://playground?experience=FinancialConnections&flow=Token&financial_connections_override_native=native&merchant=networking&financial_connections_test_mode=true&permissions=payment_method&financial_connections_confirm_intent=true
- tapOn:
id: "Customer email setting"
- inputRandomEmail
- hideKeyboard
- tapOn:
id: "connect_accounts"
# Wait until the consent button is visible
- extendedWaitUntil:
visible:
id: "consent_cta"
timeout: 30000
# Navigate to manual entry
- tapOn:
# Maestro does not yet support tapping on annotated strings.
# https://github.com/mobile-dev-inc/maestro/issues/389
point: "50%,93%"
- tapOn: "Use test account"
## ENTER PHONE FOR NEW NETWORKED USER
- waitForAnimationToEnd
- scrollUntilVisible:
element:
text: ".*555.*" # wait for placeholder to be visible
- inputText: "6223115555"
- tapOn: "Save with Link"
# CONFIRM AND COMPLETE
- tapOn:
id: "done_button"
- assertVisible: ".*Completed!.*"
############################################
## REUSE NEWLY CREATED NME ACCOUNT
############################################
- tapOn:
id: "connect_accounts"
# Common: web AuthFlow - connect OAuth institution
- extendedWaitUntil:
visible:
id: "consent_cta"
timeout: 30000
- tapOn:
id: "consent_cta"
## LOGIN TO NETWORKING
- tapOn:
id: "existing_email-button"
## 2FA
- assertVisible:
id: "OTP-0"
- inputText: "111111"
## SELECT NETWORKED ACCOUNT
# First institution should be auto selected.
- tapOn: "Connect account"
# CONFIRM AND COMPLETE
- tapOn:
id: "done_button"
- scrollUntilVisible:
element:
text: ".*Completed.*"
45 changes: 30 additions & 15 deletions scripts/execute_maestro_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ then
exit 1
fi

export MAESTRO_VERSION=1.36.0
echo "test_environment: $test_environment"
echo "MAESTRO_TAGS: $MAESTRO_TAGS"

export MAESTRO_VERSION=1.38.1

# Retry mechanism for Maestro installation
MAX_RETRIES=5
Expand All @@ -47,6 +50,13 @@ fi
# install APK.
adb install $BITRISE_APK_PATH

# Function to check if a YAML file contains a specific tag
contains_tag() {
local file="$1"
local tag="$2"
awk '/tags:/,/---/' "$file" | grep -q "$tag"
}

TEST_DIR_PATH=maestro/financial-connections
TEST_RESULTS_PATH=/tmp/test_results
RETRY_COUNT=0
Expand All @@ -55,19 +65,24 @@ RETRY_COUNT=0
mkdir -p $TEST_RESULTS_PATH

for TEST_FILE_PATH in "$TEST_DIR_PATH"/*.yaml; do
# Check if tags are present in the test file
if awk '/tags:/,/---/' "$TEST_FILE_PATH" | grep -q "$MAESTRO_TAGS"; then
# Execute Maestro test flow and retries if failed.
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
maestro test -e APP_ID=com.stripe.android.financialconnections.example --format junit --output $TEST_FILE_PATH.xml "$TEST_FILE_PATH" && break
let RETRY_COUNT=RETRY_COUNT+1
echo "Maestro test attempt $RETRY_COUNT failed. Retrying..."
done
if [ "$RETRY_COUNT" -eq "$MAX_RETRIES" ]; then
echo "Maestro tests failed after $MAX_RETRIES attempts."
exit 1
else
RETRY_COUNT=0
fi
# Check if MAESTRO_TAGS are present in the test file
if contains_tag "$TEST_FILE_PATH" "$MAESTRO_TAGS"; then
# Just run the test if it's tagged as edge, if on an edge environment
if [ "$test_environment" != "edge" ] || contains_tag "$TEST_FILE_PATH" "edge"; then
# Execute Maestro test flow and retry if failed
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
maestro test -e APP_ID=com.stripe.android.financialconnections.example --format junit --output $TEST_RESULTS_PATH/$(basename "$TEST_FILE_PATH").xml "$TEST_FILE_PATH" && break
let RETRY_COUNT=RETRY_COUNT+1
echo "Maestro test attempt $RETRY_COUNT failed. Retrying..."
done
if [ "$RETRY_COUNT" -eq "$MAX_RETRIES" ]; then
echo "Maestro tests failed after $MAX_RETRIES attempts."
exit 1
else
RETRY_COUNT=0
fi
else
echo "Skipping test file without 'edge' tag: $TEST_FILE_PATH"
fi
fi
done

0 comments on commit 1109395

Please sign in to comment.