Skip to content

Commit 287956e

Browse files
rtibblesclaude
andcommitted
Add Maestro smoke test for app launch verification
Enable WebView debugging in debug builds so Maestro can inspect WebView content via devtools. Add a minimal smoke test flow that launches the app and waits for visible content. Add Makefile targets for installing Maestro and running smoke tests, and a CI job that boots an emulator and runs the smoke test against the built APK. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fad778d commit 287956e

5 files changed

Lines changed: 94 additions & 0 deletions

File tree

.github/workflows/build_and_test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,45 @@ jobs:
9393
path: tar
9494
- name: Run unit tests
9595
run: ./gradlew test
96+
97+
smoke_test:
98+
name: Smoke test
99+
needs: [pre_job, build_apk]
100+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v6
104+
- name: Set up JDK 17
105+
uses: actions/setup-java@v4
106+
with:
107+
distribution: 'temurin'
108+
java-version: '17'
109+
- name: Install Maestro CLI
110+
run: make maestro-install
111+
- name: Add Maestro to PATH
112+
run: echo "$HOME/.maestro/bin" >> $GITHUB_PATH
113+
- name: Enable KVM
114+
run: |
115+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
116+
sudo udevadm control --reload-rules
117+
sudo udevadm trigger --name-match=kvm
118+
- name: Download APK artifact
119+
uses: actions/download-artifact@v7
120+
with:
121+
name: ${{ needs.build_apk.outputs.apk-file-name }}
122+
path: dist
123+
- name: Run smoke test
124+
uses: reactivecircus/android-emulator-runner@v2
125+
with:
126+
api-level: 30
127+
arch: x86_64
128+
target: google_apis
129+
script: |
130+
adb install -r dist/*.apk
131+
make smoke-test
132+
- name: Upload Maestro debug output
133+
if: always()
134+
uses: actions/upload-artifact@v6
135+
with:
136+
name: maestro-debug-output
137+
path: ~/.maestro/tests/

.maestro/smoke.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
appId: org.learningequality.Kolibri
2+
androidWebViewHierarchy: devtools
3+
---
4+
# Launch app and wait for the setup wizard to load
5+
- launchApp
6+
- extendedWaitUntil:
7+
visible: "How are you using Kolibri?"
8+
timeout: 120000
9+
10+
# Dismiss notification permission dialog if it appears
11+
- tapOn:
12+
text: "ALLOW"
13+
optional: true
14+
15+
# Step 1: "How are you using Kolibri?" — "On my own" is pre-selected
16+
- tapOn: "CONTINUE"
17+
18+
# Step 2: "Please select the default language" — English is pre-selected
19+
- extendedWaitUntil:
20+
visible: "Please select the default language for Kolibri"
21+
timeout: 10000
22+
- tapOn: "CONTINUE"
23+
24+
# Verify we reach the main app (Library page)
25+
- extendedWaitUntil:
26+
visible: "Your library"
27+
timeout: 30000

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ repos:
1313
hooks:
1414
- id: trailing-whitespace
1515
- id: check-yaml
16+
args: ['--allow-multiple-documents']
1617
- id: check-added-large-files
1718
- id: debug-statements
1819
- id: end-of-file-fixer

Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,24 @@ list-avds:
195195
clean-tools:
196196
rm -rf $(SDK)
197197

198+
# =============================================================================
199+
# Maestro Smoke Testing
200+
# =============================================================================
201+
202+
MAESTRO_VERSION := 2.1.0
203+
MAESTRO := $(HOME)/.maestro/bin/maestro
204+
205+
$(MAESTRO):
206+
@echo "Installing Maestro $(MAESTRO_VERSION)..."
207+
MAESTRO_VERSION=$(MAESTRO_VERSION) curl -fsSL "https://get.maestro.mobile.dev" | bash
208+
209+
.PHONY: maestro-install
210+
maestro-install: $(MAESTRO)
211+
212+
.PHONY: smoke-test
213+
smoke-test: maestro-install
214+
$(MAESTRO) test .maestro/
215+
198216
# =============================================================================
199217
# Logging
200218
# =============================================================================
@@ -230,6 +248,8 @@ help:
230248
@echo " test - Run unit tests"
231249
@echo " lint - Run Android linter"
232250
@echo " clean - Clean build artifacts"
251+
@echo " maestro-install - Install Maestro CLI"
252+
@echo " smoke-test - Run Maestro smoke tests (requires running emulator + installed APK)"
233253
@echo ""
234254
@echo "SDK & Emulator Setup:"
235255
@echo " setup - Complete setup (SDK + system image + AVD)"

app/src/main/java/org/learningequality/Kolibri/WebViewActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public void handleOnBackPressed() {
8181
}
8282

8383
private void setupWebView() {
84+
if (BuildConfig.DEBUG) {
85+
WebView.setWebContentsDebuggingEnabled(true);
86+
}
87+
8488
WebView webView = findViewById(R.id.webview);
8589
fullscreenContainer = findViewById(R.id.fullscreen_container);
8690
splashImage = findViewById(R.id.splash_image);

0 commit comments

Comments
 (0)