Skip to content

Commit 2be87ba

Browse files
committed
Wire RN E2E dev commands
1 parent 8c46bf7 commit 2be87ba

6 files changed

Lines changed: 157 additions & 9 deletions

File tree

dev.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ commands:
9393
/opt/dev/bin/dev react-native test
9494
/opt/dev/bin/dev web test
9595
96+
e2e:
97+
desc: Run shared Maestro checkout smoke flows
98+
run: |
99+
echo "Usage: dev e2e {rn-ios|rn-android}" >&2
100+
exit 1
101+
subcommands:
102+
rn-ios:
103+
desc: Run the React Native iOS Maestro guest checkout smoke flow
104+
run: /opt/dev/bin/dev react-native e2e ios
105+
rn-android:
106+
desc: Run the React Native Android Maestro guest checkout smoke flow
107+
run: /opt/dev/bin/dev react-native e2e android
108+
96109
apollo:
97110
desc: "Apollo GraphQL schema and code generation commands"
98111
subcommands:
@@ -405,6 +418,18 @@ commands:
405418
USE_LOCAL_SDK=1 ./scripts/publish_android_snapshot
406419
cd sample/android
407420
USE_LOCAL_SDK=1 ./gradlew :shopify_checkout-kit-react-native:test --refresh-dependencies
421+
e2e:
422+
desc: Run React Native sample Maestro guest checkout smoke flows
423+
run: |
424+
echo "Usage: dev rn e2e {ios|android}" >&2
425+
exit 1
426+
subcommands:
427+
ios:
428+
desc: Run the React Native iOS Maestro guest checkout smoke flow
429+
run: cd platforms/react-native && ./scripts/e2e_maestro_ios
430+
android:
431+
desc: Run the React Native Android Maestro guest checkout smoke flow
432+
run: cd platforms/react-native && ./scripts/e2e_maestro_android
408433
lint:
409434
desc: Run all React Native lint checks (Swift, module, sample)
410435
aliases: [style]

e2e/README.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
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+
React Native iOS:
15+
16+
```bash
17+
dev e2e rn-ios
18+
```
19+
20+
React Native Android:
21+
22+
```bash
23+
dev e2e rn-android
24+
```
25+
26+
The React Native commands start Metro if needed, build and launch the target
27+
sample app, then run Maestro.
28+
29+
## Files
30+
31+
- `config.yaml` configures Maestro for shared platform behavior.
32+
- `flows/` contains reusable Maestro subflows for app setup and checkout steps.
33+
- `tests/react-native/full-guest-checkout.yaml` composes the React Native guest
34+
checkout smoke test from those subflows.
35+
36+
## Scope
37+
38+
This smoke flow is intended to catch regressions in the React Native sample app
39+
integration surface: cart bootstrap, checkout presentation, checkout
40+
completion, and return to the sample app. It is not a replacement for
41+
checkout-web's browser-based coverage or for future native Swift and Android
42+
sample-app E2E coverage.

platforms/react-native/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
"pod-install": "bash ./scripts/pod_install",
3939
"snapshot": "./scripts/create_snapshot",
4040
"compare-snapshot": "./scripts/compare_snapshot",
41-
"test": "jest"
41+
"test": "jest",
42+
"e2e:ios": "maestro --platform ios test --config ../../e2e/config.yaml -e APP_ID=com.shopify.checkoutkit.reactnativedemo -e 'CART_BOOTSTRAP_LINK=com.shopify.checkoutkit.reactnativedemo://cart?productIndex=0&quantity=1' ../../e2e/tests/react-native/full-guest-checkout.yaml",
43+
"e2e:android": "maestro --platform android test --config ../../e2e/config.yaml -e APP_ID=com.shopify.checkoutkit.reactnativedemo -e 'CART_BOOTSTRAP_LINK=com.shopify.checkoutkit.reactnativedemo://cart?productIndex=0&quantity=1' ../../e2e/tests/react-native/full-guest-checkout.yaml"
4244
},
4345
"devDependencies": {
4446
"@babel/core": "^7.29.7",
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
10+
metro_running() {
11+
curl --silent --fail http://localhost:8081/status | grep -q "packager-status:running"
12+
}
13+
14+
cleanup() {
15+
if [ -n "$METRO_PID" ]; then
16+
kill "$METRO_PID" 2>/dev/null || true
17+
fi
18+
}
19+
20+
wait_for_metro() {
21+
for _ in $(seq 1 60); do
22+
if metro_running; then
23+
return 0
24+
fi
25+
sleep 1
26+
done
27+
28+
echo "Timed out waiting for Metro. Last log lines:" >&2
29+
tail -n 40 "$METRO_LOG" >&2 || true
30+
return 1
31+
}
32+
33+
cd "$ROOT_DIR"
34+
35+
if ! metro_running; then
36+
pnpm sample start --reset-cache >"$METRO_LOG" 2>&1 &
37+
METRO_PID="$!"
38+
trap cleanup EXIT
39+
fi
40+
41+
wait_for_metro
42+
pnpm sample android
43+
pnpm e2e:android
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
10+
metro_running() {
11+
curl --silent --fail http://localhost:8081/status | grep -q "packager-status:running"
12+
}
13+
14+
cleanup() {
15+
if [ -n "$METRO_PID" ]; then
16+
kill "$METRO_PID" 2>/dev/null || true
17+
fi
18+
}
19+
20+
wait_for_metro() {
21+
for _ in $(seq 1 60); do
22+
if metro_running; then
23+
return 0
24+
fi
25+
sleep 1
26+
done
27+
28+
echo "Timed out waiting for Metro. Last log lines:" >&2
29+
tail -n 40 "$METRO_LOG" >&2 || true
30+
return 1
31+
}
32+
33+
cd "$ROOT_DIR"
34+
35+
if ! metro_running; then
36+
pnpm sample start --reset-cache >"$METRO_LOG" 2>&1 &
37+
METRO_PID="$!"
38+
trap cleanup EXIT
39+
fi
40+
41+
wait_for_metro
42+
pnpm sample ios --local
43+
pnpm e2e:ios

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)