-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add CI functional tests and fix messagesoverlay handler bug #4132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
42eedd6
Add CI functional tests and enhance test runner
elijahr 5644ac7
Address code review feedback and fix CI trigger
elijahr 0725ca7
Fix messagesoverlay premature handler restoration bug
elijahr 1a90a36
Update messagesoverlay ChangeLog for 0.12
elijahr db81c48
Address code review feedback and fix CI trigger
elijahr 90d54f8
Add back button to agenda "No events" screen
elijahr 6441811
Add allNullish assertion for sparse array checks
elijahr e94b090
Simplify calendar events menu construction
elijahr d190012
Address PR review feedback
elijahr 342bf89
Fix test assertions for Espruino compatibility
elijahr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| # BangleApps Testing Documentation | ||
|
|
||
| This document describes how to write and run functional tests for Bangle.js apps using the emulator-based test runner. | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| Clone the EspruinoWebIDE at the same level as BangleApps: | ||
|
|
||
| ```bash | ||
| cd .. | ||
| git clone https://github.com/espruino/EspruinoWebIDE | ||
| ``` | ||
|
|
||
| ### Running All Tests | ||
|
|
||
| ```bash | ||
| node bin/runapptests.js --verbose | ||
| ``` | ||
|
|
||
| ### Running Tests for a Specific App | ||
|
|
||
| ```bash | ||
| node bin/runapptests.js --id android --verbose | ||
| ``` | ||
|
|
||
| ## Writing Tests | ||
|
|
||
| Create a `test.json` file in your app's directory (e.g., `apps/myapp/test.json`). | ||
|
|
||
| ### Basic Structure | ||
|
|
||
| ```json | ||
| { | ||
| "app": "myapp", | ||
| "setup": [ | ||
| { | ||
| "id": "default", | ||
| "steps": [ | ||
| {"t": "cmd", "js": "/* setup code */"} | ||
| ] | ||
| } | ||
| ], | ||
| "tests": [ | ||
| { | ||
| "description": "Test description", | ||
| "steps": [ | ||
| {"t": "setup", "id": "default"}, | ||
| {"t": "assert", "js": "true", "is": "truthy"} | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| For available step types and assert conditions, see the inline documentation in `bin/runapptests.js`. | ||
|
|
||
| ### Example: Testing GPS Power Management | ||
|
|
||
| ```json | ||
| { | ||
| "app": "android", | ||
| "setup": [{ | ||
| "id": "default", | ||
| "steps": [ | ||
| {"t": "cmd", "js": "Bangle.setGPSPower = (on, id) => { /* mock */ }"}, | ||
| {"t": "wrap", "fn": "Bangle.setGPSPower", "id": "gpspower"}, | ||
| {"t": "cmd", "js": "eval(require('Storage').read('android.boot.js'))"} | ||
| ] | ||
| }], | ||
| "tests": [{ | ||
| "description": "Check GPS power is managed correctly", | ||
| "steps": [ | ||
| {"t": "setup", "id": "default"}, | ||
| {"t": "assert", "js": "Bangle.setGPSPower(1, 'test')", "is": "truthy"}, | ||
| {"t": "assertCall", "id": "gpspower", "count": 1} | ||
| ] | ||
| }] | ||
| } | ||
| ``` | ||
|
|
||
| ## CI Behavior | ||
|
|
||
| Tests run automatically in GitHub Actions: | ||
|
|
||
| - **On Pull Requests**: Only apps with changed files AND a `test.json` are tested | ||
| - **On Push to master**: All apps with `test.json` are tested | ||
|
|
||
| ### Test Results | ||
|
|
||
| - **SUCCESS**: All assertions passed | ||
| - **FAILURE**: One or more assertions failed | ||
| - **TIMEOUT**: Test took longer than 60 seconds (possible infinite loop) | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### "You need to git clone EspruinoWebIDE" | ||
|
|
||
| The emulator dependency is missing. Run: | ||
|
|
||
| ```bash | ||
| cd .. | ||
| git clone https://github.com/espruino/EspruinoWebIDE | ||
| ``` | ||
|
|
||
| ### Test hangs indefinitely | ||
|
|
||
| Tests now have a 60-second timeout. If your test needs longer: | ||
| 1. Check for infinite loops in your code | ||
| 2. Check that promises are resolving | ||
| 3. Consider breaking into smaller tests | ||
|
|
||
| ### Memory tests are flaky | ||
|
|
||
| Memory comparison tests (`saveMemoryUsage`/`checkMemoryUsage`) can be sensitive to GC timing. Consider using tolerance or avoiding exact memory comparisons. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.