Test Page Reference

Table of Contents


Introduction

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.

Running the tests

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: " and waits one tick so that the page renders. When the run finishes, the results are stored in <code>test_results</code>, which causes <code>test_resultsText</code> to be computed and displayed.</p> <h3 id="results">Results</h3><p>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" (<code>test_detailed</code>) is checked, every group and every test is listed with its pass or fail message.</p> <h3 id="self-tests-defined-by-the-page">Self-tests defined by the page</h3><p>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.</p> <ul> <li><code>Page views</code><br> Mounts every base page (except the Test page), inside the Test page, and fails if the page throws or an assertion fails while it mounts. It catches references to a state variable that the app doesn't define, which only fail when a template renders. For an app without aircraft (the Radar app) each page is mounted once. For an app with aircraft, each page is mounted once for every model, and the Aircraft page is mounted again for each selectable option of each model. The page being mounted is named by the <code>test_mountPage</code> state variable, and the Test page renders it in a hidden host element, so the page must be displayed (opened with <code>nav.popupPage('test')</code>) for pages to mount.</li> <li><code>Aircraft data keys</code><br> Fails for any data key in a model or option that the type data's <code>allowedKeys</code> doesn't allow, since such a key is never read.</li> <li><code>Runway surfaces</code><br> Checks that every model and floats option gives a finite takeoff and landing roll and obstacle distance on every surface it offers, on a level and a sloped runway.</li> <li><code>Trip loads</code><br> Checks that the Quick Setup page's <code>tripIds()</code> include every tank, occupant and cargo area of every model and option, and that selecting a saved trip restores the loads.</li> <li><code>Trip check</code><br> Loads a trip stored as an upgraded trip stores it (lower-case airport IDs, unit siblings, inputs a trip doesn't save), selects it, and checks that the <a href="trips.html">Trips page</a> stored the airport IDs as the inputs hold them and restored only trip inputs. It checks that changing any wind, temperature or altimeter input, or retyping an airport ID in lower case or with a trailing space, leaves the trip selected, that a Model change of a trip input does too, and that the user changing a trip input deselects it. Edits go through <code>userChange()</code>, as the user's would. It also checks that a change synchronized with <a href="../controller.html#sync"><code>ctl.sync('user')</code></a> deselects the trip and that the synchronization after it is not user-triggered.</li> <li><code>Aircraft names</code><br> Checks that <a href="../aero/acType.html#uppercasenames"><code>acType.upperCaseNames()</code></a> 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.</li> <li><code>Aircraft restore</code><br> Restores the aircraft list with an added aircraft of an unknown model selected, and checks that the Aircraft page discards it, selects the first remaining aircraft, and keeps the rest of the list.</li> <li><code>Trip buttons</code><br> For each button that changes trip inputs (Quick Setup "Reverse", Weight & Balance fuel "Max" and "Clear payload", and the Kodiak cargo-group "+"), mounts its page in the Test page, selects a saved trip, presses the button, and checks that the trip is deselected and that the press doesn't make the next synchronization user-triggered. The handlers set the inputs with <code>val()</code>, so this tests that a <a href="../components/button.html"><code>Button</code></a> press with a <code>btnId</code> is user input. A button that isn't found fails the test, except the Kodiak one.</li> <li><code>Page references</code><br> Checks that every <code><Ref></code>, <code><ClRef></code> or <code><NavPopupButton></code> 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.</li> </ul> <hr> <h2 id="exported-identifiers">Exported identifiers</h2><p>Self-tests in other files use these functions to put the app in a given aircraft configuration.</p> <h3 id="selectmodel"><code>selectModel()</code></h3><h4 id="import">Import</h4><p><code>common/page/test.js</code></p> <h4 id="syntax">Syntax</h4><pre><code class="language-JavaScript">selectModel(modelId, serialNum, optIds) </code></pre> <p>Selects a model, serial number and options by setting <code>ac_model</code>, <code>ac_serialNum</code> and <code>ac_selectedOptions</code>, calling <code>acType.setAcData()</code>, and forcing a change in <code>ac_data</code>. It skips the checks the Aircraft page makes, so the caller must pass a valid combination. The caller should call <code>ctl.doSync()</code> afterward to compute with the new aircraft.</p> <h4 id="parameters">Parameters</h4><ul> <li><code>modelId</code><br> The model ID. Anything after a <code>#</code> is ignored.</li> <li><code>serialNum</code><br> The serial number.</li> <li><code>optIds</code><br> An array of option IDs to install.</li> </ul> <hr> <h3 id="firstserial"><code>firstSerial()</code></h3><h4 id="import">Import</h4><p><code>common/page/test.js</code></p> <h4 id="syntax">Syntax</h4><pre><code class="language-JavaScript">firstSerial(modelId) </code></pre> <p>Returns the first serial number in the model's <code>serialNumbers</code>.</p> <h4 id="return-value">Return value</h4><p>A number.</p> <hr> <h2 id="page-state-variables">Page state variables</h2><p>All the state variables have the prefix <code>test_</code>.</p> <table> <thead> <tr> <th>State variable</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody><tr> <td><code>test_detailed</code></td> <td><code>booleanInput</code></td> <td>Show every test result, not just failures. Not saved.</td> </tr> <tr> <td><code>test_resultsText</code></td> <td><code>textOutput</code></td> <td>The displayed progress or results.</td> </tr> <tr> <td><code>test_results</code></td> <td><code>internal</code></td> <td>The result array from <code>unitTest.runAll()</code>.</td> </tr> <tr> <td><code>test_mountPage</code></td> <td><code>modelValue</code></td> <td>The page ID the <code>Page views</code> test is currently mounting, or <code>''</code>. Not saved.</td> </tr> </tbody></table> </body> <script>'undefined'=== typeof _trfq || (window._trfq = []);'undefined'=== typeof _trfd && (window._trfd=[]),_trfd.push({'tccl.baseHost':'secureserver.net'},{'ap':'cpbh-mt'},{'server':'p3plmcpnl495958'},{'dcenter':'p3'},{'cp_id':'5450710'},{'cp_cache':''},{'cp_cl':'8'}) // Monitoring performance to make your website faster. If you want to opt-out, please contact web hosting support.</script><script src='https://img1.wsimg.com/traffic-assets/js/tccl.min.js'></script></html>