Files
template-showcase/src/features/publish-note-event/ui/AnnounceNoteButton.test.tsx
T

26 lines
1.3 KiB
TypeScript

import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it } from 'vitest'
import { AnnounceNoteButton } from '@/features/publish-note-event/ui/AnnounceNoteButton'
// The note list rendered this button unconditionally while a nearby card read
// "Link NATS to enable this" (stage sweep, 2026-10-11): clicking it with NATS
// unlinked submitted a form whose action is a no-op (`publishNoteCreated` returns
// early without a connection). The button must agree with the module panel's own
// `nats` slot about whether the module is linked, consistent with the enable-card
// pattern used everywhere else in the template.
describe('AnnounceNoteButton', () => {
it('renders the live form when NATS is linked', () => {
const markup = renderToStaticMarkup(AnnounceNoteButton({ id: 'note-1', linked: true }))
expect(markup).toContain('<form')
expect(markup).toContain('Announce')
expect(markup).not.toContain('disabled')
})
it('renders a disabled button with the enable-card explanation when NATS is not linked', () => {
const markup = renderToStaticMarkup(AnnounceNoteButton({ id: 'note-1', linked: false }))
expect(markup).not.toContain('<form')
expect(markup).toContain('disabled')
expect(markup).toContain('Link NATS to enable this.')
})
})