Skip to content

Commit 55fb1d4

Browse files
authored
Merge pull request #1863 from session-foundation/chore-add-datatestids-convo-flags
chore: add datatestids to convo item flags
2 parents cab1e6a + 364dd7a commit 55fb1d4

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

ts/components/icon/MailWithUnreadIcon.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { SessionDataTestId } from 'react';
12
import styled from 'styled-components';
23
import type { SessionIconSize } from './Icons';
34
import { IconSizeToPxStr } from './SessionIcon';
@@ -9,8 +10,10 @@ const MailWithUnreadContainer = styled.div`
910
export function MailWithUnreadIcon({
1011
iconSize,
1112
style,
13+
dataTestId,
1214
}: {
1315
iconSize: SessionIconSize;
16+
dataTestId?: SessionDataTestId;
1417
style?: React.CSSProperties;
1518
}) {
1619
const sizePx = IconSizeToPxStr[iconSize];
@@ -22,6 +25,7 @@ export function MailWithUnreadIcon({
2225
height={sizePx}
2326
fill="none"
2427
viewBox="0 0 17 17"
28+
data-testid={dataTestId}
2529
>
2630
<path
2731
fill="currentColor"

ts/components/leftpane/conversation-list-item/HeaderItem.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const NotificationSettingIcon = () => {
3838
iconColor="currentColor"
3939
iconSize="small"
4040
style={{ flexShrink: 0 }}
41+
dataTestId="conversation-item-muted"
4142
/>
4243
);
4344
case 'mentions_only':
@@ -46,6 +47,7 @@ const NotificationSettingIcon = () => {
4647
iconType="bell"
4748
iconColor="currentColor"
4849
iconSize="small"
50+
dataTestId="conversation-item-mentions-only"
4951
style={{ flexShrink: 0 }}
5052
/>
5153
);
@@ -72,6 +74,7 @@ const PinIcon = () => {
7274
iconColor="currentColor"
7375
iconSize="small"
7476
style={{ flexShrink: 0 }}
77+
dataTestId="conversation-item-pinned"
7578
/>
7679
) : null;
7780
};
@@ -152,6 +155,7 @@ const AtSymbol = ({ conversationId }: WithConvoId) => {
152155
title="Open to latest mention"
153156
// eslint-disable-next-line @typescript-eslint/no-misused-promises
154157
onMouseDown={async e => openConvoToLastMention(e, conversationId)}
158+
data-testid="conversation-item-mentioned-us"
155159
>
156160
@
157161
</MentionAtSymbol>
@@ -185,14 +189,24 @@ const UnreadCount = ({ conversationId }: WithConvoId) => {
185189
: unreadMsgCount || ' ';
186190

187191
if (forcedUnread) {
188-
return <MailWithUnreadIcon iconSize="small" style={{ maxHeight: '100%' }} />;
192+
return (
193+
<MailWithUnreadIcon
194+
iconSize="small"
195+
style={{ maxHeight: '100%' }}
196+
dataTestId="conversation-item-forced-unread"
197+
/>
198+
);
189199
}
190200

191201
if (unreadMsgCount <= 0) {
192202
return null;
193203
}
194204

195-
return <StyledUnreadCount>{unreadWithOverflow}</StyledUnreadCount>;
205+
return (
206+
<StyledUnreadCount data-testid="conversation-item-unread-count">
207+
{unreadWithOverflow}
208+
</StyledUnreadCount>
209+
);
196210
};
197211

198212
export const ConversationListItemHeaderItem = () => {

ts/react.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@ declare module 'react' {
228228
| 'name'
229229
| 'count';
230230

231+
type ConversationItemFlagsIds =
232+
| 'conversation-item-muted'
233+
| 'conversation-item-pinned'
234+
| 'conversation-item-mentions-only'
235+
| 'conversation-item-forced-unread'
236+
| 'conversation-item-unread-count'
237+
| 'conversation-item-mentioned-us';
238+
231239
type SessionDataTestId =
232240
| 'group-member-status-text'
233241
| 'loading-spinner'
@@ -281,6 +289,9 @@ declare module 'react' {
281289
// Buttons
282290
| `${Buttons}-button`
283291

292+
// Conversation Item Flags
293+
| ConversationItemFlagsIds
294+
284295
// settings menu item types
285296
| `${MenuItems}-menu-item`
286297
| `${SettingsMenuItems}-settings-menu-item`

0 commit comments

Comments
 (0)