diff --git a/src/components/Poll/PollActions/PollActions.tsx b/src/components/Poll/PollActions/PollActions.tsx index 57b91beb1..e6e79ddd8 100644 --- a/src/components/Poll/PollActions/PollActions.tsx +++ b/src/components/Poll/PollActions/PollActions.tsx @@ -87,6 +87,7 @@ export const PollActions = ({ } = useStateStore(poll.state, pollStateSelector); const [modalOpen, setModalOpen] = useState(); + const canCastVote = channelCapabilities['cast-poll-vote'] && !is_closed; const closeModal = useCallback(() => setModalOpen(undefined), []); const onUpdateAnswerClick = useCallback(() => setModalOpen('add-comment'), []); @@ -106,7 +107,7 @@ export const PollActions = ({ )} - {!is_closed && + {canCastVote && allow_user_suggested_options && options.length < MAX_POLL_OPTIONS && ( v; const defaultChannelStateContext = { - channelCapabilities: { 'query-poll-votes': true }, + channelCapabilities: { 'cast-poll-vote': true, 'query-poll-votes': true }, }; const defaultMessageContext = { @@ -87,7 +87,20 @@ describe('PollActions', () => { expect(screen.queryByText(SEE_ALL_OPTIONS_ACTION_TEXT)).not.toBeInTheDocument(); }); - it('shows "Suggest an option" action if poll is not closed and suggestions are allowed', async () => { + it('does not show "Suggest an option" action if poll is not closed and suggestions are allowed but user does not have permission to cast vote', async () => { + const pollData = generatePoll({ + allow_user_suggested_options: true, + is_closed: false, + }); + const poll = new Poll({ client: {}, poll: pollData }); + await renderComponent({ + channelStateContext: { channelCapabilities: { 'cast-poll-vote': false } }, + poll, + }); + expect(screen.queryByText(SUGGEST_OPTION_ACTION_TEXT)).not.toBeInTheDocument(); + }); + + it('shows "Suggest an option" action if poll is not closed and suggestions are allowed and user has permission to cast votes', async () => { const pollData = generatePoll({ allow_user_suggested_options: true, is_closed: false,