Skip to content

Modular logistics and supply chain operating system (LSOS)

test(console): reach 100% coverage and make the CI gate blocking

Ronald A. Richardson11bc1756a184
diff --git a/.github/workflows/console.yml b/.github/workflows/console.yml
index fcf6f890..6929eb2f 100644
--- a/.github/workflows/console.yml
+++ b/.github/workflows/console.yml
@@ -86,28 +86,22 @@ jobs:
name: console-coverage
fail_ci_if_error: false
- # Coverage gate — reports the numbers, does not block this release.
+ # Coverage gate — blocking.
#
- # Measured locally at 577/577 passing:
- # lines 70.02% · statements 69.84% · functions 68.69% · branches 71.54%
- # scripts/coverage-check.mjs applies the threshold to ALL FOUR metrics, so
- # functions is the binding constraint — 70 would fail today despite lines
- # being at 70.02%. 65 is the floor the suite comfortably holds.
+ # The console suite is at 100% on all four metrics (lines, statements,
+ # functions and branches) with 1149 tests passing. scripts/coverage-check.mjs
+ # applies the threshold to all four, so this fails the build if any of them
+ # regresses.
#
- # Deliberately still continue-on-error. Coverage produced no report at all
- # until recently (no babel instrumentation, no sendCoverage hook, and a
- # scoped-modulePrefix path mismatch dropping every file), and the Lint step
- # ahead of it was failing, so this gate has never once evaluated real data in
- # CI. Watch one green run before making it blocking.
- #
- # 100% remains the long-term target but is deferred: several files cannot be
- # covered as written — four use later(() => window.location.reload()), and
- # report.js has static methods calling getOwner() on the class, which returns
- # undefined. Reaching 100% needs those addressed (an injectable reload,
- # repairing or removing the dead statics) rather than more tests.
+ # A handful of lines are excluded or marked rather than tested, each with the
+ # reason written at the site: window.location.reload() cannot be stubbed
+ # (Location members are non-configurable per spec) so its five callers route
+ # through a one-line reloadWindow()/reloadConsole() wrapper; a few guards are
+ # unreachable given their callers; and app/resolver.js is excluded outright in
+ # config/coverage.js because nothing imports it and it would throw if it were
+ # wired up.
- name: Report coverage threshold
- continue-on-error: true
- run: pnpm run coverage:check -- --fail-under=65
+ run: pnpm run coverage:check -- --fail-under=100
- name: Build (production)
run: npx ember build --environment production
diff --git a/console/app/components/configure/filesystem.js b/console/app/components/configure/filesystem.js
index cf7a3d87..0775eea9 100644
--- a/console/app/components/configure/filesystem.js
+++ b/console/app/components/configure/filesystem.js
@@ -7,6 +7,9 @@ export default class ConfigureFilesystemComponent extends Component {
@service fetch;
@service notifications;
@service currentUser;
+ // The constructor performs loadConfigValues, which assigns this before anything can read it,
+ // so the initializer below never runs.
+ /* istanbul ignore next -- always assigned before first read */
@tracked isLoading = false;
@tracked testResponse;
@tracked disks = [];
diff --git a/console/app/components/configure/notification-channels.js b/console/app/components/configure/notification-channels.js
index 8aa8071a..216e9f0d 100644
--- a/console/app/components/configure/notification-channels.js
+++ b/console/app/components/configure/notification-channels.js
@@ -7,6 +7,9 @@ export default class ConfigureNotificationChannelsComponent extends Component {
@service fetch;
@service notifications;
@service currentUser;
+ // The constructor performs loadConfigValues, which assigns this before anything can read it,
+ // so the initializer below never runs.
+ /* istanbul ignore next -- always assigned before first read */
@tracked isLoading = false;
@tracked testResponse;
@tracked testTitle = 'Hello World from Fleetbase 🚀';
diff --git a/console/app/components/configure/queue.js b/console/app/components/configure/queue.js
index 6f8cfe1f..f87fe031 100644
--- a/console/app/components/configure/queue.js
+++ b/console/app/components/configure/queue.js
@@ -6,6 +6,9 @@ import { action } from '@ember/object';
export default class ConfigureQueueComponent extends Component {
@service fetch;
@service notifications;
+ // The constructor performs loadConfigValues, which assigns this before anything can read it,
+ // so the initializer below never runs.
+ /* istanbul ignore next -- always assigned before first read */
@tracked isLoading = false;
@tracked testResponse;
@tracked connections = [];
diff --git a/console/app/components/configure/services.js b/console/app/components/configure/services.js
index e1889ad3..7e517e35 100644
--- a/console/app/components/configure/services.js
+++ b/console/app/components/configure/services.js
@@ -354,7 +354,9 @@ export default class ConfigureServicesComponent extends Component {
}
syncSmsJsonText() {
- const customHttpConfig = this.normalizedSms.providers.custom_http || {};
+ // normalizeSmsConfig() always builds a custom_http provider, so there is nothing to
+ // fall back to here.
+ const customHttpConfig = this.normalizedSms.providers.custom_http;
this.customHttpHeadersText = JSON.stringify(customHttpConfig.headers || {}, null, 2);
this.customHttpQueryParamsText = JSON.stringify(customHttpConfig.query_params || {}, null, 2);
this.customHttpBodyText = JSON.stringify(
diff --git a/console/app/components/dashboard/metric.js b/console/app/components/dashboard/metric.js
index a39fe6e6..bf04bce0 100644
--- a/console/app/components/dashboard/metric.js
+++ b/console/app/components/dashboard/metric.js
@@ -7,6 +7,9 @@ import { task } from 'ember-concurrency';
export default class MetricComponent extends Component {
@service fetch;
+ // The constructor performs loadDashboard, which assigns this before anything can read it,
+ // so the initializer below never runs.
+ /* istanbul ignore next -- always assigned before first read */
@tracked isLoading = false;
@tracked dashboard;
diff --git a/console/app/components/modals/validate-password.js b/console/app/components/modals/validate-password.js
index 82ec4694..ab82f455 100644
--- a/console/app/components/modals/validate-password.js
+++ b/console/app/components/modals/validate-password.js
@@ -6,6 +6,9 @@ import { task } from 'ember-concurrency';
export default class ModalsValidatePasswordComponent extends Component {
@service fetch;
@service notifications;
+ // The constructor assigns the modal's options straight away, so this initializer
+ // never runs.
+ /* istanbul ignore next -- always assigned before first read */
@tracked options = {};
@tracked password;
@tracked confirmPassword;
diff --git a/console/app/initializers/load-runtime-config.js b/console/app/initializers/load-runtime-config.js
index 45b4be25..89f1b5a8 100644
--- a/console/app/initializers/load-runtime-config.js
+++ b/console/app/initializers/load-runtime-config.js
@@ -24,8 +24,6 @@ export function initialize(application) {
const endTime = performance.now();
debug(`[Runtime Config] Runtime config loaded in ${(endTime - startTime).toFixed(2)}ms`);
application.advanceReadiness();
- /* istanbul ignore next -- loadRuntimeConfig catches every failure internally, so
- this outer guard cannot fire; it exists only in case that ever stops being true */
} catch (error) {
console.error('[Runtime Config] Failed to load runtime config:', error);
// Still advance readiness to prevent hanging
diff --git a/console/app/instance-initializers/apply-router-fix.js b/console/app/instance-initializers/apply-router-fix.js
index e0cc8237..7b9517d5 100644
--- a/console/app/instance-initializers/apply-router-fix.js
+++ b/console/app/instance-initializers/apply-router-fix.js
@@ -25,9 +25,9 @@ export function initialize(appInstance) {
const endTime = performance.now();
debug(`[Initializing Router Patch] Router fix applied in ${(endTime - startTime).toFixed(2)}ms`);
+ } catch (error) {
/* istanbul ignore next -- applyRouterFix catches every failure internally, so this
outer guard cannot fire; it exists only in case that ever stops being true */
- } catch (error) {
console.error('[Initializing Router Patch] Failed to apply router fix:', error);
}
}
diff --git a/console/app/serializers/category.js b/console/app/serializers/category.js
index ae8d7b20..908d1b29 100644
--- a/console/app/serializers/category.js
+++ b/console/app/serializers/category.js
@@ -36,6 +36,7 @@ export default class CategorySerializer extends ApplicationSerializer.extend(Emb
return;
}
+ /* istanbul ignore next -- unreachable for the same reason as the else above */
return super.serializeHasMany(...arguments);
}
}
diff --git a/console/app/serializers/dashboard.js b/console/app/serializers/dashboard.js
index cc8ca993..de169f2e 100644
--- a/console/app/serializers/dashboard.js
+++ b/console/app/serializers/dashboard.js
@@ -17,6 +17,7 @@ export default class DashboardSerializer extends ApplicationSerializer.extend(Em
return;
}
+ /* istanbul ignore next -- unreachable for the same reason as the else above */
return super.serializeHasMany(...arguments);
}
}
diff --git a/console/app/serializers/user.js b/console/app/serializers/user.js
index d0f3c04d..fda94647 100644
--- a/console/app/serializers/user.js
+++ b/console/app/serializers/user.js
@@ -26,7 +26,9 @@ export default class UserSerializer extends ApplicationSerializer.extend(Embedde
let existing = this.store.peekRecord(normalized.data.type, normalized.data.id);
if (existing) {
- let attrs = normalized.data.attributes || {};
+ // normalize() always produces an attributes hash, and `for...in` over an absent
+ // one would be a no-op anyway.
+ let attrs = normalized.data.attributes;
for (let key in attrs) {
if (attrs[key] === null || attrs[key] === undefined || key === 'avatar_url') {
diff --git a/console/tests/unit/initializers/load-runtime-config-test.js b/console/tests/unit/initializers/load-runtime-config-test.js
index faba95e6..377061f9 100644
--- a/console/tests/unit/initializers/load-runtime-config-test.js
+++ b/console/tests/unit/initializers/load-runtime-config-test.js
@@ -26,4 +26,38 @@ module('Unit | Initializer | load-runtime-config', function () {
assert.deepEqual(calls, ['defer', 'advance'], 'readiness always advances');
});
+
+ test('readiness still advances when the first attempt throws', async function (assert) {
+ // The app must boot even if advancing readiness fails once — otherwise a failure
+ // here would leave the console stuck on its loading screen forever.
+ const calls = [];
+ let advanced;
+ const didAdvance = new Promise((resolve) => (advanced = resolve));
+ const errors = [];
+ const originalError = console.error;
+ console.error = (...args) => errors.push(args[0]);
+
+ const application = {
+ deferReadiness: () => calls.push('defer'),
+ advanceReadiness: () => {
+ calls.push('advance');
+
+ if (calls.length === 2) {
+ throw new Error('readiness already advanced');
+ }
+
+ advanced();
+ },
+ };
+
+ try {
+ initialize(application);
+ await didAdvance;
+ } finally {
+ console.error = originalError;
+ }
+
+ assert.deepEqual(calls, ['defer', 'advance', 'advance'], 'the second attempt is made from the catch');
+ assert.deepEqual(errors, ['[Runtime Config] Failed to load runtime config:'], 'and the failure is logged');
+ });
});
diff --git a/console/tests/unit/transforms/array-test.js b/console/tests/unit/transforms/array-test.js
index c49b826f..02bf58e1 100644
--- a/console/tests/unit/transforms/array-test.js
+++ b/console/tests/unit/transforms/array-test.js
@@ -56,3 +56,14 @@ module('Unit | Transform | array | iterables', function (hooks) {
assert.deepEqual(transform.deserialize(new Map([['a', 1]])), [['a', 1]], 'a Map deserializes to its entries');
});
});
+
+module('Unit | Transform | array | serializing iterables', function (hooks) {
+ setupTest(hooks);
+
+ test('a non-string iterable is spread into an array on the way out too', function (assert) {
+ const transform = this.owner.lookup('transform:array');
+
+ assert.deepEqual(transform.serialize(new Set(['a', 'b'])), ['a', 'b'], 'a Set is sent as a list');
+ assert.deepEqual(transform.serialize(new Map([['k', 1]])), [['k', 1]], 'and so is a Map');
+ });
+});