Skip to content

Commit c5fb44e

Browse files
committed
Wire RN E2E dev commands
1 parent 7d2db00 commit c5fb44e

6 files changed

Lines changed: 177 additions & 9 deletions

File tree

dev.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,18 @@ commands:
425425
USE_LOCAL_SDK=1 ./scripts/publish_android_snapshot
426426
cd sample/android
427427
USE_LOCAL_SDK=1 ./gradlew :shopify_checkout-kit-react-native:test --refresh-dependencies
428+
e2e:
429+
desc: Run React Native sample Maestro guest checkout smoke flows
430+
run: |
431+
echo "Usage: dev rn e2e {ios|android}" >&2
432+
exit 1
433+
subcommands:
434+
ios:
435+
desc: Run the React Native iOS Maestro guest checkout smoke flow
436+
run: cd platforms/react-native && ./scripts/e2e_maestro_ios
437+
android:
438+
desc: Run the React Native Android Maestro guest checkout smoke flow
439+
run: cd platforms/react-native && ./scripts/e2e_maestro_android
428440
lint:
429441
desc: Run all React Native lint checks (Swift, module, sample)
430442
aliases: [style]

e2e/README.md

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,47 @@
11
# Checkout Kit End-to-End Tests
22

3-
This directory is reserved for cross-platform end-to-end tests. There is no runnable e2e suite checked in yet.
3+
This directory contains Maestro end-to-end smoke flows for Checkout Kit sample
4+
apps.
45

5-
Planned coverage:
6+
The current runnable suite starts with React Native. It verifies a full guest
7+
checkout from a seeded cart in the sample app, through Shopify checkout, and
8+
back to the app after completion.
69

7-
- Swift checkout presentation and protocol lifecycle.
8-
- Android checkout presentation and protocol lifecycle.
9-
- React Native wrapper behavior.
10-
- Web component open/close and `checkout:*` events.
10+
## Run locally
1111

12-
Until this directory contains test code, use the platform test suites and sample apps described in each platform README.
12+
Run the matching command from the repo root.
13+
14+
Run `dev up` first to provision the local toolchain. Install Maestro separately
15+
and make sure `maestro --version` succeeds before running these flows.
16+
17+
React Native iOS:
18+
19+
```bash
20+
dev rn e2e ios
21+
```
22+
23+
React Native Android:
24+
25+
```bash
26+
dev rn e2e android
27+
```
28+
29+
The React Native commands start Metro if needed, build and launch the target
30+
sample app, then run Maestro. They require the standard storefront `.env` setup,
31+
but the E2E flow seeds its own cart through the bootstrap deep link; no manual
32+
sample cart setup is required.
33+
34+
## Files
35+
36+
- `config.yaml` configures Maestro for shared platform behavior.
37+
- `flows/` contains reusable Maestro subflows for app setup and checkout steps.
38+
- `tests/react-native/full-guest-checkout.yaml` composes the React Native guest
39+
checkout smoke test from those subflows.
40+
41+
## Scope
42+
43+
This smoke flow is intended to catch regressions in the React Native sample app
44+
integration surface: cart bootstrap, checkout presentation, checkout
45+
completion, and return to the sample app. It is not a replacement for
46+
checkout-web's browser-based coverage or for future native Swift and Android
47+
sample-app E2E coverage.

platforms/react-native/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CI uses the default (published) path naturally — no special flag handling. Kee
8484

8585
### Gotchas
8686

