Skip to content

test(backend): add unit tests for admin audit, notification, streams, and alert services - #358

Merged
EmeditWeb merged 1 commit into
Elite-Work:mainfrom
pixels26:test/backend-service-tests-192-195
Oct 19, 2026
Merged

EmeditWeb merged 1 commit into
Elite-Work:mainfrom
pixels26:test/backend-service-tests-192-195

Conversation

@pixels26

Copy link
Copy Markdown
Contributor

Description

Adds focused unit-test suites for four backend services that had no corresponding test file under backend/src/services/__tests__/. Each suite covers the service's exported functions and the failure paths that previously could only be caught by integration tests or production.

adminAudit.service.ts (#192)

  • verifyChain(): empty table, all-legacy rows, valid multi-link chains, chained rows following legacy rows, tampered prevHash, tampered row data, first-broken-id reporting, and findMany rejection.
  • list(): cursor look-ahead trimming, nextCursor boundaries, malformed cursor rejection without a DB call, cursor-mode DB failures, legacy offset pagination, invalid page/limit normalization, limit capping/flooring, and legacy count() failures.

adminNotification.service.ts (#193)

  • Emission of all four admin notification events, multiple listeners, listeners registered through onSuccess/onFailure, listener error propagation, and no-listener behavior.
  • Default logging listeners for info/error events, plus removeAllListeners() restoring defaults while dropping custom listeners.
  • extractErrorInfo(): error-like objects, Error instances, non-string codes, non-object details, non-string messages, and primitive/null/undefined inputs.

adminStreams.service.ts (#194)

  • vestingStateOf(): not started, blank amounts, partial/full/over vesting, zero totalVested, arbitrary-precision BigInt comparison, and invalid integer strings.
  • list(): summary mapping, status/adminTag/combined filters, in-memory vestingState filtering, empty and out-of-range pages, pagination flooring/capping/defaults, and DB failures.
  • getByStreamId(): found, missing, and DB failure paths.

alert.service.ts (#195)

  • isConfigured(), unconfigured dispatch, signed/unsigned payloads, default details, registry routing/runbook metadata, and timestamps.
  • Cooldown suppression, per-type cooldowns, cooldown expiry, per-alert-type dedupe precedence, non-OK response handling, network failure handling, success logging, and resetCooldown() for one/all types.

Related Issues

Type of Change

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infrastructure / CI / Policy / Documentation update

Test Plan

  • Added 70 focused tests across the four new suites.
  • pnpm jest src/services/__tests__/adminAudit.service.test.ts src/services/__tests__/adminNotification.service.test.ts src/services/__tests__/adminStreams.service.test.ts src/services/__tests__/alert.service.test.ts --coverage=false --runInBand -> 4 suites, 70 tests passed.
  • Ran the new suites together with the existing src/__tests__ suites for the same services -> 8 suites, 105 tests passed.
  • pnpm eslint on all four new files passes.
  • Full pnpm test: the new tests pass, but the repository-wide run requires local Postgres/Redis and currently hits pre-existing unrelated failures on main (e.g. src/services/__tests__/health.service.test.ts type errors and DB connection failures in webhook tests).

PR Checklist

  • Code builds and passes all unit & integration tests locally (pnpm test / cargo test)
  • Tests are scoped to the four services named in the linked issues.
  • No production code was changed.
  • No secrets, private keys, or credentials are hardcoded.
  • Admin regression coverage under backend/src/__tests__/ was preserved; new service-level suites complement it.

@pixels26
pixels26 requested a review from FrankHood1 as a code owner October 19, 2026 15:03
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@pixels26 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@EmeditWeb
EmeditWeb merged commit 0f64e86 into Elite-Work:main Oct 19, 2026
10 of 14 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

2 participants