@@ -17,6 +17,12 @@ const MessageListContainer = styled.div`
1717 flex: 1;
1818 overflow-y: auto;
1919 padding: 1rem;
20+ /* Add test id */
21+
22+ &[data-testid] {
23+ outline: none;
24+ }
25+
2026 display: flex;
2127 flex-direction: column;
2228 gap: 1rem;
@@ -152,27 +158,27 @@ const MessageItem = styled.div<{ type: MessageType }>`
152158 perspective: inherit;
153159
154160 background-color: ${ ( { type} ) => {
155- switch ( type ) {
156- case 'user' :
157- return ( { theme} ) => theme . colors . primary ;
158- case 'system' :
159- return ( { theme} ) => theme . colors . secondary ;
160- case 'error' :
161- return ( { theme} ) => `linear-gradient(135deg, ${ theme . colors . error } , ${ theme . colors . warning } )` ;
162- case 'loading' :
163- return ( { theme} ) => theme . colors . surface ;
164- case 'assistant' :
165- return ( { theme} ) => theme . colors . surface ;
166- case 'reference' :
167- return ( { theme} ) => theme . colors . surface ;
168- default :
169- return ( { theme} ) => theme . colors . surface ;
170- }
171- } } ;
161+ switch ( type ) {
162+ case 'user' :
163+ return ( { theme} ) => theme . colors . primary ;
164+ case 'system' :
165+ return ( { theme} ) => theme . colors . secondary ;
166+ case 'error' :
167+ return ( { theme} ) => `linear-gradient(135deg, ${ theme . colors . error } , ${ theme . colors . warning } )` ;
168+ case 'loading' :
169+ return ( { theme} ) => theme . colors . surface ;
170+ case 'assistant' :
171+ return ( { theme} ) => theme . colors . surface ;
172+ case 'reference' :
173+ return ( { theme} ) => theme . colors . surface ;
174+ default :
175+ return ( { theme} ) => theme . colors . surface ;
176+ }
177+ } } ;
172178 color: ${ ( { type, theme} ) =>
173- type === 'user' || type === 'system' || type === 'error'
174- ? '#fff'
175- : theme . colors . text . primary } ;
179+ type === 'user' || type === 'system' || type === 'error'
180+ ? '#fff'
181+ : theme . colors . text . primary } ;
176182
177183 &:hover {
178184 transform: translate3d(0, -3px, 0);
@@ -376,7 +382,11 @@ const MessageList: React.FC<MessageListProps> = ({messages: propMessages}) => {
376382 } , [ finalMessages ] ) ;
377383
378384 return (
379- < MessageListContainer ref = { messageListRef } className = { containerClassName } >
385+ < MessageListContainer
386+ data-testid = "message-list"
387+ id = "message-list-container"
388+ ref = { messageListRef } className = { containerClassName }
389+ >
380390 { finalMessages . map ( ( message ) => {
381391 console . debug ( 'MessageList - Rendering message' , {
382392 id : message . id ,
@@ -387,10 +397,13 @@ const MessageList: React.FC<MessageListProps> = ({messages: propMessages}) => {
387397 return < MessageItem
388398 key = { message . id }
389399 type = { message . type }
400+ data-testid = { `message-${ message . id } ` }
401+ id = { `message-${ message . id } ` }
390402 >
391403 { < MessageContent
392404 className = "message-body"
393405 onClick = { ! isArchive ? handleClick : undefined }
406+ data-testid = { `message-content-${ message . id } ` }
394407 dangerouslySetInnerHTML = { {
395408 __html : message . content
396409 } }
0 commit comments