diff --git a/dev.yml b/dev.yml index 1446df79..f9df23de 100644 --- a/dev.yml +++ b/dev.yml @@ -427,17 +427,20 @@ commands: cd sample/android USE_LOCAL_SDK=1 ./gradlew :shopify_checkout-kit-react-native:test --refresh-dependencies e2e: - desc: Run React Native sample Maestro guest checkout smoke flows + desc: Run React Native sample Maestro checkout smoke flows + syntax: "{ios|android} [--guest] [--hardcoded-buyer-identity]" run: | - echo "Usage: dev rn e2e {ios|android}" >&2 + echo "Usage: dev rn e2e {ios|android} [--guest] [--hardcoded-buyer-identity]" >&2 exit 1 subcommands: ios: - desc: Run the React Native iOS Maestro guest checkout smoke flow - run: cd platforms/react-native && ./scripts/e2e_maestro_ios + desc: Run the React Native iOS Maestro checkout smoke flows + syntax: "[--guest] [--hardcoded-buyer-identity]" + run: cd platforms/react-native && ./scripts/e2e_maestro_ios "$@" android: - desc: Run the React Native Android Maestro guest checkout smoke flow - run: cd platforms/react-native && ./scripts/e2e_maestro_android + desc: Run the React Native Android Maestro checkout smoke flows + syntax: "[--guest] [--hardcoded-buyer-identity]" + run: cd platforms/react-native && ./scripts/e2e_maestro_android "$@" lint: desc: Run all React Native lint checks (Swift, module, sample) aliases: [style] diff --git a/e2e/README.md b/e2e/README.md index d25711b9..b06805dd 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -26,6 +26,17 @@ React Native Android: dev rn e2e android ``` +Run one or more focused React Native scenarios by passing scenario flags: + +```bash +dev rn e2e ios --guest +dev rn e2e ios --hardcoded-buyer-identity +dev rn e2e ios --guest --hardcoded-buyer-identity +dev rn e2e android --guest +dev rn e2e android --hardcoded-buyer-identity +dev rn e2e android --guest --hardcoded-buyer-identity +``` + The React Native commands start Metro if needed, build and launch the target sample app, then run Maestro. They require the standard storefront `.env` setup, but the E2E flows seed their own carts through the bootstrap deep link. The diff --git a/platforms/react-native/scripts/e2e_maestro_android b/platforms/react-native/scripts/e2e_maestro_android index 55def4bc..add6c4cd 100755 --- a/platforms/react-native/scripts/e2e_maestro_android +++ b/platforms/react-native/scripts/e2e_maestro_android @@ -9,6 +9,58 @@ METRO_LOG="${TMPDIR:-/tmp}/checkout-kit-rn-android-metro.log" METRO_PID="" APP_ID="com.shopify.checkoutkit.reactnativedemo" CART_BOOTSTRAP_BASE_LINK="${APP_ID}://cart?productIndex=0&quantity=1" +MAESTRO_FLOWS=() + +usage() { + cat <&2 +Usage: dev rn e2e android [--guest] [--hardcoded-buyer-identity] + +Runs all React Native Android Maestro checkout smoke flows by default. +Pass one or more focused scenario flags to run only those flows. + +Options: + --guest Run only the guest checkout smoke flow. + --hardcoded-buyer-identity Run only the hardcoded buyer identity smoke flow. +EOF +} + +add_maestro_flow() { + local flow="$1" + + if [ "${#MAESTRO_FLOWS[@]}" -gt 0 ]; then + for existing_flow in "${MAESTRO_FLOWS[@]}"; do + if [ "$existing_flow" = "$flow" ]; then + return + fi + done + fi + + MAESTRO_FLOWS+=("$flow") +} + +for arg in "$@"; do + case "$arg" in + --guest) + add_maestro_flow "tests/react-native/checkout-guest.yaml" + ;; + --hardcoded-buyer-identity) + add_maestro_flow "tests/react-native/checkout-hardcoded-buyer-identity.yaml" + ;; + -h|--help) + usage + exit 0 + ;; + *) + usage + echo "Unknown option: $arg" >&2 + exit 1 + ;; + esac +done + +if [ "${#MAESTRO_FLOWS[@]}" -eq 0 ]; then + MAESTRO_FLOWS=(".") +fi metro_running() { curl --silent --fail http://localhost:8081/status | grep -q "packager-status:running" @@ -58,5 +110,5 @@ pnpm sample android --local --extra-params "--refresh-dependencies" maestro --platform android test --config config.yaml \ -e "APP_ID=${APP_ID}" \ -e "CART_BOOTSTRAP_BASE_LINK=${CART_BOOTSTRAP_BASE_LINK}" \ - . + "${MAESTRO_FLOWS[@]}" ) diff --git a/platforms/react-native/scripts/e2e_maestro_ios b/platforms/react-native/scripts/e2e_maestro_ios index 13075bf9..0b95550a 100755 --- a/platforms/react-native/scripts/e2e_maestro_ios +++ b/platforms/react-native/scripts/e2e_maestro_ios @@ -9,6 +9,58 @@ METRO_LOG="${TMPDIR:-/tmp}/checkout-kit-rn-ios-metro.log" METRO_PID="" APP_ID="com.shopify.checkoutkit.reactnativedemo" CART_BOOTSTRAP_BASE_LINK="${APP_ID}://cart?productIndex=0&quantity=1" +MAESTRO_FLOWS=() + +usage() { + cat <&2 +Usage: dev rn e2e ios [--guest] [--hardcoded-buyer-identity] + +Runs all React Native iOS Maestro checkout smoke flows by default. +Pass one or more focused scenario flags to run only those flows. + +Options: + --guest Run only the guest checkout smoke flow. + --hardcoded-buyer-identity Run only the hardcoded buyer identity smoke flow. +EOF +} + +add_maestro_flow() { + local flow="$1" + + if [ "${#MAESTRO_FLOWS[@]}" -gt 0 ]; then + for existing_flow in "${MAESTRO_FLOWS[@]}"; do + if [ "$existing_flow" = "$flow" ]; then + return + fi + done + fi + + MAESTRO_FLOWS+=("$flow") +} + +for arg in "$@"; do + case "$arg" in + --guest) + add_maestro_flow "tests/react-native/checkout-guest.yaml" + ;; + --hardcoded-buyer-identity) + add_maestro_flow "tests/react-native/checkout-hardcoded-buyer-identity.yaml" + ;; + -h|--help) + usage + exit 0 + ;; + *) + usage + echo "Unknown option: $arg" >&2 + exit 1 + ;; + esac +done + +if [ "${#MAESTRO_FLOWS[@]}" -eq 0 ]; then + MAESTRO_FLOWS=(".") +fi metro_running() { curl --silent --fail http://localhost:8081/status | grep -q "packager-status:running" @@ -58,5 +110,5 @@ pnpm sample ios --local maestro --platform ios test --config config.yaml \ -e "APP_ID=${APP_ID}" \ -e "CART_BOOTSTRAP_BASE_LINK=${CART_BOOTSTRAP_BASE_LINK}" \ - . + "${MAESTRO_FLOWS[@]}" )