File tree Expand file tree Collapse file tree 2 files changed +25
-11
lines changed
redisinsight/ui/src/components/side-panels/panels/ai-assistant/components/shared/error-message Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ describe('ErrorMessage', () => {
1818 expect ( screen . getByTestId ( 'ai-chat-error-report-link' ) ) . toBeInTheDocument ( )
1919
2020 expect ( screen . getByTestId ( 'ai-chat-error-restart-session-btn' ) ) . toBeInTheDocument ( )
21+ expect ( screen . getByTestId ( 'ai-chat-error-report-link' ) ) . toBeInTheDocument ( )
2122 } )
2223
2324 it ( 'should render rate limit error' , ( ) => {
@@ -31,6 +32,7 @@ describe('ErrorMessage', () => {
3132 expect ( screen . getByTestId ( 'ai-chat-error-message' ) ) . toHaveTextContent ( AI_CHAT_ERRORS . rateLimit ( 100 ) )
3233
3334 expect ( screen . queryByTestId ( 'ai-chat-error-restart-session-btn' ) ) . not . toBeInTheDocument ( )
35+ expect ( screen . queryByTestId ( 'ai-chat-error-report-link' ) ) . not . toBeInTheDocument ( )
3436 } )
3537
3638 it ( 'should render tokens limit error' , ( ) => {
@@ -43,7 +45,8 @@ describe('ErrorMessage', () => {
4345
4446 expect ( screen . getByTestId ( 'ai-chat-error-message' ) ) . toHaveTextContent ( AI_CHAT_ERRORS . tokenLimit ( ) )
4547
46- expect ( screen . queryByTestId ( 'ai-chat-error-restart-session-btn' ) ) . not . toBeInTheDocument ( )
48+ expect ( screen . getByTestId ( 'ai-chat-error-restart-session-btn' ) ) . toBeInTheDocument ( )
49+ expect ( screen . queryByTestId ( 'ai-chat-error-report-link' ) ) . not . toBeInTheDocument ( )
4750 } )
4851
4952 it ( 'should not render restart button with timeout error' , ( ) => {
Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ const ERROR_CODES_WITHOUT_RESTART = [
2626 CustomErrorCodes . AiQueryRateLimitToken ,
2727]
2828
29+ const ERROR_CODES_WITHOUT_REPORT_ISSUE = [
30+ CustomErrorCodes . AiQueryRateLimitRequest ,
31+ CustomErrorCodes . AiQueryRateLimitToken ,
32+ CustomErrorCodes . AiQueryRateLimitMaxTokens ,
33+ ]
34+
2935const ErrorMessage = ( props : Props ) => {
3036 const { error, onRestart } = props
3137
@@ -51,21 +57,26 @@ const ErrorMessage = (props: Props) => {
5157
5258 const isShowRestart = ! ( error . errorCode && ERROR_CODES_WITHOUT_RESTART . includes ( error . errorCode ) )
5359 && error . statusCode !== ApiStatusCode . Timeout
60+ const isShowReportIssue = ! ( error . errorCode && ERROR_CODES_WITHOUT_REPORT_ISSUE . includes ( error . errorCode ) )
5461
5562 return (
5663 < >
5764 < div className = { styles . errorMessage } data-testid = "ai-chat-error-message" >
5865 { getErrorMessage ( error ) }
59- { ' ' }
60- < a
61- className = "link-underline"
62- href = { EXTERNAL_LINKS . githubIssues }
63- data-testid = "ai-chat-error-report-link"
64- target = "_blank"
65- rel = "noreferrer"
66- >
67- report the issue
68- </ a >
66+ { isShowReportIssue && (
67+ < >
68+ { ' ' }
69+ < a
70+ className = "link-underline"
71+ href = { EXTERNAL_LINKS . githubIssues }
72+ data-testid = "ai-chat-error-report-link"
73+ target = "_blank"
74+ rel = "noreferrer"
75+ >
76+ report the issue
77+ </ a >
78+ </ >
79+ ) }
6980 </ div >
7081 { isShowRestart && (
7182 < RestartChat
You can’t perform that action at this time.
0 commit comments