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 two self-tests that apply to any app:
Page viewstest_mountPage state variable, and the Test page renders it in a hidden host element.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.
import {selectModel, firstSerial} from 'common/page/test.js';
selectModel()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()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. |