Skip to content

Conversation

@sherwinski
Copy link
Contributor

@sherwinski sherwinski commented Nov 18, 2025

1 Line Summary

Increases testing code coverage for certain modules that are labelled as low-coverage (≤50%) by vitest.

Details

Increases tests for the following:

  • SessionManager

Adds new test files for the following:

  • Bell
  • Badge
  • Launcher
  • Button
  • Dialog
  • Message
  • Bell
  • LoginManager
  • TagManager
  • PromptsManager
  • helpers
  • IDManager
  • PermissionManager

Before

 Test Files  40 passed (40)
      Tests  359 passed (359)
   Start at  10:26:36
   Duration  6.37s (transform 12.24s, setup 8.80s, collect 16.51s, tests 8.05s, environment 14.64s, prepare 3.47s)
 % Coverage report from v8
=============================== Coverage summary ===============================
Statements   : 63.18% ( 3572/5653 )
Branches     : 50.01% ( 1476/2951 )
Functions    : 70.55% ( 865/1226 )
Lines        : 63.37% ( 3461/5461 )
================================================================================

After

 Test Files  52 passed (52)
      Tests  393 passed (393)
   Start at  05:14:55
   Duration  32.94s (transform 8.41s, setup 17.21s, collect 18.03s, tests 6.97s, environment 33.19s, prepare 5.19s)
 % Coverage report from v8
=============================== Coverage summary ===============================
Statements   : 67.52% ( 3817/5653 )
Branches     : 54.86% ( 1619/2951 )
Functions    : 75.44% ( 925/1226 )
Lines        : 67.69% ( 3697/5461 )
================================================================================

Systems Affected

  • WebSDK
  • Backend
  • Dashboard

Validation

Tests

Info

Checklist

  • All the automated tests pass or I explained why that is not possible
  • I have personally tested this on my machine or explained why that is not possible
  • I have included test coverage for these changes or explained why they are not needed

Programming Checklist
Interfaces:

  • Don't use default export
  • New interfaces are in model files

Functions:

  • Don't use default export
  • All function signatures have return types
  • Helpers should not access any data but rather be given the data to operate on.

Typescript:

  • No Typescript warnings
  • Avoid silencing null/undefined warnings with the exclamation point

Other:

  • Iteration: refrain from using elem of array syntax. Prefer forEach or use map
  • Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context

Screenshots

Info

Checklist

  • I have included screenshots/recordings of the intended results or explained why they are not needed

Related Tickets



This change is Reviewable

- `_upsertSession` paths: no user (no SW notify), user + SW supported (calls `_notifySWToUpsertSession` + installs listeners once), no SW (sets `_onSessionSent` on `_UserCreate`, emits `SESSION_STARTED`).
- `_notifySWToUpsertSession` builds proper payload and posts to worker messenger.
- `_handleOnFocus`/`_handleOnBlur` wait for `LoginManager._switchingUsersPromise` and log on errors (augment existing switching-user tests).
- Constructor respects enable false early-return; defaults for size/position/theme; installs hooks/updates state when enabled.
- State transitions when `_subscribed`/`_unsubscribed`/`_blocked` flags change trigger message/display logic guards.
Tests for:
  - triggers events
  - unsubscribed + not optedOut → calls register flow
  - toggles dialog path and hides message
  - resets handling flag
- `_show`/`_hide` set `_shown` and resolve promises
- visibility classes toggle
…ent hooks install once; native vs slidedown gating
…f non-empty; returns `{}` and warns when no diff; stores remote/local tags mutate internal state
… error on timeout; `enforceAppId`/`enforceAlias` throw and pass when expected
- Maps Notification permission states
- guards for unavailable API in environment
@sherwinski sherwinski changed the title test: increase code coverage in test: increase code coverage across various modules Nov 18, 2025
@sherwinski sherwinski merged commit 6f30e7c into main Nov 21, 2025
3 checks passed
@sherwinski sherwinski deleted the tests/add-tests-low-coverage-modules branch November 21, 2025 17:11
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.

3 participants