87-
- **iOS**: `dev rn ios` runs `pod install` before launching, so dropping or adding `--local` will re-resolve the pods as needed. You can still run `dev rn pod-install [--local]` directly when you only want to refresh pods.
87+
- **iOS**: non-local runs use `pod install`, while `dev rn ios --local` and `dev rn pod-install --local` run a targeted update for the `ShopifyCheckoutKit` pods so CocoaPods re-resolves the local SDK path.
8888
- **Android (CLI)**: covered automatically by the publish script — every `--local` run re-publishes the local Android and Kotlin protocol artifacts before building.
8989
- **Android (Android Studio)**: when running the sample via Android Studio's Run button after editing `platforms/android/**` or `protocol/languages/kotlin/**`, run `platforms/react-native/scripts/publish_android_snapshot` once manually (with `USE_LOCAL_SDK=1`) or run `dev rn android --local` from a terminal to refresh `~/.m2/`.
9090
- The flag affects **only the RN build**. The standalone Swift and Android SDK builds (`dev android build`, `swift build`, etc.) are unaffected.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
7+
METRO_LOG="${TMPDIR:-/tmp}/checkout-kit-rn-android-metro.log"
8+
METRO_PID=""
9+
APP_ID="com.shopify.checkoutkit.reactnativedemo"
10+
CART_BOOTSTRAP_LINK="${APP_ID}://cart?productIndex=0&quantity=1"
11+
12+
metro_running() {
13+
curl --silent --fail http://localhost:8081/status | grep -q "packager-status:running"
14+
}
15+
16+
cleanup() {
17+
if [ -n "$METRO_PID" ]; then
18+
kill "$METRO_PID" 2>/dev/null || true
19+
fi
20+
}
21+
22+
wait_for_metro() {
23+
for _ in $(seq 1 60); do
24+
if metro_running; then
25+
return 0
26+
fi
27+
sleep 1
28+
done
29+
30+
echo "Timed out waiting for Metro. Last log lines:" >&2
31+
tail -n 40 "$METRO_LOG" >&2 || true
32+
return 1
33+
}
34+
35+
require_maestro() {
36+
if ! maestro --version >/dev/null 2>&1; then
37+
echo "Maestro is required to run React Native E2E tests." >&2
38+
echo "Install Maestro and make sure maestro --version succeeds." >&2
39+
return 1
40+
fi
41+
}
42+
43+
cd "$ROOT_DIR"
44+
45+
require_maestro
46+
47+
if ! metro_running; then
48+
/opt/dev/bin/dev react-native start >"$METRO_LOG" 2>&1 &
49+
METRO_PID="$!"
50+
trap cleanup EXIT
51+
fi
52+
53+
wait_for_metro
54+
pnpm sample android --local --extra-params "--refresh-dependencies"
55+
maestro --platform android test --config ../../e2e/config.yaml \
56+
-e "APP_ID=${APP_ID}" \
57+
-e "CART_BOOTSTRAP_LINK=${CART_BOOTSTRAP_LINK}" \
58+
../../e2e/tests/react-native/full-guest-checkout.yaml
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
7+
METRO_LOG="${TMPDIR:-/tmp}/checkout-kit-rn-ios-metro.log"
8+
METRO_PID=""
9+
APP_ID="com.shopify.checkoutkit.reactnativedemo"
10+
CART_BOOTSTRAP_LINK="${APP_ID}://cart?productIndex=0&quantity=1"
11+
12+
metro_running() {
13+
curl --silent --fail http://localhost:8081/status | grep -q "packager-status:running"
14+
}
15+
16+
cleanup() {
17+
if [ -n "$METRO_PID" ]; then
18+
kill "$METRO_PID" 2>/dev/null || true
19+
fi
20+
}
21+
22+
wait_for_metro() {
23+
for _ in $(seq 1 60); do
24+
if metro_running; then
25+
return 0
26+
fi
27+
sleep 1
28+
done
29+
30+
echo "Timed out waiting for Metro. Last log lines:" >&2
31+
tail -n 40 "$METRO_LOG" >&2 || true
32+
return 1
33+
}
34+
35+
require_maestro() {
36+
if ! maestro --version >/dev/null 2>&1; then
37+
echo "Maestro is required to run React Native E2E tests." >&2
38+
echo "Install Maestro and make sure maestro --version succeeds." >&2
39+
return 1
40+
fi
41+
}
42+
43+
cd "$ROOT_DIR"
44+
45+
require_maestro
46+
47+
if ! metro_running; then
48+
/opt/dev/bin/dev react-native start >"$METRO_LOG" 2>&1 &
49+
METRO_PID="$!"
50+
trap cleanup EXIT
51+
fi
52+
53+
wait_for_metro
54+
pnpm sample ios --local
55+
maestro --platform ios test --config ../../e2e/config.yaml \
56+
-e "APP_ID=${APP_ID}" \
57+
-e "CART_BOOTSTRAP_LINK=${CART_BOOTSTRAP_LINK}" \
58+
../../e2e/tests/react-native/full-guest-checkout.yaml

platforms/react-native/scripts/pod_install

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ done
1010

1111
cd sample/ios
1212
bundle check || bundle install
13-
bundle exec pod install --repo-update
13+
14+
if [ "${USE_LOCAL_SDK:-0}" = "1" ]; then
15+
bundle exec pod update ShopifyCheckoutKit ShopifyCheckoutKit/AcceleratedCheckouts --repo-update
16+
else
17+
bundle exec pod install --repo-update
18+
fi

0 commit comments

Comments
 (0)