import { render } from '@testing-library/react-native'
import React from 'react'
import { Text } from 'react-native'
import type { ConversationResource } from '../../../types'
import { ConversationActions } from '../conversation_actions'
jest.mock('react-native-gesture-handler/ReanimatedSwipeable', () => {
const { View: MockView } = jest.requireActual('react-native')
return {
__esModule: true,
default: ({
children,
renderLeftActions,
}: {
children: React.ReactNode
renderLeftActions: () => React.ReactNode
}) => (
{renderLeftActions()}
{children}
),
}
})
jest.mock('../../../hooks/use_conversations_actions', () => ({
useConversationsMute: () => ({ muted: false, setMuted: jest.fn(), isPending: false }),
useConversationsMarkRead: () => ({ read: false, markRead: jest.fn(), isPending: false }),
}))
const createdAt = '2026-10-01T12:00:00Z'
const conversation = (overrides: Partial): ConversationResource => ({
type: 'Conversation',
id: 7,
title: 'Youth Group',
conversationPreview: null,
createdAt,
lastMessageCreatedAt: createdAt,
muted: false,
repliesDisabled: false,
unreadCount: 1,
unreadReaction: false,
updatedAt: createdAt,
...overrides,
})
const renderActions = (overrides: Partial) =>
render(
Youth Group
)
describe('ConversationActions', () => {
it('offers mark read but not mute on an archived conversation', () => {
const view = renderActions({ disabled: true, disabledReason: 'archived' })
expect(view.getByText('Mark read')).toBeTruthy()
expect(view.queryByText('Silence')).toBeNull()
})
it('offers mute on a conversation disabled for another reason', () => {
const view = renderActions({ disabled: true, disabledReason: 'safety_check' })
expect(view.getByText('Silence')).toBeTruthy()
})
})