Skip to content

Commit 0920dfc

Browse files
chore: address flaky tests
1 parent ef5d8cc commit 0920dfc

6 files changed

Lines changed: 47 additions & 9 deletions

File tree

.github/scripts/determine-widget-scope.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ all_widgets=$(echo "$widget_dirs" | jq -R -s -c 'split("\n") | map(select(length
1919
all_widgets_and_js=$(echo "$widget_dirs" | jq -R -s -c 'split("\n") | map(select(length > 0)) + ["mobile-resources-native", "nanoflow-actions-native"]')
2020

2121
# Convert a space-separated list of widget names into a JSON array (or [] when empty).
22+
# Deduplicates entries as a safety measure.
2223
to_json_array() {
2324
if [[ -z "$1" ]]; then
2425
echo "[]"
2526
else
26-
echo "[\"$(echo "$1" | sed 's/ /","/g')\"]"
27+
# Sort and deduplicate, then convert to JSON array
28+
echo "$1" | tr ' ' '\n' | sort -u | jq -R -s -c 'split("\n") | map(select(length > 0))'
2729
fi
2830
}
2931

@@ -54,15 +56,16 @@ if [ "$event_name" == "pull_request" ]; then
5456
if [[ $file == packages/pluggableWidgets/* ]]; then
5557
widget=$(echo $file | cut -d'/' -f3)
5658
subdir=$(echo $file | cut -d'/' -f4)
57-
if [[ ! $selected_workspaces =~ $widget ]]; then
59+
# Use word boundary check to prevent both duplicates and substring false matches
60+
if [[ ! " $selected_workspaces " =~ " $widget " ]]; then
5861
selected_workspaces="$selected_workspaces $widget"
5962
fi
6063
# A change confined to the widget's e2e/ folder (Maestro flows + screenshots) changes
6164
# only the TEST, not the built artifact — so it should NOT trigger a rebuild. The widget
6265
# still goes into selected_workspaces above (it gets TESTED), but it's kept out of the
6366
# BUILD scope; its .mpk comes from the test project's committed baseline, exactly like
6467
# every other not-rebuilt widget in a partial run.
65-
if [[ "$subdir" != "e2e" ]] && [[ ! $build_workspaces =~ $widget ]]; then
68+
if [[ "$subdir" != "e2e" ]] && [[ ! " $build_workspaces " =~ " $widget " ]]; then
6669
build_workspaces="$build_workspaces $widget"
6770
fi
6871
elif [[ $file == packages/jsActions/mobile-resources-native/* ]] || [[ $file == packages/jsActions/nanoflow-actions-native/* ]]; then

maestro/Smoke.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ appId: "${APP_ID}"
22
---
33
# Fast-fail smoke check (S6). Run ONCE per shard before any widget flows: if the app can't
44
# launch and render the "Widgets menu", the build/bundle is fundamentally broken and every
5-
# flow would fail the same way. Bail in ~1.5 min instead of grinding 8-9 flows × retries up
6-
# to the job timeout. Short timeout + NO retry block on purpose — this is the cheap probe.
5+
# flow would fail the same way. Bail in ~2 min instead of grinding 8-9 flows × retries up
6+
# to the job timeout. Timeout was 60s but gallery-native on Android needs extra time for
7+
# initial asset loading. 90s gives room while still being a fast-fail probe.
78
- launchApp:
89
clearState: true
910
permissions:
1011
camera: allow
1112
notifications: allow
1213
- extendedWaitUntil:
1314
visible: "Widgets menu"
14-
timeout: 60000
15+
timeout: 90000

maestro/helpers/helpers.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,28 @@ ensure_emulator_ready() {
136136
done
137137
}
138138

139+
# Function to verify Mendix runtime is responding (Android only - uses adb reverse)
140+
verify_runtime_ready() {
141+
if [ "$PLATFORM" != "android" ]; then
142+
return 0 # iOS doesn't need this check - runtime is on localhost
143+
fi
144+
local max_attempts=10
145+
local attempt=1
146+
echo "Verifying Mendix runtime connectivity..."
147+
while [ "$attempt" -le "$max_attempts" ]; do
148+
# Use adb to check if localhost:8080 is reachable from the emulator's perspective
149+
if adb shell "curl -s -o /dev/null -w '%{http_code}' http://localhost:8080/" 2>/dev/null | grep -q "200\|302"; then
150+
echo "✅ Runtime is reachable from emulator (attempt $attempt)"
151+
return 0
152+
fi
153+
echo "Runtime not ready yet (attempt $attempt/$max_attempts), waiting..."
154+
sleep 3
155+
attempt=$((attempt + 1))
156+
done
157+
echo "⚠️ Runtime verification timed out - proceeding anyway (app will handle connection errors)"
158+
return 0 # Don't fail hard - let the app/smoke check handle it
159+
}
160+
139161
# Function to run tests
140162
run_tests() {
141163
local test_files=("$@")
@@ -178,6 +200,7 @@ smoke_check() {
178200
if [ "$PLATFORM" == "android" ]; then
179201
ensure_emulator_ready
180202
set_status_bar
203+
verify_runtime_ready # Ensure runtime is reachable before launching app
181204
fi
182205
start_recording "smoke-attempt-$attempt"
183206
if $HOME/.local/bin/maestro/bin/maestro test --env APP_ID=$APP_ID --env PLATFORM=$PLATFORM --env MAESTRO_DRIVER_STARTUP_TIMEOUT=$MAESTRO_DRIVER_STARTUP_TIMEOUT "$script_dir/Smoke.yaml"; then

packages/pluggableWidgets/bottom-sheet-native/e2e/specs/maestro/Botton_sheet_expanding_fullscreen.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ appId: "${APP_ID}"
88
text: "Bottom Sheet"
99
- tapOn:
1010
text: "Expanding fullscreen"
11-
# Because the image loading can take some time due to resources on emulator, we need to wait for the image to be visible
12-
- extendedWaitUntil:
11+
# Because the image loading and animation can take some time due to resources on emulator, we need to wait
12+
- extendedWaitUntil:
1313
visible: randText # Any random text that does not exist in the UI
1414
optional: true # This should be true so that the test won't fail
15-
timeout: 10000 # 10 seconds
15+
timeout: 15000 # 15 seconds to allow for animation to complete
1616
- takeScreenshot:
1717
path: "maestro/images/actual/${PLATFORM}/bottom_sheet_expanding_fullscreen"
1818
- assertScreenshot:

packages/pluggableWidgets/bottom-sheet-native/e2e/specs/maestro/Modal_basic_non_native.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ appId: "${APP_ID}"
88
text: "Bottom Sheet"
99
- tapOn:
1010
text: "Modal basic non native"
11+
# Wait for the page to fully load before tapping Open
12+
- extendedWaitUntil:
13+
visible: "Open"
14+
timeout: 10000
1115
- tapOn:
1216
text: "Open"
1317

packages/pluggableWidgets/intro-screen-native/e2e/specs/maestro/IntroScreen.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ appId: "${APP_ID}"
4747
timeout: 5000
4848
- tapOn:
4949
text: "NEXT"
50+
# Wait for slide transition to complete and FINISH button to appear
51+
- extendedWaitUntil:
52+
visible: "Active slide: 3"
53+
timeout: 5000
54+
- extendedWaitUntil:
55+
visible: "FINISH"
56+
timeout: 5000
5057
- tapOn:
5158
text: "FINISH"
5259
- extendedWaitUntil:

0 commit comments

Comments
 (0)