Skip to content

added unit test suite for payment stream creation hook - #488

Open
AbuTuraab wants to merge 2 commits into
Fundable-Protocol:mainfrom
AbuTuraab:create-unit-test-suite-for-payment-stream-creation-hook
Open

added unit test suite for payment stream creation hook#488
AbuTuraab wants to merge 2 commits into
Fundable-Protocol:mainfrom
AbuTuraab:create-unit-test-suite-for-payment-stream-creation-hook

Conversation

@AbuTuraab

@AbuTuraab AbuTuraab commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Closes #463

Implemented use-create-stream unit coverage in use-create-stream.test.ts.
It covers:
Optimistic stream insertion and cache invalidation after success
Rollback of all matching stream caches plus user-facing failure toast
Explicit sender precedence over wallet address
Disconnected-wallet validation without calling the API

Summary by CodeRabbit

  • Bug Fixes

    • Stream creation now supports an optional sender and automatically uses the connected wallet when no sender is provided.
    • Clear errors are shown when a wallet is not connected.
    • Failed stream creation restores cached stream data without leaving optimistic updates behind.
  • Tests

    • Added coverage for successful creation, error recovery, sender overrides, wallet validation, and cache updates.

@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@AbuTuraab 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

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@AbuTuraab, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5897dd5b-6bc5-4fbb-9939-2af8cfb6b55b

📥 Commits

Reviewing files that changed from the base of the PR and between 8e2d99e and 65d785a.

📒 Files selected for processing (1)
  • apps/web/src/hooks/use-create-stream.test.ts
📝 Walkthrough

Walkthrough

The stream creation input now accepts an optional sender. A new Vitest suite covers optimistic updates, API invocation, cache invalidation, rollback behavior, explicit sender selection, and wallet connection validation.

Changes

Stream creation hook

Layer / File(s) Summary
Input contract and test setup
apps/web/src/hooks/use-create-stream.ts, apps/web/src/hooks/use-create-stream.test.ts
The hook input type makes sender optional, and tests configure mocked dependencies, fixtures, and a QueryClient wrapper.
Mutation behavior coverage
apps/web/src/hooks/use-create-stream.test.ts
Tests cover optimistic cache updates, successful mutation invalidation, rollback and error reporting, explicit sender precedence, and disconnected-wallet rejection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • #363 — Requests unit tests for use-create-stream.ts covering optimistic updates, rollback, and wallet checks.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding a unit test suite for the use-create-stream hook.
Linked Issues check ✅ Passed The PR adds Vitest coverage for optimistic updates, rollback, validation, and sender handling as requested.
Out of Scope Changes check ✅ Passed The changes stay focused on the hook and its tests, with no unrelated code paths added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
🔧 Fix failing CI
  • Fix failing CI in branch create-unit-test-suite-for-payment-stream-creation-hook

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/web/src/hooks/use-create-stream.test.ts (1)

80-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the rollback test observe the optimistic state first.

mockRejectedValue rejects immediately, and the test only verifies the final cache. A regression that removes optimistic insertion could therefore still pass. Use a deferred rejection, wait for the temporary stream to appear, then reject and assert restoration.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/hooks/use-create-stream.test.ts` around lines 80 - 90, Update
the failure test around useCreateStream to defer createStreamMock’s rejection,
assert the optimistic temporary stream appears in the relevant caches before
rejecting, then trigger the rejection and verify both caches are restored and
the error notification remains emitted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/web/src/hooks/use-create-stream.test.ts`:
- Around line 29-31: Update createWrapper so the returned QueryClientProvider
wrapper has an explicit component name, either by defining it as a named
component or assigning its displayName, while preserving the existing children
and queryClient behavior.

---

Nitpick comments:
In `@apps/web/src/hooks/use-create-stream.test.ts`:
- Around line 80-90: Update the failure test around useCreateStream to defer
createStreamMock’s rejection, assert the optimistic temporary stream appears in
the relevant caches before rejecting, then trigger the rejection and verify both
caches are restored and the error notification remains emitted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a2ff1437-cc23-4683-8416-d8bc3f704405

📥 Commits

Reviewing files that changed from the base of the PR and between 8effcde and 8e2d99e.

📒 Files selected for processing (2)
  • apps/web/src/hooks/use-create-stream.test.ts
  • apps/web/src/hooks/use-create-stream.ts

Comment thread apps/web/src/hooks/use-create-stream.test.ts Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

web(use-create-stream.test): create unit test suite for payment stream creation hook

1 participant