test: add data-testid to all context menu items

pull/3205/head
Audric Ackermann 7 months ago
parent 6c617de892
commit 9ddd50f82c
No known key found for this signature in database

@ -1,5 +1,5 @@
import { MouseEvent, useEffect, useState } from 'react'; import { MouseEvent, useEffect, useState } from 'react';
import { contextMenu, Item, Menu } from 'react-contexify'; import { contextMenu, Menu } from 'react-contexify';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components'; import styled from 'styled-components';
@ -10,6 +10,7 @@ import { getHasOngoingCallWithPubkey } from '../../state/selectors/call';
import { SessionIconButton } from '../icon'; import { SessionIconButton } from '../icon';
import { DropDownAndToggleButton } from '../icon/DropDownAndToggleButton'; import { DropDownAndToggleButton } from '../icon/DropDownAndToggleButton';
import { SessionContextMenuContainer } from '../SessionContextMenuContainer'; import { SessionContextMenuContainer } from '../SessionContextMenuContainer';
import { ItemWithDataTestId } from '../menu/items/MenuItemWithDataTestId';
const VideoInputMenu = ({ const VideoInputMenu = ({
triggerId, triggerId,
@ -23,14 +24,14 @@ const VideoInputMenu = ({
<Menu id={triggerId} animation="fade"> <Menu id={triggerId} animation="fade">
{camerasList.map(m => { {camerasList.map(m => {
return ( return (
<Item <ItemWithDataTestId
key={m.deviceId} key={m.deviceId}
onClick={() => { onClick={() => {
void CallManager.selectCameraByDeviceId(m.deviceId); void CallManager.selectCameraByDeviceId(m.deviceId);
}} }}
> >
{m.label.substr(0, 40)} {m.label.substr(0, 40)}
</Item> </ItemWithDataTestId>
); );
})} })}
</Menu> </Menu>
@ -96,14 +97,14 @@ const AudioInputMenu = ({
<Menu id={triggerId} animation="fade"> <Menu id={triggerId} animation="fade">
{audioInputsList.map(m => { {audioInputsList.map(m => {
return ( return (
<Item <ItemWithDataTestId
key={m.deviceId} key={m.deviceId}
onClick={() => { onClick={() => {
void CallManager.selectAudioInputByDeviceId(m.deviceId); void CallManager.selectAudioInputByDeviceId(m.deviceId);
}} }}
> >
{m.label.substr(0, 40)} {m.label.substr(0, 40)}
</Item> </ItemWithDataTestId>
); );
})} })}
</Menu> </Menu>
@ -165,14 +166,14 @@ const AudioOutputMenu = ({
<Menu id={triggerId} animation="fade"> <Menu id={triggerId} animation="fade">
{audioOutputsList.map(m => { {audioOutputsList.map(m => {
return ( return (
<Item <ItemWithDataTestId
key={m.deviceId} key={m.deviceId}
onClick={() => { onClick={() => {
void CallManager.selectAudioOutputByDeviceId(m.deviceId); void CallManager.selectAudioOutputByDeviceId(m.deviceId);
}} }}
> >
{m.label.substr(0, 40)} {m.label.substr(0, 40)}
</Item> </ItemWithDataTestId>
); );
})} })}
</Menu> </Menu>

@ -2,7 +2,7 @@
import { Dispatch, useCallback, useEffect, useRef, useState } from 'react'; import { Dispatch, useCallback, useEffect, useRef, useState } from 'react';
import { isNumber } from 'lodash'; import { isNumber } from 'lodash';
import { Item, ItemParams, Menu, useContextMenu } from 'react-contexify'; import { ItemParams, Menu, useContextMenu } from 'react-contexify';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import useClickAway from 'react-use/lib/useClickAway'; import useClickAway from 'react-use/lib/useClickAway';
import useMouse from 'react-use/lib/useMouse'; import useMouse from 'react-use/lib/useMouse';
@ -51,6 +51,7 @@ import { MessageReactBar } from './MessageReactBar';
import { showCopyAccountIdAction } from '../../../menu/items/CopyAccountId'; import { showCopyAccountIdAction } from '../../../menu/items/CopyAccountId';
import { CopyAccountIdMenuItem } from '../../../menu/items/CopyAccountId/CopyAccountIdMenuItem'; import { CopyAccountIdMenuItem } from '../../../menu/items/CopyAccountId/CopyAccountIdMenuItem';
import { Localizer } from '../../../basic/Localizer'; import { Localizer } from '../../../basic/Localizer';
import { ItemWithDataTestId } from '../../../menu/items/MenuItemWithDataTestId';
export type MessageContextMenuSelectorProps = Pick< export type MessageContextMenuSelectorProps = Pick<
MessageRenderingProps, MessageRenderingProps,
@ -109,7 +110,7 @@ const DeleteItem = ({ messageId }: { messageId: string }) => {
return null; return null;
} }
return <Item onClick={onDelete}>{window.i18n('delete')}</Item>; return <ItemWithDataTestId onClick={onDelete}>{window.i18n('delete')}</ItemWithDataTestId>;
}; };
type MessageId = { messageId: string }; type MessageId = { messageId: string };
@ -146,12 +147,16 @@ const AdminActionItems = ({ messageId }: MessageId) => {
return showAdminActions ? ( return showAdminActions ? (
<> <>
<Item onClick={onBan}>{window.i18n('banUser')}</Item> <ItemWithDataTestId onClick={onBan}>{window.i18n('banUser')}</ItemWithDataTestId>
<Item onClick={onUnban}>{window.i18n('banUnbanUser')}</Item> <ItemWithDataTestId onClick={onUnban}>{window.i18n('banUnbanUser')}</ItemWithDataTestId>
{isSenderAdmin ? ( {isSenderAdmin ? (
<Item onClick={removeModerator}>{window.i18n('adminRemoveAsAdmin')}</Item> <ItemWithDataTestId onClick={removeModerator}>
{window.i18n('adminRemoveAsAdmin')}
</ItemWithDataTestId>
) : ( ) : (
<Item onClick={addModerator}>{window.i18n('adminPromoteToAdmin')}</Item> <ItemWithDataTestId onClick={addModerator}>
{window.i18n('adminPromoteToAdmin')}
</ItemWithDataTestId>
)} )}
</> </>
) : null; ) : null;
@ -170,7 +175,9 @@ const RetryItem = ({ messageId }: MessageId) => {
await found.retrySend(); await found.retrySend();
} }
}, [messageId]); }, [messageId]);
return showRetry ? <Item onClick={onRetry}>{window.i18n('resend')}</Item> : null; return showRetry ? (
<ItemWithDataTestId onClick={onRetry}>{window.i18n('resend')}</ItemWithDataTestId>
) : null;
}; };
export const showMessageInfoOverlay = async ({ export const showMessageInfoOverlay = async ({
@ -372,26 +379,28 @@ export const MessageContextMenu = (props: Props) => {
/> />
)} )}
{attachments?.length && attachments.every(m => !m.pending && m.path) ? ( {attachments?.length && attachments.every(m => !m.pending && m.path) ? (
<Item onClick={saveAttachment}>{window.i18n('save')}</Item> <ItemWithDataTestId onClick={saveAttachment}>{window.i18n('save')}</ItemWithDataTestId>
) : null} ) : null}
<Item onClick={copyText}>{window.i18n('copy')}</Item> <ItemWithDataTestId onClick={copyText}>{window.i18n('copy')}</ItemWithDataTestId>
{(isSent || !isOutgoing) && <Item onClick={onReply}>{window.i18n('reply')}</Item>} {(isSent || !isOutgoing) && (
<Item <ItemWithDataTestId onClick={onReply}>{window.i18n('reply')}</ItemWithDataTestId>
)}
<ItemWithDataTestId
onClick={() => { onClick={() => {
void showMessageInfoOverlay({ messageId, dispatch }); void showMessageInfoOverlay({ messageId, dispatch });
}} }}
> >
<Localizer token="info" /> <Localizer token="info" />
</Item> </ItemWithDataTestId>
{/* this is a message in the view, so always private */} {/* this is a message in the view, so always private */}
{sender && showCopyAccountIdAction({ isPrivate: true, pubkey: sender }) ? ( {sender && showCopyAccountIdAction({ isPrivate: true, pubkey: sender }) ? (
<CopyAccountIdMenuItem pubkey={sender} /> <CopyAccountIdMenuItem pubkey={sender} />
) : null} ) : null}
<RetryItem messageId={messageId} /> <RetryItem messageId={messageId} />
{isDeletable ? ( {isDeletable ? (
<Item onClick={onSelect}> <ItemWithDataTestId onClick={onSelect}>
<Localizer token="messageSelect" /> <Localizer token="messageSelect" />
</Item> </ItemWithDataTestId>
) : null} ) : null}
<DeleteItem messageId={messageId} /> <DeleteItem messageId={messageId} />
<AdminActionItems messageId={messageId} /> <AdminActionItems messageId={messageId} />

@ -86,7 +86,7 @@ export const BlockOrUnblockDialog = ({ pubkeys, action, onConfirmed }: NonNullab
return ( return (
<SessionWrapperModal showExitIcon={true} title={localizedAction} onClose={closeModal}> <SessionWrapperModal showExitIcon={true} title={localizedAction} onClose={closeModal}>
<StyledModalDescriptionContainer> <StyledModalDescriptionContainer data-testid="block-unblock-modal-description">
<Localizer {...args} /> <Localizer {...args} />
</StyledModalDescriptionContainer> </StyledModalDescriptionContainer>
<Flex container={true} flexDirection="column" alignItems="center"> <Flex container={true} flexDirection="column" alignItems="center">
@ -97,12 +97,14 @@ export const BlockOrUnblockDialog = ({ pubkeys, action, onConfirmed }: NonNullab
buttonColor={SessionButtonColor.Danger} buttonColor={SessionButtonColor.Danger}
onClick={onConfirm} onClick={onConfirm}
text={localizedAction} text={localizedAction}
dataTestId="session-confirm-ok-button"
/> />
<SessionButton <SessionButton
buttonType={SessionButtonType.Simple} buttonType={SessionButtonType.Simple}
buttonColor={SessionButtonColor.White} buttonColor={SessionButtonColor.White}
onClick={closeModal} onClick={closeModal}
text={window.i18n('cancel')} text={window.i18n('cancel')}
dataTestId="session-cancel-ok-button"
/> />
</div> </div>
</Flex> </Flex>

@ -1,4 +1,4 @@
import { Item, Menu } from 'react-contexify'; import { Menu } from 'react-contexify';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { useConvoIdFromContext } from '../../contexts/ConvoIdContext'; import { useConvoIdFromContext } from '../../contexts/ConvoIdContext';
@ -27,6 +27,7 @@ import {
} from './Menu'; } from './Menu';
import { CopyCommunityUrlMenuItem } from './items/CopyCommunityUrl/CopyCommunityUrlMenuItem'; import { CopyCommunityUrlMenuItem } from './items/CopyCommunityUrl/CopyCommunityUrlMenuItem';
import { CopyAccountIdMenuItem } from './items/CopyAccountId/CopyAccountIdMenuItem'; import { CopyAccountIdMenuItem } from './items/CopyAccountId/CopyAccountIdMenuItem';
import { ItemWithDataTestId } from './items/MenuItemWithDataTestId';
export type PropsContextConversationItem = { export type PropsContextConversationItem = {
triggerId: string; triggerId: string;
@ -92,7 +93,7 @@ export const PinConversationMenuItem = (): JSX.Element | null => {
}; };
const menuText = isPinned ? window.i18n('pinUnpin') : window.i18n('pin'); const menuText = isPinned ? window.i18n('pinUnpin') : window.i18n('pin');
return <Item onClick={togglePinConversation}>{menuText}</Item>; return <ItemWithDataTestId onClick={togglePinConversation}>{menuText}</ItemWithDataTestId>;
} }
return null; return null;
}; };

@ -1,4 +1,4 @@
import { Item, Submenu } from 'react-contexify'; import { Submenu } from 'react-contexify';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
import { useConvoIdFromContext } from '../../contexts/ConvoIdContext'; import { useConvoIdFromContext } from '../../contexts/ConvoIdContext';
import { import {
@ -57,6 +57,7 @@ import { getIsMessageSection } from '../../state/selectors/section';
import { useSelectedConversationKey } from '../../state/selectors/selectedConversation'; import { useSelectedConversationKey } from '../../state/selectors/selectedConversation';
import type { LocalizerToken } from '../../types/localizer'; import type { LocalizerToken } from '../../types/localizer';
import { SessionButtonColor } from '../basic/SessionButton'; import { SessionButtonColor } from '../basic/SessionButton';
import { ItemWithDataTestId } from './items/MenuItemWithDataTestId';
/** Menu items standardized */ /** Menu items standardized */
@ -66,13 +67,13 @@ export const InviteContactMenuItem = (): JSX.Element | null => {
if (isPublic) { if (isPublic) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
showInviteContactByConvoId(convoId); showInviteContactByConvoId(convoId);
}} }}
> >
{window.i18n('membersInvite')} {window.i18n('membersInvite')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -91,7 +92,11 @@ export const MarkConversationUnreadMenuItem = (): JSX.Element | null => {
void conversation?.markAsUnread(true); void conversation?.markAsUnread(true);
}; };
return <Item onClick={markUnread}>{window.i18n('messageMarkUnread')}</Item>; return (
<ItemWithDataTestId onClick={markUnread}>
{window.i18n('messageMarkUnread')}
</ItemWithDataTestId>
);
} }
return null; return null;
}; };
@ -133,7 +138,7 @@ export const DeletePrivateContactMenuItem = () => {
); );
}; };
return <Item onClick={showConfirmationModal}>{menuItemText}</Item>; return <ItemWithDataTestId onClick={showConfirmationModal}>{menuItemText}</ItemWithDataTestId>;
} }
return null; return null;
}; };
@ -149,7 +154,7 @@ export const LeaveGroupOrCommunityMenuItem = () => {
if (!isKickedFromGroup && !isLeft && !isPrivate) { if (!isKickedFromGroup && !isLeft && !isPrivate) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
void showLeaveGroupByConvoId(convoId, username); void showLeaveGroupByConvoId(convoId, username);
}} }}
@ -160,7 +165,7 @@ export const LeaveGroupOrCommunityMenuItem = () => {
lastMessage?.interactionStatus === ConversationInteractionStatus.Error lastMessage?.interactionStatus === ConversationInteractionStatus.Error
? window.i18n('conversationsDelete') ? window.i18n('conversationsDelete')
: window.i18n('groupLeave')} : window.i18n('groupLeave')}
</Item> </ItemWithDataTestId>
); );
} }
@ -177,7 +182,7 @@ export const ShowUserDetailsMenuItem = () => {
if (isPrivate && !isBlinded) { if (isPrivate && !isBlinded) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
dispatch( dispatch(
updateUserDetailsModal({ updateUserDetailsModal({
@ -189,7 +194,7 @@ export const ShowUserDetailsMenuItem = () => {
}} }}
> >
{window.i18n('contactUserDetails')} {window.i18n('contactUserDetails')}
</Item> </ItemWithDataTestId>
); );
} }
@ -204,13 +209,13 @@ export const UpdateGroupNameMenuItem = () => {
if (!isKickedFromGroup && !left && weAreAdmin) { if (!isKickedFromGroup && !left && weAreAdmin) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
void showUpdateGroupNameByConvoId(convoId); void showUpdateGroupNameByConvoId(convoId);
}} }}
> >
{window.i18n('groupEdit')} {window.i18n('groupEdit')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -224,13 +229,13 @@ export const RemoveModeratorsMenuItem = (): JSX.Element | null => {
if (!isKickedFromGroup && weAreAdmin && isPublic) { if (!isKickedFromGroup && weAreAdmin && isPublic) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
showRemoveModeratorsByConvoId(convoId); showRemoveModeratorsByConvoId(convoId);
}} }}
> >
{window.i18n('adminRemove')} {window.i18n('adminRemove')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -244,13 +249,13 @@ export const AddModeratorsMenuItem = (): JSX.Element | null => {
if (!isKickedFromGroup && weAreAdmin && isPublic) { if (!isKickedFromGroup && weAreAdmin && isPublic) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
showAddModeratorsByConvoId(convoId); showAddModeratorsByConvoId(convoId);
}} }}
> >
{window.i18n('adminPromote')} {window.i18n('adminPromote')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -264,13 +269,13 @@ export const UnbanMenuItem = (): JSX.Element | null => {
if (isPublic && !isKickedFromGroup && weAreAdmin) { if (isPublic && !isKickedFromGroup && weAreAdmin) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
showUnbanUserByConvoId(convoId); showUnbanUserByConvoId(convoId);
}} }}
> >
{window.i18n('banUnbanUser')} {window.i18n('banUnbanUser')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -284,13 +289,13 @@ export const BanMenuItem = (): JSX.Element | null => {
if (isPublic && !isKickedFromGroup && weAreAdmin) { if (isPublic && !isKickedFromGroup && weAreAdmin) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
showBanUserByConvoId(convoId); showBanUserByConvoId(convoId);
}} }}
> >
{window.i18n('banUser')} {window.i18n('banUser')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -302,9 +307,9 @@ export const MarkAllReadMenuItem = (): JSX.Element | null => {
if (!isIncomingRequest && !PubKey.isBlinded(convoId)) { if (!isIncomingRequest && !PubKey.isBlinded(convoId)) {
return ( return (
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
<Item onClick={async () => markAllReadByConvoId(convoId)}> <ItemWithDataTestId onClick={async () => markAllReadByConvoId(convoId)}>
{window.i18n('messageMarkRead')} {window.i18n('messageMarkRead')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -323,7 +328,7 @@ export const BlockMenuItem = (): JSX.Element | null => {
? async () => unblockConvoById(convoId) ? async () => unblockConvoById(convoId)
: async () => blockConvoById(convoId); : async () => blockConvoById(convoId);
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
return <Item onClick={blockHandler}>{blockTitle}</Item>; return <ItemWithDataTestId onClick={blockHandler}>{blockTitle}</ItemWithDataTestId>;
} }
return null; return null;
}; };
@ -341,9 +346,9 @@ export const ClearNicknameMenuItem = (): JSX.Element | null => {
return ( return (
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
<Item onClick={async () => clearNickNameByConvoId(convoId)}> <ItemWithDataTestId onClick={async () => clearNickNameByConvoId(convoId)}>
{window.i18n('nicknameRemove')} {window.i18n('nicknameRemove')}
</Item> </ItemWithDataTestId>
); );
}; };
@ -358,13 +363,13 @@ export const ChangeNicknameMenuItem = () => {
return null; return null;
} }
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
dispatch(changeNickNameModal({ conversationId: convoId })); dispatch(changeNickNameModal({ conversationId: convoId }));
}} }}
> >
{window.i18n('nicknameSet')} {window.i18n('nicknameSet')}
</Item> </ItemWithDataTestId>
); );
}; };
@ -380,14 +385,14 @@ export const DeleteMessagesMenuItem = () => {
return null; return null;
} }
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
deleteAllMessagesByConvoIdWithConfirmation(convoId); deleteAllMessagesByConvoIdWithConfirmation(convoId);
}} }}
> >
{/* just more than 1 to have the string Delete Messages */} {/* just more than 1 to have the string Delete Messages */}
{window.i18n('deleteMessage', { count: 2 })} {window.i18n('deleteMessage', { count: 2 })}
</Item> </ItemWithDataTestId>
); );
}; };
@ -407,13 +412,13 @@ export const DeletePrivateConversationMenuItem = () => {
} }
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
showLeavePrivateConversationbyConvoId(convoId); showLeavePrivateConversationbyConvoId(convoId);
}} }}
> >
{isMe ? window.i18n('noteToSelfHide') : window.i18n('conversationsDelete')} {isMe ? window.i18n('noteToSelfHide') : window.i18n('conversationsDelete')}
</Item> </ItemWithDataTestId>
); );
}; };
@ -425,7 +430,7 @@ export const AcceptMsgRequestMenuItem = () => {
if (isRequest && isPrivate) { if (isRequest && isPrivate) {
return ( return (
<Item <ItemWithDataTestId
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
onClick={async () => { onClick={async () => {
await convo.setDidApproveMe(true); await convo.setDidApproveMe(true);
@ -434,7 +439,7 @@ export const AcceptMsgRequestMenuItem = () => {
}} }}
> >
{window.i18n('accept')} {window.i18n('accept')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -448,7 +453,7 @@ export const DeclineMsgRequestMenuItem = () => {
if (isPrivate && isRequest) { if (isPrivate && isRequest) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
declineConversationWithConfirm({ declineConversationWithConfirm({
conversationId: convoId, conversationId: convoId,
@ -459,7 +464,7 @@ export const DeclineMsgRequestMenuItem = () => {
}} }}
> >
{window.i18n('decline')} {window.i18n('decline')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -473,7 +478,7 @@ export const DeclineAndBlockMsgRequestMenuItem = () => {
if (isRequest && isPrivate) { if (isRequest && isPrivate) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
declineConversationWithConfirm({ declineConversationWithConfirm({
conversationId: convoId, conversationId: convoId,
@ -484,7 +489,7 @@ export const DeclineAndBlockMsgRequestMenuItem = () => {
}} }}
> >
{window.i18n('block')} {window.i18n('block')}
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;
@ -540,7 +545,7 @@ export const NotificationForConvoMenuItem = (): JSX.Element | null => {
const disabled = item.value === currentNotificationSetting; const disabled = item.value === currentNotificationSetting;
return ( return (
<Item <ItemWithDataTestId
key={item.value} key={item.value}
onClick={() => { onClick={() => {
void setNotificationForConvoId(convoId, item.value); void setNotificationForConvoId(convoId, item.value);
@ -548,7 +553,7 @@ export const NotificationForConvoMenuItem = (): JSX.Element | null => {
disabled={disabled} disabled={disabled}
> >
{item.name} {item.name}
</Item> </ItemWithDataTestId>
); );
})} })}
</Submenu> </Submenu>

@ -1,9 +1,10 @@
import { Item, Menu } from 'react-contexify'; import { Menu } from 'react-contexify';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { SessionContextMenuContainer } from '../SessionContextMenuContainer'; import { SessionContextMenuContainer } from '../SessionContextMenuContainer';
import { hideMessageRequestBanner } from '../../state/ducks/userConfig'; import { hideMessageRequestBanner } from '../../state/ducks/userConfig';
import { ItemWithDataTestId } from './items/MenuItemWithDataTestId';
export type PropsContextConversationItem = { export type PropsContextConversationItem = {
triggerId: string; triggerId: string;
@ -12,13 +13,13 @@ export type PropsContextConversationItem = {
const HideBannerMenuItem = (): JSX.Element => { const HideBannerMenuItem = (): JSX.Element => {
const dispatch = useDispatch(); const dispatch = useDispatch();
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
dispatch(hideMessageRequestBanner()); dispatch(hideMessageRequestBanner());
}} }}
> >
{window.i18n('hide')} {window.i18n('hide')}
</Item> </ItemWithDataTestId>
); );
}; };

@ -1,8 +1,8 @@
import { Item } from 'react-contexify';
import { useIsPrivate } from '../../../../hooks/useParamSelector'; import { useIsPrivate } from '../../../../hooks/useParamSelector';
import { copyPublicKeyByConvoId } from '../../../../interactions/conversationInteractions'; import { copyPublicKeyByConvoId } from '../../../../interactions/conversationInteractions';
import { Localizer } from '../../../basic/Localizer'; import { Localizer } from '../../../basic/Localizer';
import { showCopyAccountIdAction } from '.'; import { showCopyAccountIdAction } from '.';
import { ItemWithDataTestId } from '../MenuItemWithDataTestId';
/** /**
* Can be used to copy the conversation AccountID or the message's author sender'id. * Can be used to copy the conversation AccountID or the message's author sender'id.
@ -15,13 +15,13 @@ export const CopyAccountIdMenuItem = ({ pubkey }: { pubkey: string }): JSX.Eleme
if (showCopyAccountIdAction({ isPrivate, pubkey })) { if (showCopyAccountIdAction({ isPrivate, pubkey })) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
void copyPublicKeyByConvoId(pubkey); void copyPublicKeyByConvoId(pubkey);
}} }}
> >
<Localizer token="accountIDCopy" /> <Localizer token="accountIDCopy" />
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;

@ -1,8 +1,8 @@
import { Item } from 'react-contexify';
import { showCopyCommunityUrlMenuItem } from '.'; import { showCopyCommunityUrlMenuItem } from '.';
import { useIsPublic } from '../../../../hooks/useParamSelector'; import { useIsPublic } from '../../../../hooks/useParamSelector';
import { copyPublicKeyByConvoId } from '../../../../interactions/conversationInteractions'; import { copyPublicKeyByConvoId } from '../../../../interactions/conversationInteractions';
import { Localizer } from '../../../basic/Localizer'; import { Localizer } from '../../../basic/Localizer';
import { ItemWithDataTestId } from '../MenuItemWithDataTestId';
export const CopyCommunityUrlMenuItem = ({ convoId }: { convoId: string }): JSX.Element | null => { export const CopyCommunityUrlMenuItem = ({ convoId }: { convoId: string }): JSX.Element | null => {
const isPublic = useIsPublic(convoId); const isPublic = useIsPublic(convoId);
@ -11,13 +11,13 @@ export const CopyCommunityUrlMenuItem = ({ convoId }: { convoId: string }): JSX.
if (showCopyCommunityUrlMenuItem({ isPublic })) { if (showCopyCommunityUrlMenuItem({ isPublic })) {
return ( return (
<Item <ItemWithDataTestId
onClick={() => { onClick={() => {
void copyPublicKeyByConvoId(convoId); void copyPublicKeyByConvoId(convoId);
}} }}
> >
<Localizer token="communityUrlCopy" /> <Localizer token="communityUrlCopy" />
</Item> </ItemWithDataTestId>
); );
} }
return null; return null;

@ -0,0 +1,9 @@
import { Item, ItemProps } from 'react-contexify';
export function ItemWithDataTestId({ children, ...props }: ItemProps) {
return (
<Item data-testid="context-menu-item" {...props}>
{children}
</Item>
);
}
Loading…
Cancel
Save