diff --git a/dev.yml b/dev.yml index 33d50b66..fc107b40 100644 --- a/dev.yml +++ b/dev.yml @@ -457,16 +457,18 @@ commands: USE_LOCAL_SDK=1 ./gradlew :shopify_checkout-kit-react-native:test --refresh-dependencies e2e: desc: Run React Native sample Maestro checkout smoke flows - syntax: "{ios|android}" + 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 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 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) diff --git a/e2e/README.md b/e2e/README.md index e9271c14..254db92f 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -30,6 +30,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 3f479aac..db4a10e6 100755 --- a/platforms/react-native/scripts/e2e_maestro_android +++ b/platforms/react-native/scripts/e2e_maestro_android @@ -10,17 +10,43 @@ METRO_PID="" E2E_ENV_FILE="" 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 +Usage: dev rn e2e android [--guest] [--hardcoded-buyer-identity] -Runs React Native Android Maestro checkout smoke flows against the released native SDK artifacts. +Runs all React Native Android Maestro checkout smoke flows against the released native SDK artifacts. +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 @@ -33,6 +59,12 @@ for arg in "$@"; do esac done +if [ "${#MAESTRO_FLOWS[@]}" -eq 0 ]; then + MAESTRO_FLOWS=( + "tests/react-native/checkout-guest.yaml" + "tests/react-native/checkout-hardcoded-buyer-identity.yaml" + ) +fi metro_running() { curl --silent --fail http://localhost:8081/status | grep -q "packager-status:running" @@ -96,8 +128,10 @@ ENVFILE="$E2E_ENV_FILE" pnpm sample android --extra-params "--refresh-dependenci ( cd "$REPO_ROOT/e2e" - maestro --platform android test --config config.yaml \ - -e "APP_ID=${APP_ID}" \ - -e "CART_BOOTSTRAP_BASE_LINK=${CART_BOOTSTRAP_BASE_LINK}" \ - tests/react-native + for flow in "${MAESTRO_FLOWS[@]}"; do + maestro --platform android test --config config.yaml \ + -e "APP_ID=${APP_ID}" \ + -e "CART_BOOTSTRAP_BASE_LINK=${CART_BOOTSTRAP_BASE_LINK}" \ + "$flow" + done ) diff --git a/platforms/react-native/scripts/e2e_maestro_ios b/platforms/react-native/scripts/e2e_maestro_ios index 90c1704f..b8abcfc7 100755 --- a/platforms/react-native/scripts/e2e_maestro_ios +++ b/platforms/react-native/scripts/e2e_maestro_ios @@ -10,17 +10,43 @@ METRO_PID="" E2E_ENV_FILE="" 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 +Usage: dev rn e2e ios [--guest] [--hardcoded-buyer-identity] -Runs React Native iOS Maestro checkout smoke flows against the released native SDK artifacts. +Runs all React Native iOS Maestro checkout smoke flows against the released native SDK artifacts. +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 @@ -33,6 +59,12 @@ for arg in "$@"; do esac done +if [ "${#MAESTRO_FLOWS[@]}" -eq 0 ]; then + MAESTRO_FLOWS=( + "tests/react-native/checkout-guest.yaml" + "tests/react-native/checkout-hardcoded-buyer-identity.yaml" + ) +fi metro_running() { curl --silent --fail http://localhost:8081/status | grep -q "packager-status:running" @@ -96,8 +128,10 @@ ENVFILE="$E2E_ENV_FILE" pnpm sample ios ( cd "$REPO_ROOT/e2e" - maestro --platform ios test --config config.yaml \ - -e "APP_ID=${APP_ID}" \ - -e "CART_BOOTSTRAP_BASE_LINK=${CART_BOOTSTRAP_BASE_LINK}" \ - tests/react-native + for flow in "${MAESTRO_FLOWS[@]}"; do + maestro --platform ios test --config config.yaml \ + -e "APP_ID=${APP_ID}" \ + -e "CART_BOOTSTRAP_BASE_LINK=${CART_BOOTSTRAP_BASE_LINK}" \ + "$flow" + done )