Skip to content

Commit

Permalink
feat: update chatbox props
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Mar 31, 2022
1 parent 3deca6c commit 125a1e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cypress/integration/item/chatbox/chatbox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const openChatbox = () => {
};

// THESE TESTS ARE SKIPPED BECAUSE THEY FAIL IN CI
describe.skip('Chatbox Scenarios', () => {
describe('Chatbox Scenarios', () => {
let client;

beforeEach(() => {
Expand All @@ -42,7 +42,8 @@ describe.skip('Chatbox Scenarios', () => {

// send message
const message = 'a new message';
cy.get(`#${CHATBOX_ID} #${CHATBOX_INPUT_BOX_ID} input`).type(message);
// get the input field (which is a textarea because it is multiline
cy.get(`#${CHATBOX_ID} #${CHATBOX_INPUT_BOX_ID} textarea:visible`).type(message);
cy.get(`#${CHATBOX_ID} #${CHATBOX_INPUT_BOX_ID} button`).click();
cy.wait('@postItemChatMessage').then(({ request: { body } }) => {
expect(body.body).to.equal(message);
Expand Down
11 changes: 10 additions & 1 deletion src/components/common/Chatbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HEADER_HEIGHT } from '../../config/constants';
import { CHATBOX_INPUT_BOX_ID, CHATBOX_ID } from '../../config/selectors';
import { CurrentUserContext } from '../context/CurrentUserContext';

const { useItemChat, useMembers } = hooks;
const { useItemChat, useMembers, useAvatar } = hooks;

const Chatbox = ({ item }) => {
const { data: chat, isLoading: isChatLoading } = useItemChat(item.get('id'));
Expand All @@ -21,6 +21,12 @@ const Chatbox = ({ item }) => {
const { mutate: sendMessage } = useMutation(
MUTATION_KEYS.POST_ITEM_CHAT_MESSAGE,
);
const { mutate: editMessage } = useMutation(
MUTATION_KEYS.PATCH_ITEM_CHAT_MESSAGE,
);
const { mutate: deleteMessage } = useMutation(
MUTATION_KEYS.DELETE_ITEM_CHAT_MESSAGE,
);

if (isChatLoading || isLoadingCurrentMember || isMembersLoading) {
return <Loader />;
Expand All @@ -36,6 +42,9 @@ const Chatbox = ({ item }) => {
messages={List(chat?.get('messages'))}
height={window.innerHeight - HEADER_HEIGHT * 2}
sendMessageFunction={sendMessage}
deleteMessageFunction={deleteMessage}
editMessageFunction={editMessage}
useAvatarHook={useAvatar}
/>
);
};
Expand Down

0 comments on commit 125a1e4

Please sign in to comment.