test(frontend): cover missing and null record branches in ContextMenus

- Assert LoveButton is hidden (visible=false) when record.missing is true
  in both AlbumContextMenu and ArtistContextMenu
- Assert both menus render nothing when record is undefined, exercising
  the early-return branch

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yosoyepa 2026-05-15 16:49:50 -05:00
parent 9d8e680451
commit 4ce1ef0102

View File

@ -67,6 +67,17 @@ describe('AlbumContextMenu', () => {
render(<AlbumContextMenu record={albumRecord} />)
expect(capturedLoveButtonProps.resource).toBe('album')
})
it('hides LoveButton when record.missing is true', () => {
render(<AlbumContextMenu record={{ ...albumRecord, missing: true }} />)
expect(capturedLoveButtonProps.visible).toBe(false)
expect(screen.queryByTestId('love-button')).not.toBeInTheDocument()
})
it('renders nothing when record is undefined', () => {
const { container } = render(<AlbumContextMenu />)
expect(container).toBeEmptyDOMElement()
})
})
describe('ArtistContextMenu', () => {
@ -96,4 +107,15 @@ describe('ArtistContextMenu', () => {
render(<ArtistContextMenu record={artistRecord} />)
expect(capturedLoveButtonProps.resource).toBe('artist')
})
it('hides LoveButton when record.missing is true', () => {
render(<ArtistContextMenu record={{ ...artistRecord, missing: true }} />)
expect(capturedLoveButtonProps.visible).toBe(false)
expect(screen.queryByTestId('love-button')).not.toBeInTheDocument()
})
it('renders nothing when record is undefined', () => {
const { container } = render(<ArtistContextMenu />)
expect(container).toBeEmptyDOMElement()
})
})