diff --git a/src/containers/WaGroups/WaPolls/WaPolls.test.tsx b/src/containers/WaGroups/WaPolls/WaPolls.test.tsx index c57530fd6..61bce8e5c 100644 --- a/src/containers/WaGroups/WaPolls/WaPolls.test.tsx +++ b/src/containers/WaGroups/WaPolls/WaPolls.test.tsx @@ -14,6 +14,23 @@ const mockUseLocationValue: any = { state: null, }; +vi.mock('../../../components/UI/EmojiPicker/EmojiPicker', () => ({ + default: ({ onEmojiSelect }: { onEmojiSelect: (emoji: any) => void }) => ( +
+ +
+ ), +})); + vi.mock('react-router-dom', async () => ({ ...((await vi.importActual('react-router-dom')) as {}), useLocation: () => { @@ -52,6 +69,11 @@ describe('Create', () => { fireEvent.change(screen.getByPlaceholderText('Option 1'), { target: { value: 'Option 1' } }); fireEvent.change(screen.getByPlaceholderText('Option 2'), { target: { value: 'Option 2' } }); + fireEvent.click(screen.getAllByTestId('emoji-picker')[0]); + + expect(screen.getByTestId('emoji-container')).toBeInTheDocument(); + fireEvent.click(screen.getByTestId('mock-emoji-picker')); + fireEvent.click(screen.getByTestId('add-btn')); fireEvent.change(screen.getByPlaceholderText('Option 3'), { target: { value: 'Option 3' } }); diff --git a/src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx b/src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx index 311be38f4..b140963a3 100644 --- a/src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx +++ b/src/containers/WaGroups/WaPolls/WaPollsList/WaPollsList.tsx @@ -27,11 +27,7 @@ const queries = { const getLabel = (label: string) =>
{label}
; const getContent = (content: string) => { - return ( -
- {content ? (content.length < 100 ? content : `${content.slice(0, 100)}...`) : ''} -
- ); + return
{content.length < 100 ? content : `${content.slice(0, 100)}...`}
; }; export const WaPollsList = () => { const [deleteWaPollId, setDeleteWaPollId] = useState(null); diff --git a/src/mocks/Groups.tsx b/src/mocks/Groups.tsx index 945210a31..2cd98e739 100644 --- a/src/mocks/Groups.tsx +++ b/src/mocks/Groups.tsx @@ -69,9 +69,16 @@ export const waGroup = { media: null, messageNumber: 4, status: 'sent', - type: 'TEXT', - poll: null, - pollContent: '{}', + type: 'POLL', + poll: { + __typename: 'WaPoll', + allowMultipleAnswer: false, + id: '4', + pollContent: + '{"text": "this is a poll", "options": [{ "votes": 1, "name": "option 1", "id": 0 },{ "votes": 1, "name": "option 2", "id": 1 },{ "votes": 0, "name": "okay option 4", "id": 2 }]}', + }, + pollContent: + '{"text": "this is a poll", "options": [{ "votes": 1, "name": "option 1", "id": 0 },{ "votes": 1, "name": "option 2", "id": 1 },{ "votes": 0, "name": "okay option 4", "id": 2 }]}', }, { __typename: 'WaMessage', @@ -130,9 +137,16 @@ const sampleMessage = { media: null, messageNumber: 1, status: 'received', - type: 'TEXT', - poll: null, - pollContent: '{}', + type: 'POLL', + poll: { + __typename: 'WaPoll', + allowMultipleAnswer: false, + id: '4', + pollContent: + '{"text": "this is a poll", "options": [{ "votes": 1, "name": "option 1", "id": 0 },{ "votes": 1, "name": "option 2", "id": 1 },{ "votes": 0, "name": "okay option 4", "id": 2 }]}', + }, + pollContent: + '{"text": "this is a poll", "options": [{ "votes": 1, "name": "option 1", "id": 0 },{ "votes": 1, "name": "option 2", "id": 1 },{ "votes": 0, "name": "okay option 4", "id": 2 }]}', }; const sampleSearchQueryResult = [ diff --git a/src/mocks/WaPolls.tsx b/src/mocks/WaPolls.tsx index 088b75e87..b34ef6ec2 100644 --- a/src/mocks/WaPolls.tsx +++ b/src/mocks/WaPolls.tsx @@ -5,6 +5,13 @@ import { GET_POLL, GET_POLLS, GET_POLLS_COUNT } from 'graphql/queries/WaPolls'; const createPoll = { request: { query: CREATE_POLL, + variables: { + input: { + label: 'Poll Title', + poll_content: '{"options":[{"id":0,"name":"Option 1😃"},{"name":"Option 3","id":2}],"text":"Poll Content"}', + allow_multiple_answer: true, + }, + }, }, result: { data: { @@ -16,7 +23,6 @@ const createPoll = { }, }, }, - variableMatcher: () => true, }; const getPoll = {