The Test page (page ID test, title "Self-test") runs the app's self-test when it is opened and displays the results. It is defined in common/page/test.js. Every aircraft app and the Radar app imports it for its side effect:
import './common/page/test.js';
The page is a popup page. The developer card of the Settings page opens it with nav.popupPage('test'). An app can open it the same way from anywhere else. The test suites themselves are registered by many files with unitTest.create(); see the unitTest Reference.
When the page opens, it clears the previous results and shows "Running tests...". It then runs every registered test with unitTest.runAll(), using a progress callback that updates the results text to "N% Running test:
test_results, which causes test_resultsText to be computed and displayed.
By default the page shows only "All tests passed" or, if any test failed, a "Failed tests" list with the failing assertions under each group. When "Show detailed results" (test_detailed) is checked, every group and every test is listed with its pass or fail message.
The page's file defines self-tests that apply to any app. The aircraft data, runway and trip tests return at once in an app without aircraft.
Page viewstest_mountPage state variable, and the Test page renders it in a hidden host element, so the page must be displayed (opened with nav.popupPage('test')) for pages to mount.Aircraft data keysallowedKeys doesn't allow, since such a key is never read.Runway surfacesTrip loadstripIds() include every tank, occupant and cargo area of every model and option, and that selecting a saved trip restores the loads.Trip checkuserChange(), as the user's would. It also checks that a change synchronized with ctl.sync('user') deselects the trip and that the synchronization after it is not user-triggered.Aircraft namesacType.upperCaseNames() stores typed aircraft names in upper case, keeps a name already in upper case, gives a name that then matches another a suffix, and renames the selected aircraft.Aircraft restoreTrip buttonsval(), so this tests that a Button press with a btnId is user input. A button that isn't found fails the test, except the Kodiak one.Page references<Ref>, <ClRef> or <NavPopupButton> in the help topics, page tips, and page templates names a page or help topic that the app has, and that every help table of contents entry is a defined topic. Content that a template builds with a function is not reached.Self-tests in other files use these functions to put the app in a given aircraft configuration.
selectModel()common/page/test.js
selectModel(modelId, serialNum, optIds)
Selects a model, serial number and options by setting ac_model, ac_serialNum and ac_selectedOptions, calling acType.setAcData(), and forcing a change in ac_data. It skips the checks the Aircraft page makes, so the caller must pass a valid combination. The caller should call ctl.doSync() afterward to compute with the new aircraft.
modelId# is ignored.serialNumoptIdsfirstSerial()common/page/test.js
firstSerial(modelId)
Returns the first serial number in the model's serialNumbers.
A number.
All the state variables have the prefix test_.
| State variable | Type | Description |
|---|---|---|
test_detailed |
booleanInput |
Show every test result, not just failures. Not saved. |
test_resultsText |
textOutput |
The displayed progress or results. |
test_results |
internal |
The result array from unitTest.runAll(). |
test_mountPage |
modelValue |
The page ID the Page views test is currently mounting, or ''. Not saved. |