Skip to content

Commit e8ae098

Browse files
authored
fix(mobile): repair discover categories and bootstrap iOS auth (#4912)
1 parent f78d7e7 commit e8ae098

File tree

7 files changed

+519
-6
lines changed

7 files changed

+519
-6
lines changed

.agents/skills/mobile-e2e/SKILL.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ xcodebuild -workspace Folo.xcworkspace \
7070
build
7171
```
7272

73+
### Apple Silicon simulator optimization
74+
75+
When running on an Apple Silicon Mac and building only for the simulator used in the current run, prefer compiling only the active `arm64` simulator architecture:
76+
77+
```bash
78+
xcodebuild ... \
79+
ONLY_ACTIVE_ARCH=YES \
80+
ARCHS=arm64
81+
```
82+
83+
Use this optimization only for local self-test / e2e simulator builds tied to the current machine. Do not use it when you need a universal simulator app for other machines or when running on Intel Macs.
84+
7385
Expected output pattern:
7486

7587
```bash

.agents/skills/mobile-self-test/SKILL.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ xcodebuild -workspace Folo.xcworkspace \
163163
clean build
164164
```
165165

166+
On Apple Silicon Macs, when the build is only for the dedicated simulator created for the current self-test run, prefer compiling only the active `arm64` simulator architecture:
167+
168+
```bash
169+
ONLY_ACTIVE_ARCH=YES \
170+
ARCHS=arm64
171+
```
172+
173+
Do not use that optimization when you need a universal simulator bundle for other machines or when the host Mac is Intel.
174+
166175
Expected output pattern:
167176

168177
```bash
@@ -299,6 +308,15 @@ export E2E_PASSWORD='Password123!'
299308
export E2E_EMAIL="folo-self-test-$(date +%Y%m%d%H%M%S)@example.com"
300309
```
301310

311+
For non-auth iOS self-tests, bootstrap auth through the standard iOS runner mode after the app has been installed and launched once:
312+
313+
```bash
314+
cd apps/mobile
315+
pnpm run e2e:ios:bootstrap
316+
```
317+
318+
This bootstrap path is the default for `prod` and `local` self-tests. Only skip it when the feature under test is login, registration, sign-out, session restoration, or another auth-specific flow that must be validated visually end-to-end.
319+
302320
#### iOS registration bootstrap
303321

304322
```bash

apps/mobile/e2e/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
pnpm run e2e:doctor
1414
pnpm run e2e:android
1515
pnpm run e2e:ios
16+
pnpm run e2e:ios:bootstrap
1617
```
1718

1819
## iOS Notes
@@ -22,6 +23,27 @@ pnpm run e2e:ios
2223
- `content.yaml`: ensure onboarding feed unfollowed -> follow -> timeline/read-unread -> unfollow
2324
- The iOS runner resets the simulator, disables password autofill prompts, installs the provided app bundle, then executes Maestro.
2425

26+
## Prod iOS auth bootstrap
27+
28+
When non-auth iOS self-tests need a signed-in simulator quickly, bootstrap auth through the standard iOS runner mode:
29+
30+
```bash
31+
pnpm run e2e:ios:bootstrap
32+
```
33+
34+
This mode uses the auth bootstrap helper on iOS when `EXPO_PUBLIC_E2E_ENV_PROFILE=prod` or `EXPO_PUBLIC_E2E_ENV_PROFILE=local`, and falls back to the normal iOS registration flow for other environments.
35+
36+
Optional environment variables:
37+
38+
- `E2E_EMAIL`
39+
- `E2E_PASSWORD`
40+
- `MAESTRO_IOS_DEVICE_ID`
41+
- `E2E_API_URL`
42+
- `E2E_CALLBACK_URL`
43+
- `E2E_BUNDLE_ID`
44+
45+
The bootstrap script signs in against prod using the mobile fallback token header, writes the auth cookie into the simulator's `ExpoSQLiteStorage` fallback store, and relaunches the app.
46+
2547
## Environment
2648

2749
- `E2E_EMAIL`

apps/mobile/e2e/run-maestro.sh

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
set -eu
33

44
platform="${1:?platform is required}"
5+
mode="${2:-full}"
56
debug_output="${MAESTRO_DEBUG_OUTPUT:-e2e/artifacts/${platform}}"
67
run_suffix="$(date +%s)-$$"
78

@@ -40,6 +41,7 @@ extract_ios_app_from_tar() {
4041
}
4142

4243
resolve_ios_app_path() {
44+
device_id="$1"
4345
if [ -n "${MAESTRO_IOS_APP_PATH:-}" ]; then
4446
if [ -d "${MAESTRO_IOS_APP_PATH}" ]; then
4547
printf '%s' "${MAESTRO_IOS_APP_PATH}"
@@ -60,7 +62,13 @@ resolve_ios_app_path() {
6062
return
6163
fi
6264

63-
find "$HOME/Library/Developer/Xcode/DerivedData" -path '*Build/Products/Release-iphonesimulator/Folo.app' | head -n1
65+
existing_path="$(find "$HOME/Library/Developer/Xcode/DerivedData" -path '*Build/Products/Release-iphonesimulator/Folo.app' | head -n1)"
66+
if [ -n "${existing_path}" ]; then
67+
printf '%s' "${existing_path}"
68+
return
69+
fi
70+
71+
build_ios_simulator_app "${device_id}"
6472
}
6573

6674
wait_for_android_ready() {
@@ -106,6 +114,48 @@ prepare_ios_simulator() {
106114
xcrun simctl bootstatus "${device_id}" -b >/dev/null 2>&1 || true
107115
}
108116

117+
append_ios_arch_args() {
118+
arch="$(uname -m)"
119+
if [ "${arch}" = "arm64" ]; then
120+
printf '%s\n' "ONLY_ACTIVE_ARCH=YES" "ARCHS=arm64"
121+
fi
122+
}
123+
124+
build_ios_simulator_app() {
125+
device_id="$1"
126+
(
127+
cd ios
128+
pod install
129+
set -- $(append_ios_arch_args)
130+
PROFILE=e2e-ios-simulator \
131+
EXPO_PUBLIC_E2E_ENV_PROFILE="${EXPO_PUBLIC_E2E_ENV_PROFILE:-}" \
132+
EXPO_PUBLIC_E2E_LANGUAGE="${EXPO_PUBLIC_E2E_LANGUAGE:-en}" \
133+
xcodebuild -workspace Folo.xcworkspace \
134+
-scheme Folo \
135+
-configuration Release \
136+
-sdk iphonesimulator \
137+
-destination "id=${device_id}" \
138+
build \
139+
"$@"
140+
)
141+
142+
find "$HOME/Library/Developer/Xcode/DerivedData" -path '*Build/Products/Release-iphonesimulator/Folo.app' | head -n1
143+
}
144+
145+
run_ios_bootstrap_auth() {
146+
device_id="$1"
147+
148+
case "${EXPO_PUBLIC_E2E_ENV_PROFILE:-prod}" in
149+
prod|local)
150+
pnpm run e2e:bootstrap:ios:prod-auth -- --udid "${device_id}"
151+
;;
152+
*)
153+
maestro test --format junit --platform ios --device "${device_id}" --debug-output "${debug_output}/bootstrap-auth" \
154+
-e E2E_EMAIL="${E2E_EMAIL}" -e E2E_PASSWORD="${E2E_PASSWORD}" e2e/flows/ios/register.yaml
155+
;;
156+
esac
157+
}
158+
109159
case "${platform}" in
110160
ios)
111161
device_id="$(resolve_ios_device)"
@@ -114,7 +164,7 @@ case "${platform}" in
114164
exit 1
115165
fi
116166

117-
app_path="$(resolve_ios_app_path)"
167+
app_path="$(resolve_ios_app_path "${device_id}")"
118168
if [ -z "${app_path}" ] || [ ! -d "${app_path}" ]; then
119169
echo "Unable to resolve a built iOS .app bundle. Set MAESTRO_IOS_APP_PATH or place a build-*.tar.gz in apps/mobile." >&2
120170
exit 1
@@ -124,8 +174,19 @@ case "${platform}" in
124174
xcrun simctl install "${device_id}" "${app_path}" >/dev/null 2>&1 || true
125175
xcrun simctl launch "${device_id}" is.follow >/dev/null 2>&1 || true
126176

127-
maestro test --format junit --platform ios --device "${device_id}" --debug-output "${debug_output}/auth" \
128-
-e E2E_EMAIL="${E2E_EMAIL}" -e E2E_PASSWORD="${E2E_PASSWORD}" e2e/flows/ios/auth.yaml
177+
case "${mode}" in
178+
full)
179+
maestro test --format junit --platform ios --device "${device_id}" --debug-output "${debug_output}/auth" \
180+
-e E2E_EMAIL="${E2E_EMAIL}" -e E2E_PASSWORD="${E2E_PASSWORD}" e2e/flows/ios/auth.yaml
181+
;;
182+
bootstrap-auth)
183+
run_ios_bootstrap_auth "${device_id}"
184+
;;
185+
*)
186+
echo "Unsupported iOS runner mode: ${mode}" >&2
187+
exit 1
188+
;;
189+
esac
129190

130191
;;
131192
android)

apps/mobile/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
"bump": "vv",
99
"dev": "npm run start",
1010
"e2e:android": "sh ./e2e/run-maestro.sh android",
11+
"e2e:bootstrap:ios:auth": "tsx scripts/e2e-prod-ios-auth-bootstrap.ts",
12+
"e2e:bootstrap:ios:prod-auth": "pnpm run e2e:bootstrap:ios:auth",
1113
"e2e:doctor": "sh -c 'for f in e2e/flows/shared/*.yaml e2e/flows/android/*.yaml e2e/flows/ios/*.yaml; do maestro check-syntax $f; done'",
1214
"e2e:ios": "sh ./e2e/run-maestro.sh ios",
15+
"e2e:ios:bootstrap": "sh ./e2e/run-maestro.sh ios bootstrap-auth",
1316
"eas-build-post-install": "rm -rf $TMPDIR/metro-cache",
1417
"eas-build-pre-install": "command -v pod >/dev/null 2>&1 && pod repo update || echo 'CocoaPods not found, skipping pod repo update'",
1518
"ios": "expo run:ios",

0 commit comments

Comments
 (0)