-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
chore(client): data-testid for message containers #11079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ const MessageAvatar = ({ iconData }: { iconData: TMessageIcon }) => ( | |
| const MessageBody = ({ message, messageLabel, fontSize }) => ( | ||
| <div | ||
| className={cn('relative flex w-11/12 flex-col', message.isCreatedByUser ? '' : 'agent-turn')} | ||
| data-testid={message.isCreatedByUser ? 'user-message' : 'assistant-message'} | ||
|
||
| > | ||
| <div className={cn('select-none font-semibold', fontSize)}>{messageLabel}</div> | ||
| <SearchContent message={message} /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -164,6 +164,7 @@ const MessageRender = memo( | |||||||||||||
| 'relative flex w-11/12 flex-col', | ||||||||||||||
| msg.isCreatedByUser ? 'user-turn' : 'agent-turn', | ||||||||||||||
| )} | ||||||||||||||
| data-testid={msg.isCreatedByUser ? 'user-message' : 'assistant-message'} | ||||||||||||||
|
||||||||||||||
| data-testid={msg.isCreatedByUser ? 'user-message' : 'assistant-message'} | |
| data-testid={ | |
| msg.isCreatedByUser | |
| ? `user-message-${msg.messageId}` | |
| : `assistant-message-${msg.messageId}` | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -164,6 +164,7 @@ const ContentRender = memo( | |||||||||||||
| 'relative flex w-11/12 flex-col', | ||||||||||||||
| msg.isCreatedByUser ? 'user-turn' : 'agent-turn', | ||||||||||||||
| )} | ||||||||||||||
| data-testid={msg.isCreatedByUser ? 'user-message' : 'assistant-message'} | ||||||||||||||
|
||||||||||||||
| data-testid={msg.isCreatedByUser ? 'user-message' : 'assistant-message'} | |
| data-testid={ | |
| msg.isCreatedByUser | |
| ? `user-message-${msg.messageId}` | |
| : `assistant-message-${msg.messageId}` | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -66,6 +66,7 @@ export default function Message(props: TMessageProps) { | |||||
| </div> | ||||||
| <div | ||||||
| className={cn('relative flex w-11/12 flex-col', isCreatedByUser ? '' : 'agent-turn')} | ||||||
| data-testid={isCreatedByUser ? 'user-message' : 'assistant-message'} | ||||||
|
||||||
| data-testid={isCreatedByUser ? 'user-message' : 'assistant-message'} | |
| data-testid={isCreatedByUser ? `user-message-${messageId}` : `assistant-message-${messageId}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data-testid attribute should be unique within a page. In a conversation with multiple messages, there will be multiple elements with the same 'user-message' or 'assistant-message' test ID, which violates HTML best practices and makes E2E testing unreliable. Consider making the test ID unique by incorporating the message ID, for example:
data-testid={isCreatedByUser ?user-message-${messageId}:assistant-message-${messageId}}