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 two self-tests that apply to any app:</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.</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> <pre><code class="language-JavaScript">import {selectModel, firstSerial} from 'common/page/test.js'; </code></pre> <h3 id="selectmodel"><code>selectModel()</code></h3><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="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>