Skip to content

test(comments): extract NIP-22 tag builder and add usePostComment tests#346

Open
DSanich wants to merge 1 commit into
divinevideo:mainfrom
DSanich:test/341-nip22-post-comment
Open

test(comments): extract NIP-22 tag builder and add usePostComment tests#346
DSanich wants to merge 1 commit into
divinevideo:mainfrom
DSanich:test/341-nip22-post-comment

Conversation

@DSanich
Copy link
Copy Markdown
Contributor

@DSanich DSanich commented May 7, 2026

Summary

  • Extract buildNip22CommentTags(root, reply?) into src/lib/buildNip22CommentTags.ts — pure NIP-22 (kind 1111) tag construction previously inlined in usePostComment (URL vs event roots, addressable/replaceable/regular kinds, reply vs top-level branches).
  • Wire usePostComment to call the helper inside mutationFn so publish payloads stay identical while logic becomes unit-testable.
  • Add buildNip22CommentTags.test.ts with fixtures for addressable short-video roots (kind 34236), regular/replaceable roots, URL roots, threaded replies (including reply-as-URL).
  • Add usePostComment.test.ts with mocked useNostrPublish / useCurrentUser: asserts publishEvent receives kind: 1111 and matching tags (including reply); exercises cancelQueries, deferred-publish optimistic UI, onSuccess replacement + invalidateQueries after the 6s delay (fake timers), and onError rollback.

Avoid naming corporate partners, customers, or other sensitive external brands in this PR title or body. Use generic descriptors unless a maintainer explicitly approves the public reference.

Motivation

Related Issue

Testing

  • npm run test
  • Manual verification completed

Visuals

  • UI change with screenshots/video attached
  • No visual change
  • Visuals and text avoid sensitive external brand or partner names unless explicitly approved

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

🚀 Preview Deployment

Property Value
Preview URL https://d3dedf75.divine-web-fm8.pages.dev
Commit eb1676c
Branch test/341-nip22-post-comment

@jalcine
Copy link
Copy Markdown
Contributor

jalcine commented May 20, 2026

Is there an issue that this is in relation to? If not, I suggest opening one so we can discuss the merit of this. This is in lieu of the contributing guidelines.

EDIT: I see it, going to review that

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.

test(comments): unit tests for NIP-22 comment tags and usePostComment

2 participants