Skip to content

test: bring 6 packages to 100% line coverage#38

Merged
ProjectAJ14 merged 3 commits into
mainfrom
test-coverage-100-percent
May 31, 2026
Merged

test: bring 6 packages to 100% line coverage#38
ProjectAJ14 merged 3 commits into
mainfrom
test-coverage-100-percent

Conversation

@ProjectAJ14

Copy link
Copy Markdown
Contributor

Summary

  • Adds 304 tests across timer_button, html_rich_text, cli_core, connectivity_wrapper, morse_tap, and ns_utils, bringing all six to 100% line coverage.
  • Introduces small, localized test seams (@visibleForTesting hooks) and a few narrow coverage:ignore pragmas on genuinely unreachable-in-tests branches (web-only code, defensive cleanups in error catch blocks).
  • Widens three on Exception catch blocks in ns_utils to catch because json.encode throws Error-typed objects — the previous on Exception catches were dead code.

Coverage results

Package Files Coverage
timer_button 1 75/75 (100%)
html_rich_text 1 73/73 (100%)
cli_core 5 83/83 (100%)
connectivity_wrapper 9 145/145 (100%)
morse_tap 7 414/414 (100%)
ns_utils 19 488/488 (100%)

Production-code changes (minimal, test-enablers)

  • cli_core/logger_extension.dart: extracted stdoutTerminalColumnsResolver as a @visibleForTesting function pointer so tests can stub the terminal-columns lookup.
  • morse_tap/haptic_utils.dart: added @visibleForTesting debugHapticSupportedOverride so haptic paths work off-device.
  • connectivity_wrapper/connectivity_wrapper.dart: // coverage:ignore-line on the kIsWeb branch of _defaultAddresses, a sock?.destroy() cleanup that is unreachable in practice, and a timer?.cancel() that only runs when _maybeEmitStatusUpdate is passed a Timer (the one-shot Timer constructor never does).
  • ns_utils/extensions/list.dart, extensions/map.dart, extensions/context.dart, methods/conversion.dart: swap on Exception catchcatch where the thrown type is Error-typed (JsonUnsupportedObjectError, etc.).
  • ns_utils/extensions/list.dart: refactor toComaSeparatedValues so the catch is reachable (previously the initializer data = toString() threw before entering try).
  • ns_utils/utils/sizes.dart: // coverage:ignore-line on the private Sizes._() constructor.

Remaining work (not in this PR)

5 packages still need coverage work: ns_firebase_utils, ns_intl_phone_input, dzod, nonstop_cli, contact_permission.

Test plan

  • cd packages/timer_button && flutter test — 31 tests pass
  • cd packages/html_rich_text && flutter test — 21 tests pass
  • cd packages/cli_core && dart test — 27 tests pass
  • cd packages/connectivity_wrapper && flutter test — 57 tests pass
  • cd packages/morse_tap && flutter test — 70 tests pass
  • cd packages/ns_utils && flutter test — 98 tests pass
  • melos lint — format + analyze clean

🤖 Generated with Claude Code

ProjectAJ14 and others added 2 commits April 18, 2026 17:59
Covers timer_button, html_rich_text, cli_core, connectivity_wrapper,
morse_tap, and ns_utils. Adds 304 tests total, all passing.

Minor production adjustments to enable testing:
- cli_core: extract stdoutTerminalColumnsResolver as a @VisibleForTesting
  seam so the wrap()'s non-length branch is reachable from tests.
- morse_tap: add @VisibleForTesting debugHapticSupportedOverride on
  HapticUtils so haptic paths can be exercised off-device.
- connectivity_wrapper: narrow 3 truly-unreachable-in-tests branches
  with coverage:ignore pragmas (kIsWeb, sock?.destroy, timer?.cancel).
- ns_utils: widen 3 'on Exception catch' to 'catch' (json encoding
  errors are Error-typed so the previous catches were dead); refactor
  List.toComaSeparatedValues so the catch is reachable; mark the
  private Sizes._() constructor with coverage:ignore.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI build job failed on `dart format --set-exit-if-changed` and
`dart analyze --fatal-infos` for the test-coverage changes.

- Reformat 9 test files to satisfy dart format.
- Remove unnecessary/unused imports flagged by the analyzer
  (mason_logger in cli_core tests, meta in morse_tap haptic_utils,
  cupertino and ns_utils/src.dart in ns_utils tests).
- Suppress unrelated_type_equality_checks on the intentional
  HapticConfig == String inequality assertion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
connectivity_wrapper 100.00% <ø> (?)
dzod ?
html_rich_text 100.00% <ø> (+6.84%) ⬆️
morse_tap 100.00% <ø> (+85.54%) ⬆️
ns_intl_phone_input ?
ns_utils 100.00% <100.00%> (+88.07%) ⬆️
timer_button ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...connectivity_wrapper/lib/connectivity_wrapper.dart 100.00% <ø> (ø)
packages/morse_tap/lib/src/utils/haptic_utils.dart 100.00% <ø> (+100.00%) ⬆️
packages/ns_utils/lib/extensions/context.dart 100.00% <ø> (+100.00%) ⬆️
packages/ns_utils/lib/extensions/list.dart 100.00% <100.00%> (+63.63%) ⬆️
packages/ns_utils/lib/methods/conversion.dart 100.00% <ø> (+25.00%) ⬆️
packages/ns_utils/lib/utils/sizes.dart 100.00% <ø> (+100.00%) ⬆️

... and 67 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ProjectAJ14
ProjectAJ14 merged commit 484a388 into main May 31, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant