Skip to content

Commit

Permalink
chore: fix datatestids
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilb committed Nov 25, 2024
1 parent 93c4510 commit 89e2115
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ts/components/SessionSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const SessionSearchInput = () => {
const placeholder = isGroupCreationSearch ? window.i18n('searchContacts') : window.i18n('search');

return (
<StyledSearchInput>
<StyledSearchInput data-testid={isGroupCreationSearch ? 'search-contacts-field' : undefined}>
<SessionIconButton
iconColor="var(--search-bar-icon-color)"
iconSize="medium"
Expand Down
2 changes: 1 addition & 1 deletion ts/components/conversation/MessageRequestButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const ConversationMessageRequestButtons = () => {
onClick={() => {
handleDeclineConversationRequest(selectedConvoId, selectedConvoId, convoOrigin);
}}
dataTestId="decline-message-request"
dataTestId="delete-message-request"
/>
</ConversationBannerRow>
<ConversationIncomingRequestExplanation />
Expand Down
7 changes: 2 additions & 5 deletions ts/components/conversation/SubtleNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const ConversationOutgoingRequestExplanation = () => {
if (!contactFromLibsession || !contactFromLibsession.approvedMe) {
return (
<Container
data-testid={'empty-conversation-notification'}
data-testid={'empty-conversation-control-message'}
style={{ padding: 0 }}
noExtraPadding={true}
>
Expand Down Expand Up @@ -249,12 +249,9 @@ export const NoMessageInConversation = () => {
return null;
}

const dataTestId: SessionDataTestId =
isGroupV2 && isKickedFromGroup ? 'empty-conversation-notification' : 'group-control-message';

return (
<TextNotification
dataTestId={dataTestId}
dataTestId={'empty-conversation-control-message'}
html={getHtmlToRender()}
noExtraPadding={false} // in this case, `TextNotification` is **not** part of a bigger component so we need to add some spacing
/>
Expand Down
2 changes: 2 additions & 0 deletions ts/components/dialog/InviteContactsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,15 @@ const InviteContactsDialogInner = (props: Props) => {
buttonType={SessionButtonType.Simple}
disabled={!hasContacts || isProcessingUIChange}
onClick={onClickOK}
dataTestId="session-confirm-ok-button"
/>
<SessionButton
text={cancelText}
buttonColor={SessionButtonColor.Danger}
buttonType={SessionButtonType.Simple}
onClick={closeDialog}
disabled={isProcessingUIChange}
dataTestId="session-confirm-cancel-button"
/>
</div>
</SessionWrapperModal>
Expand Down
2 changes: 1 addition & 1 deletion ts/components/dialog/OpenUrlModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function OpenUrlModal(props: OpenUrlModalState) {
text={window.i18n('urlCopy')}
buttonType={SessionButtonType.Simple}
onClick={onClickCopy}
dataTestId="session-confirm-cancel-button"
dataTestId="copy-url-button"
/>
</div>
</SessionWrapperModal>
Expand Down
4 changes: 2 additions & 2 deletions ts/components/leftpane/overlay/OverlayClosedGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export const OverlayClosedGroupV2 = () => {
text={window.i18n('create')}
disabled={disableCreateButton}
onClick={onEnterPressed}
dataTestId="next-button"
dataTestId="create-group-button"
margin="auto 0 var(--margins-lg) 0 " // just to keep that button at the bottom of the overlay (even with an empty list)
/>
</div>
Expand Down Expand Up @@ -358,7 +358,7 @@ export const OverlayLegacyClosedGroup = () => {
text={window.i18n('create')}
disabled={disableCreateButton}
onClick={onEnterPressed}
dataTestId="next-button"
dataTestId="create-group-button"
margin="auto 0 0" // just to keep that button at the bottom of the overlay (even with an empty list)
/>
</Flex>
Expand Down
3 changes: 3 additions & 0 deletions ts/components/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ export const AcceptMsgRequestMenuItem = () => {
convoId,
});
}}
dataTestId="accept-menu-item"
>
{window.i18n('accept')}
</ItemWithDataTestId>
Expand All @@ -474,6 +475,7 @@ export const DeclineMsgRequestMenuItem = () => {
conversationIdOrigin: null,
});
}}
dataTestId="delete-menu-item"
>
{window.i18n('delete')}
</ItemWithDataTestId>
Expand Down Expand Up @@ -503,6 +505,7 @@ export const DeclineAndBlockMsgRequestMenuItem = () => {
conversationIdOrigin: convoOrigin ?? null,
});
}}
dataTestId="block-menu-item"
>
{window.i18n('block')}
</ItemWithDataTestId>
Expand Down
9 changes: 7 additions & 2 deletions ts/components/menu/items/MenuItemWithDataTestId.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React from 'react';
import { Item, ItemProps } from 'react-contexify';

export function ItemWithDataTestId({ children, ...props }: ItemProps) {
export function ItemWithDataTestId({
children,
dataTestId,
...props
}: Omit<ItemProps, 'data-testid'> & { dataTestId?: React.SessionDataTestId }) {
return (
<Item data-testid="context-menu-item" {...props}>
<Item data-testid={dataTestId || 'context-menu-item'} {...props}>
{children}
</Item>
);
Expand Down
12 changes: 8 additions & 4 deletions ts/react.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ declare module 'react' {
| 'help-settings-menu-item'
| 'permissions-settings-menu-item'
| 'clearData-settings-menu-item'
| 'block-menu-item'
| 'delete-menu-item'
| 'accept-menu-item'

// timer options
| 'time-option-0'
Expand Down Expand Up @@ -107,8 +110,7 @@ declare module 'react' {
| 'group-request-explanation'
| 'conversation-request-explanation'
| 'group-invite-control-message'
| 'empty-conversation-notification'
| 'group-control-message'
| 'empty-conversation-control-message'

// call notification types
| 'call-notification-missed-call'
Expand Down Expand Up @@ -177,6 +179,7 @@ declare module 'react' {
| 'contact-status'
| 'version-warning'
| 'open-url-confirm-button'
| 'copy-url-button'
| 'continue-session-button'
| 'next-new-conversation-button'
| 'reveal-recovery-phrase'
Expand All @@ -199,7 +202,6 @@ declare module 'react' {
| 'hide-recovery-phrase-toggle'
| 'reveal-recovery-phrase-toggle'
| 'resend-promote-button'
| 'next-button'
| 'continue-button'
| 'back-button'
| 'empty-conversation'
Expand All @@ -210,10 +212,12 @@ declare module 'react' {
| 'save-button-profile-update'
| 'copy-button-profile-update'
| 'disappear-set-button'
| 'decline-message-request'
| 'create-group-button'
| 'delete-message-request'
| 'accept-message-request'
| 'mentions-popup-row'
| 'session-id-signup'
| 'search-contacts-field'
| 'three-dot-loading-animation'
| 'recovery-phrase-input'
| 'display-name-input'
Expand Down

0 comments on commit 89e2115

Please sign in to comment.