From 4ce1b7813a719685f62c818a8f131a6d134ac43f Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 18 Nov 2021 11:36:14 +1100 Subject: [PATCH] add data-testid for leftpane sections and edit profile dialog --- ts/components/Avatar.tsx | 4 +- .../conversation/ConversationHeader.tsx | 4 +- .../media-gallery/MediaGallery.tsx | 2 +- ts/components/dialog/EditProfileDialog.tsx | 11 ++- .../dialog/OnionStatusPathDialog.tsx | 4 +- ts/components/session/ActionsPanel.tsx | 81 ++++++++++++------- .../session/LeftPaneSettingSection.tsx | 2 +- ts/components/session/SessionInput.tsx | 2 +- .../session/SessionMemberListItem.tsx | 2 +- ts/components/session/SessionSearchInput.tsx | 2 +- .../session/conversation/SessionRecording.tsx | 6 +- .../conversation/SessionRightPanel.tsx | 2 +- .../session/icon/SessionIconButton.tsx | 2 + .../session/settings/SessionSettings.tsx | 2 +- 14 files changed, 81 insertions(+), 45 deletions(-) diff --git a/ts/components/Avatar.tsx b/ts/components/Avatar.tsx index acc5ead9f..0c347cce8 100644 --- a/ts/components/Avatar.tsx +++ b/ts/components/Avatar.tsx @@ -23,6 +23,7 @@ type Props = { base64Data?: string; // if this is not empty, it will be used to render the avatar with base64 encoded data memberAvatars?: Array; // this is added by usingClosedConversationDetails onAvatarClick?: () => void; + dataTestId?: string; }; const Identicon = (props: Props) => { @@ -92,7 +93,7 @@ const AvatarImage = (props: { }; const AvatarInner = (props: Props) => { - const { avatarPath, base64Data, size, memberAvatars, name } = props; + const { avatarPath, base64Data, size, memberAvatars, name, dataTestId } = props; const [imageBroken, setImageBroken] = useState(false); // contentType is not important const { urlToLoad } = useEncryptedFileFetch(avatarPath || '', ''); @@ -122,6 +123,7 @@ const AvatarInner = (props: Props) => { props.onAvatarClick?.(); }} role="button" + data-testid={dataTestId} > {hasImage ? ( { return (
- +
@@ -145,7 +145,7 @@ const TripleDotsMenu = (props: { triggerId: string; showBackButton: boolean }) = }); }} > - +
); }; diff --git a/ts/components/conversation/media-gallery/MediaGallery.tsx b/ts/components/conversation/media-gallery/MediaGallery.tsx index efffb3caa..72a69aaa6 100644 --- a/ts/components/conversation/media-gallery/MediaGallery.tsx +++ b/ts/components/conversation/media-gallery/MediaGallery.tsx @@ -45,7 +45,7 @@ const Sections = (props: Props & { selectedTab: TabType }) => { const label = type === 'media' ? window.i18n('mediaEmptyState') : window.i18n('documentsEmptyState'); - return ; + return ; } return ( diff --git a/ts/components/dialog/EditProfileDialog.tsx b/ts/components/dialog/EditProfileDialog.tsx index dfd7d09f1..4c84a81ea 100644 --- a/ts/components/dialog/EditProfileDialog.tsx +++ b/ts/components/dialog/EditProfileDialog.tsx @@ -82,7 +82,7 @@ export class EditProfileDialog extends React.Component<{}, State> { : undefined; return ( -
+
{
-

+

{sessionID}

@@ -182,10 +185,10 @@ export class EditProfileDialog extends React.Component<{}, State> { {this.renderProfileHeader()}
-

{name}

+

{name}

{ this.setState({ mode: 'edit' }); }} diff --git a/ts/components/dialog/OnionStatusPathDialog.tsx b/ts/components/dialog/OnionStatusPathDialog.tsx index 00540b6fb..dee364720 100644 --- a/ts/components/dialog/OnionStatusPathDialog.tsx +++ b/ts/components/dialog/OnionStatusPathDialog.tsx @@ -150,8 +150,9 @@ export const ModalStatusLight = (props: StatusLightType) => { export const ActionPanelOnionStatusLight = (props: { isSelected: boolean; handleClick: () => void; + dataTestId?: string; }) => { - const { isSelected, handleClick } = props; + const { isSelected, handleClick, dataTestId } = props; const onionPathsCount = useSelector(getOnionPathsCount); const firstPathLength = useSelector(getFirstOnionPathLength); @@ -179,6 +180,7 @@ export const ActionPanelOnionStatusLight = (props: { glowStartDelay={0} noScale={true} isSelected={isSelected} + dataTestId={dataTestId} /> ); }; diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 4952fdffc..8e09ca7f9 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { SessionIconButton, SessionIconType } from './icon'; +import { SessionIconButton } from './icon'; import { Avatar, AvatarSize } from '../Avatar'; import { SessionToastContainer } from './SessionToastContainer'; import { getConversationController } from '../../session/conversations'; @@ -96,47 +96,71 @@ const Section = (props: { type: SectionType; avatarPath?: string | null }) => { onAvatarClick={handleClick} name={userName} pubkey={ourNumber} + dataTestId="leftpane-primary-avatar" /> ); } const unreadToShow = type === SectionType.Message ? unreadMessageCount : undefined; - let iconType: SessionIconType; switch (type) { case SectionType.Message: - iconType = 'chatBubble'; - break; + return ( + + ); case SectionType.Contact: - iconType = 'users'; - break; + return ( + + ); case SectionType.Settings: - iconType = 'gear'; - break; - case SectionType.Moon: - iconType = 'moon'; - break; + return ( + + ); + case SectionType.PathIndicator: + return ( + + ); default: - iconType = 'moon'; - } - const iconColor = undefined; - - return ( - <> - {type === SectionType.PathIndicator ? ( - - ) : ( + return ( - )} - - ); + ); + } }; const cleanUpMediasInterval = DURATION.MINUTES * 30; @@ -300,7 +324,10 @@ export const ActionsPanel = () => { -
+
diff --git a/ts/components/session/LeftPaneSettingSection.tsx b/ts/components/session/LeftPaneSettingSection.tsx index 29e87d949..73ba038bf 100644 --- a/ts/components/session/LeftPaneSettingSection.tsx +++ b/ts/components/session/LeftPaneSettingSection.tsx @@ -58,7 +58,7 @@ const LeftPaneSettingsCategoryRow = (props: { item: any }) => {
{item.id === focusedSettingsSection && ( - + )}
diff --git a/ts/components/session/SessionInput.tsx b/ts/components/session/SessionInput.tsx index c870e0928..611ae6450 100644 --- a/ts/components/session/SessionInput.tsx +++ b/ts/components/session/SessionInput.tsx @@ -108,7 +108,7 @@ export class SessionInput extends React.PureComponent { return ( { this.setState({ forceShow: !this.state.forceShow, diff --git a/ts/components/session/SessionMemberListItem.tsx b/ts/components/session/SessionMemberListItem.tsx index 9557c4ebc..9cf9fd0b6 100644 --- a/ts/components/session/SessionMemberListItem.tsx +++ b/ts/components/session/SessionMemberListItem.tsx @@ -72,7 +72,7 @@ export const SessionMemberListItem = (props: Props) => { {name}
- +
); diff --git a/ts/components/session/SessionSearchInput.tsx b/ts/components/session/SessionSearchInput.tsx index 5f8512859..3c25f4301 100644 --- a/ts/components/session/SessionSearchInput.tsx +++ b/ts/components/session/SessionSearchInput.tsx @@ -21,7 +21,7 @@ export const SessionSearchInput = (props: Props) => { return (
- + onChange(e.target.value)} diff --git a/ts/components/session/conversation/SessionRecording.tsx b/ts/components/session/conversation/SessionRecording.tsx index d8dbdf393..e98a333fd 100644 --- a/ts/components/session/conversation/SessionRecording.tsx +++ b/ts/components/session/conversation/SessionRecording.tsx @@ -125,16 +125,16 @@ export class SessionRecording extends React.Component { {isRecording && ( )} {actionPauseAudio && ( - + )} {hasRecordingAndPaused && ( - + )} {hasRecording && ( {
{ dispatch(closeRightPanel()); diff --git a/ts/components/session/icon/SessionIconButton.tsx b/ts/components/session/icon/SessionIconButton.tsx index 48271ec53..90ef8bdfb 100644 --- a/ts/components/session/icon/SessionIconButton.tsx +++ b/ts/components/session/icon/SessionIconButton.tsx @@ -10,6 +10,7 @@ interface SProps extends SessionIconProps { isSelected?: boolean; isHidden?: boolean; margin?: string; + dataTestId?: string; } const SessionIconButtonInner = React.forwardRef((props, ref) => { @@ -43,6 +44,7 @@ const SessionIconButtonInner = React.forwardRef((props, ref={ref} onClick={clickHandler} style={{ display: isHidden ? 'none' : 'flex', margin: margin ? margin : '' }} + data-testid={props.dataTestId} > {
v{window.versionInfo.version} - + {window.versionInfo.commitHash}