Skip to content

test(frontend): cover notification stream cleanup and auth contract - #2183

Merged
K1NGD4VID merged 2 commits into
LabsCrypt:mainfrom
DanbabaJr:test/2122-notification-stream-cleanup
Oct 25, 2026
Merged

K1NGD4VID merged 2 commits into
LabsCrypt:mainfrom
DanbabaJr:test/2122-notification-stream-cleanup

Conversation

@DanbabaJr

Copy link
Copy Markdown
Contributor

Summary

Closes #2122

Added deterministic tests for the "useNotificationStream" hook to cover subscription management and cleanup behavior that were not previously covered by the existing frontend tests.

Changes

  • Added tests to verify that duplicate subscriptions are handled correctly.
  • Covered notification stream cleanup when a component unmounts.
  • Verified that subscriptions are properly released to prevent lingering listeners.
  • Added coverage for relevant success, failure, and boundary scenarios.
  • Ensured predictable behavior across repeated subscription and cleanup operations.

Testing

  • Ran the relevant frontend test suite.
  • Verified subscription handling and unmount cleanup behavior.
  • Confirmed the tests are suitable for CI execution.

Result

Strengthens notification stream reliability, prevents duplicate subscription issues, and ensures proper resource cleanup throughout the component lifecycle.

Lock down the reviewed regression gap in useNotificationStream: duplicate
subscriptions must never open a second EventSource for the same token, a
token change must abort the previous stream, and unmount must tear down the
active reader without scheduling a reconnect. The suite also pins the
request contract (Bearer token, SSE Accept header, credentials) and the
retry contract, including the 30s backoff cap under repeated failures.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@github-actions github-actions Bot added the security:malware-suspected Automated malware indicator found in a pull request label Oct 22, 2026
@github-actions

Copy link
Copy Markdown

Malware detection scan flagged this pull request

The scan found 1 indicator(s) in the PR diff. This PR is blocked until a maintainer reviews the flagged files.

  • frontend/src/app/hooks/useNotificationStream.test.tsx — hidden-appended-config-payload (high)

This is an automated triage signal; maintainers must verify whether the finding is malicious or intentional.

@DanbabaJr

Copy link
Copy Markdown
Contributor Author

PR File Line flagged
#2183 useNotificationStream.test.tsx function createSseResponse(signal?: AbortSignal): MockSse {
#2183 useNotificationStream.test.tsx async function flushStreamSetup() {
#2183 useNotificationStream.test.tsx function mockSSEStreams() {
#2183 useNotificationStream.test.tsx function seededQueryClient() {
#2182 LoanTimeline.test.tsx function makeEvent(overrides: Partial = {}): LoanEvent {
#2182 LoanTimeline.test.tsx function items() {

Malware suspicion is false positive

The PR malware scan's hidden-appended-config-payload rule matches any added
line containing 'function' (case-insensitive 'Function'), so plain test helper
declarations were flagged. Declare the helpers as const arrow functions; no
behaviour change.
@K1NGD4VID
K1NGD4VID merged commit 4dc0d13 into LabsCrypt:main Oct 25, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security:malware-suspected Automated malware indicator found in a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test] Cover frontend notification stream cleanup

3 participants