From 4fd2fc05fc3576503483ac1714c5bd21a01d8d71 Mon Sep 17 00:00:00 2001 From: Henrique Velloso Date: Wed, 18 Feb 2026 23:09:17 -0300 Subject: [PATCH] Update version number and refine visibility checks in Maestro flows - Incremented app version in `pubspec.yaml` from 1.0.0+1000 to 1.0.0+3000. - Replaced `extendedWaitUntil` with `assertVisible` in multiple Maestro flow files to streamline visibility checks and improve readability. - Added a new flow `check_signed_in_test_account.yaml` to verify if the app is already signed in with the test account, enhancing the automated testing process. --- .../flows/check_signed_in_test_account.yaml | 36 ++++++++++ maestro/flows/install_app.yaml | 8 +-- maestro/flows/install_older_version.yaml | 29 ++++----- maestro/flows/search_app.yaml | 16 ++--- maestro/flows/setup_amber_test_account.yaml | 65 ++++++------------- maestro/flows/sign_in_amber.yaml | 17 ++--- maestro/flows/uninstall_if_installed.yaml | 8 +-- maestro/flows/verify_and_update_all.yaml | 12 ++-- maestro/smoke_test.yaml | 22 ++----- pubspec.yaml | 2 +- test/scripts/run-test-003.sh | 38 ++++++++--- 11 files changed, 121 insertions(+), 132 deletions(-) create mode 100644 maestro/flows/check_signed_in_test_account.yaml diff --git a/maestro/flows/check_signed_in_test_account.yaml b/maestro/flows/check_signed_in_test_account.yaml new file mode 100644 index 0000000..e0fdb86 --- /dev/null +++ b/maestro/flows/check_signed_in_test_account.yaml @@ -0,0 +1,36 @@ +appId: dev.zapstore.app +--- +# ============================================================= +# Sub-flow: Check if Zapstore is already signed in with test account +# +# Returns success if both "Sign Out" and "npub1lhr" are visible on Profile. +# Use this BEFORE setup_amber to skip Amber/sign-in when already logged in. +# +# Test account npub prefix: npub1lhr +# ============================================================= + +- runFlow: + when: + visible: "Allow" + commands: + - tapOn: "Allow" + +- assertVisible: + text: ".*Tab 3 of 3" + +- tapOn: + text: ".*Tab 3 of 3" + label: "Tap Profile tab" +- tapOn: + text: ".*Tab 3 of 3" + label: "Tap Profile tab again to reset to root" + +- waitForAnimationToEnd + +- scrollUntilVisible: + element: + text: "Sign Out" + direction: UP + +- assertVisible: + text: ".*npub1lhr.*" diff --git a/maestro/flows/install_app.yaml b/maestro/flows/install_app.yaml index 8a38c24..af2d768 100644 --- a/maestro/flows/install_app.yaml +++ b/maestro/flows/install_app.yaml @@ -39,9 +39,7 @@ appId: dev.zapstore.app - tapOn: "Trust and install app" # Android system install dialog -- extendedWaitUntil: - visible: "Install" - timeout: 15000 +- assertVisible: "Install" - tapOn: "Install" # Wait for either "Open" (success) or Samsung "package analysis error" dialog. @@ -59,6 +57,4 @@ appId: dev.zapstore.app - tapOn: "OK" # Confirm install completed -- extendedWaitUntil: - visible: "Open" - timeout: 15000 +- assertVisible: "Open" diff --git a/maestro/flows/install_older_version.yaml b/maestro/flows/install_older_version.yaml index eda413f..0c958d2 100644 --- a/maestro/flows/install_older_version.yaml +++ b/maestro/flows/install_older_version.yaml @@ -28,7 +28,6 @@ appId: dev.zapstore.app element: text: ".*All Versions.*" direction: DOWN - timeout: 30000 - tapOn: text: ".*All Versions.*" @@ -50,11 +49,11 @@ appId: dev.zapstore.app label: "Install older version" # Wait for the first dialog to appear. -# Use specific dialog phrases to avoid matching background "Install" buttons -# in the All Versions list. +# Regex must match the FULL accessibilityText / text of each element +# (Java matches()), so use .* wildcards around partial phrases. - extendedWaitUntil: visible: - text: "(?:Do you want to update|Do you want to install|Accept|Trust and install app)" + text: "(?:.*Do you want to (?:update|install).*|Accept|Trust and install app)" timeout: 60000 # Amber may ask to sign a request during install @@ -63,10 +62,8 @@ appId: dev.zapstore.app visible: "Accept" commands: - tapOn: "Accept" - - extendedWaitUntil: - visible: - text: "(?:Do you want to update|Do you want to install|Trust and install app)" - timeout: 30000 + - assertVisible: + text: "(?:.*Do you want to (?:update|install).*|Trust and install app)" # Samsung security dialog (may not appear if source already trusted) - runFlow: @@ -74,22 +71,22 @@ appId: dev.zapstore.app visible: "Trust and install app" commands: - tapOn: "Trust and install app" - - extendedWaitUntil: - visible: - text: "(?:Do you want to update|Do you want to install)" - timeout: 30000 + - assertVisible: + text: ".*Do you want to (?:update|install).*" # Handle Android system install dialog - runFlow: when: - visible: "Do you want to install" + visible: + text: ".*Do you want to install.*" commands: - tapOn: "Install" # Handle Android system update/downgrade dialog - runFlow: when: - visible: "Do you want to update" + visible: + text: ".*Do you want to update.*" commands: - tapOn: "Update" @@ -107,6 +104,4 @@ appId: dev.zapstore.app - tapOn: "OK" # Confirm install completed -- extendedWaitUntil: - visible: "Open" - timeout: 30000 +- assertVisible: "Open" diff --git a/maestro/flows/search_app.yaml b/maestro/flows/search_app.yaml index a261ab5..3de768e 100644 --- a/maestro/flows/search_app.yaml +++ b/maestro/flows/search_app.yaml @@ -19,10 +19,8 @@ appId: dev.zapstore.app - tapOn: "Allow" # Wait for the app to be ready (tab bar visible) -- extendedWaitUntil: - visible: - text: ".*Tab 1 of 3" - timeout: 20000 +- assertVisible: + text: ".*Tab 1 of 3" # Ensure we're on the Search tab root - tapOn: @@ -41,18 +39,14 @@ appId: dev.zapstore.app commands: - tapOn: "Clear search" -- extendedWaitUntil: - visible: "Search apps" - timeout: 20000 +- assertVisible: "Search apps" - tapOn: "Search apps" - inputText: "${APP_SEARCH_TERM}" - pressKey: Enter -- extendedWaitUntil: - visible: - text: "${APP_MATCH_TEXT}" - timeout: 20000 +- assertVisible: + text: "${APP_MATCH_TEXT}" - tapOn: text: "${APP_MATCH_TEXT}" diff --git a/maestro/flows/setup_amber_test_account.yaml b/maestro/flows/setup_amber_test_account.yaml index 63d6613..a686135 100644 --- a/maestro/flows/setup_amber_test_account.yaml +++ b/maestro/flows/setup_amber_test_account.yaml @@ -3,9 +3,10 @@ appId: com.greenart7c3.nostrsigner # ============================================================= # Sub-flow: Ensure test account is active in Amber # -# Handles two scenarios: -# A) Amber has accounts → pick or import via account selector +# Handles three scenarios: +# A) Amber main screen ("Applications") → open Accounts tab # B) Fresh Amber (onboarding) → import from nsec directly +# C) Already on account selector → pick or import # # Test account npub (truncated): npub1lhr # @@ -17,58 +18,43 @@ appId: com.greenart7c3.nostrsigner # - Device language set to English # ============================================================= -# Wait for Amber to load -- extendedWaitUntil: - visible: - text: "(?:Accounts|Use your private key)" - timeout: 15000 +# Wait for Amber to load (main screen or onboarding) +- assertVisible: + text: "(?:Applications|Use your private key|Select Account)" -# ─── Scenario A: main screen with accounts ─── +# ─── Scenario A: main screen with accounts (title = "Applications") ─── - runFlow: when: - visible: "Accounts" + visible: "Applications" commands: - tapOn: text: "Accounts" - label: "Open accounts selector" - - extendedWaitUntil: - visible: "Select Account" - timeout: 5000 + label: "Tap Accounts bottom tab" + - assertVisible: "Select Account" # Import test account if not present - runFlow: when: notVisible: "npub1lhr" commands: - tapOn: "Add New Account" - - extendedWaitUntil: - visible: "Use your private key" - timeout: 10000 + - assertVisible: "Use your private key" - tapOn: "Use your private key" - - extendedWaitUntil: - visible: "Nsec / private key" - timeout: 10000 + - assertVisible: "Nsec / private key" - tapOn: text: "Nsec / private key" label: "Tap nsec input field" - inputText: "${NOSTR_TEST_NSEC}" - tapOn: "Next" - - extendedWaitUntil: - visible: "Finish" - timeout: 10000 + - assertVisible: "Finish" - tapOn: "Finish" - # Wait for notification dialog or main screen - - extendedWaitUntil: - visible: - text: "(?:Allow Amber|Applications)" - timeout: 20000 + - assertVisible: + text: "(?:Allow Amber|Applications)" - runFlow: when: visible: "Allow" commands: - tapOn: "Allow" - - extendedWaitUntil: - visible: "Applications" - timeout: 15000 + - assertVisible: "Applications" # If account sheet is still open (account existed), select it - runFlow: when: @@ -85,28 +71,19 @@ appId: com.greenart7c3.nostrsigner visible: "Use your private key" commands: - tapOn: "Use your private key" - - extendedWaitUntil: - visible: "Nsec / private key" - timeout: 10000 + - assertVisible: "Nsec / private key" - tapOn: text: "Nsec / private key" label: "Tap nsec input field" - inputText: "${NOSTR_TEST_NSEC}" - tapOn: "Next" - - extendedWaitUntil: - visible: "Finish" - timeout: 10000 + - assertVisible: "Finish" - tapOn: "Finish" - # Wait for notification dialog or main screen - - extendedWaitUntil: - visible: - text: "(?:Allow Amber|Applications)" - timeout: 20000 + - assertVisible: + text: "(?:Allow Amber|Applications)" - runFlow: when: visible: "Allow" commands: - tapOn: "Allow" - - extendedWaitUntil: - visible: "Applications" - timeout: 15000 + - assertVisible: "Applications" diff --git a/maestro/flows/sign_in_amber.yaml b/maestro/flows/sign_in_amber.yaml index 8fe31da..bea00c4 100644 --- a/maestro/flows/sign_in_amber.yaml +++ b/maestro/flows/sign_in_amber.yaml @@ -22,10 +22,8 @@ appId: dev.zapstore.app - tapOn: "Allow" # Wait for the app to fully load (tab bar must be visible) -- extendedWaitUntil: - visible: - text: ".*Tab 3 of 3" - timeout: 20000 +- assertVisible: + text: ".*Tab 3 of 3" - tapOn: text: ".*Tab 3 of 3" @@ -41,7 +39,6 @@ appId: dev.zapstore.app element: text: "(?:Sign in with Amber|Sign Out)" direction: UP - timeout: 30000 # If signed in with wrong account, sign out first - runFlow: @@ -53,9 +50,7 @@ appId: dev.zapstore.app notVisible: "npub1lhrt" commands: - tapOn: "Sign Out" - - extendedWaitUntil: - visible: "Sign in with Amber" - timeout: 15000 + - assertVisible: "Sign in with Amber" # If not signed in, sign in via Amber - runFlow: @@ -63,14 +58,11 @@ appId: dev.zapstore.app visible: "Sign in with Amber" commands: - tapOn: "Sign in with Amber" - - extendedWaitUntil: - visible: "Connect" - timeout: 20000 + - assertVisible: "Connect" - tapOn: "Connect" - scrollUntilVisible: element: "Sign Out" direction: UP - timeout: 30000 # After Amber sign-in, app may return to a different tab — go back to Profile - tapOn: @@ -84,4 +76,3 @@ appId: dev.zapstore.app element: text: "(?:Sign Out|npub1lhrt)" direction: UP - timeout: 15000 diff --git a/maestro/flows/uninstall_if_installed.yaml b/maestro/flows/uninstall_if_installed.yaml index 5814024..a278887 100644 --- a/maestro/flows/uninstall_if_installed.yaml +++ b/maestro/flows/uninstall_if_installed.yaml @@ -13,10 +13,6 @@ appId: dev.zapstore.app visible: "Uninstall" commands: - tapOn: "Uninstall" - - extendedWaitUntil: - visible: "OK" - timeout: 5000 + - assertVisible: "OK" - tapOn: "OK" - - extendedWaitUntil: - visible: "Install" - timeout: 10000 + - assertVisible: "Install" diff --git a/maestro/flows/verify_and_update_all.yaml b/maestro/flows/verify_and_update_all.yaml index a24b1ed..768c8c5 100644 --- a/maestro/flows/verify_and_update_all.yaml +++ b/maestro/flows/verify_and_update_all.yaml @@ -18,10 +18,8 @@ appId: dev.zapstore.app - tapOn: "Allow" # Wait for the app to be ready (tab bar visible) -- extendedWaitUntil: - visible: - text: ".*Tab 2 of 3" - timeout: 20000 +- assertVisible: + text: ".*Tab 2 of 3" - tapOn: text: ".*Tab 2 of 3" @@ -43,10 +41,8 @@ appId: dev.zapstore.app - waitForAnimationToEnd # Wait for updates to load (may take time after restart) -- extendedWaitUntil: - visible: - text: ".*Update All.*" - timeout: 30000 +- assertVisible: + text: ".*Update All.*" - tapOn: text: ".*Update All.*" diff --git a/maestro/smoke_test.yaml b/maestro/smoke_test.yaml index 45d356d..4cf528a 100644 --- a/maestro/smoke_test.yaml +++ b/maestro/smoke_test.yaml @@ -9,13 +9,9 @@ tags: # ====== Search Tab (Initial Screen) ====== -- extendedWaitUntil: - visible: "Search apps" - timeout: 15000 +- assertVisible: "Search apps" -- extendedWaitUntil: - visible: "LATEST RELEASES" - timeout: 10000 +- assertVisible: "LATEST RELEASES" - takeScreenshot: "01_search_home.png" @@ -51,9 +47,7 @@ tags: - inputText: "nostr" - pressKey: Enter -- extendedWaitUntil: - notVisible: "LATEST RELEASES" - timeout: 10000 +- assertNotVisible: "LATEST RELEASES" - takeScreenshot: "05_search_results.png" @@ -65,18 +59,14 @@ tags: APP_SEARCH_TERM: "Zapstore" APP_MATCH_TEXT: ".*open app store.*" -- extendedWaitUntil: - visible: "Zapstore Alpha" - timeout: 5000 +- assertVisible: "Zapstore Alpha" - takeScreenshot: "06_app_detail.png" # Go back to search results - back -- extendedWaitUntil: - visible: - text: ".*open app store.*" - timeout: 5000 +- assertVisible: + text: ".*open app store.*" - takeScreenshot: "07_back_to_search.png" diff --git a/pubspec.yaml b/pubspec.yaml index 44af526..bb8fd33 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: zapstore description: Zapstore mobile app publish_to: none -version: 1.0.0+1000 +version: 1.0.0+3000 environment: sdk: ^3.8.1 diff --git a/test/scripts/run-test-003.sh b/test/scripts/run-test-003.sh index dc35a49..2636737 100755 --- a/test/scripts/run-test-003.sh +++ b/test/scripts/run-test-003.sh @@ -180,7 +180,7 @@ setup_amber() { adb -s "$DEVICE_ID" shell am force-stop com.greenart7c3.nostrsigner 2>/dev/null || true adb -s "$DEVICE_ID" shell am force-stop "$ZAPSTORE_PKG" 2>/dev/null || true sleep 2 - adb -s "$DEVICE_ID" shell monkey -p com.greenart7c3.nostrsigner -c android.intent.category.LAUNCHER 1 >/dev/null 2>&1 + adb -s "$DEVICE_ID" shell am start -n com.greenart7c3.nostrsigner/.MainActivity >/dev/null 2>&1 sleep 5 if run_maestro "$FLOWS_DIR/setup_amber_test_account.yaml" "NOSTR_TEST_NSEC=$NOSTR_TEST_NSEC"; then log " Amber test account ready" @@ -396,6 +396,28 @@ EOF # ── Main ───────────────────────────────────────────────────────────── +# Check if already signed in with test account; if not, setup Amber and sign in. +# Skips Amber setup entirely when already logged in with correct user. +# setup_amber only imports the account into Amber if it's not already there. +# Sets ALREADY_SIGNED_IN=1 when skipped, so main won't restart Zapstore. +ensure_signed_in() { + log "── Check: Already signed in with test account? ──" + restart_zapstore + if run_maestro "$FLOWS_DIR/check_signed_in_test_account.yaml" 2>/dev/null; then + log " Already signed in with test account, skipping Amber setup" + ALREADY_SIGNED_IN=1 + return 0 + fi + ALREADY_SIGNED_IN=0 + log " Not signed in (or wrong account), setting up Amber and signing in..." + adb -s "$DEVICE_ID" shell pm clear "$ZAPSTORE_PKG" >/dev/null 2>&1 || true + adb -s "$DEVICE_ID" shell pm grant "$ZAPSTORE_PKG" android.permission.POST_NOTIFICATIONS 2>/dev/null || true + adb -s "$DEVICE_ID" shell am force-stop com.greenart7c3.nostrsigner 2>/dev/null || true + setup_amber + restart_zapstore + sign_in +} + main() { log "═══ TEST-003: Bulk Update Flow ═══" @@ -404,16 +426,12 @@ main() { discover_device setup_screen - setup_amber - # Clear Zapstore data to avoid NIP04 conflicts between - # the previous session (e.g. hvmelo) and the test account in Amber - adb -s "$DEVICE_ID" shell pm clear "$ZAPSTORE_PKG" >/dev/null 2>&1 || true - # Re-grant notification permission so the dialog won't appear on fresh launch - adb -s "$DEVICE_ID" shell pm grant "$ZAPSTORE_PKG" android.permission.POST_NOTIFICATIONS 2>/dev/null || true - adb -s "$DEVICE_ID" shell am force-stop com.greenart7c3.nostrsigner 2>/dev/null || true + ensure_signed_in uninstall_apps - restart_zapstore - sign_in + # Only restart when we did full setup (pm clear); when already signed in, Zapstore stays open + if [ "${ALREADY_SIGNED_IN:-0}" -eq 0 ]; then + restart_zapstore + fi install_all_older verify_and_update verify_post_update