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', () => {
18
18
expect ( screen . getByTestId ( 'ai-chat-error-report-link' ) ) . toBeInTheDocument ( )
19
19
20
20
expect ( screen . getByTestId ( 'ai-chat-error-restart-session-btn' ) ) . toBeInTheDocument ( )
21
+ expect ( screen . getByTestId ( 'ai-chat-error-report-link' ) ) . toBeInTheDocument ( )
21
22
} )
22
23
23
24
it ( 'should render rate limit error' , ( ) => {
@@ -31,6 +32,7 @@ describe('ErrorMessage', () => {
31
32
expect ( screen . getByTestId ( 'ai-chat-error-message' ) ) . toHaveTextContent ( AI_CHAT_ERRORS . rateLimit ( 100 ) )
32
33
33
34
expect ( screen . queryByTestId ( 'ai-chat-error-restart-session-btn' ) ) . not . toBeInTheDocument ( )
35
+ expect ( screen . queryByTestId ( 'ai-chat-error-report-link' ) ) . not . toBeInTheDocument ( )
34
36
} )
35
37
36
38
it ( 'should render tokens limit error' , ( ) => {
@@ -43,7 +45,8 @@ describe('ErrorMessage', () => {
43
45
44
46
expect ( screen . getByTestId ( 'ai-chat-error-message' ) ) . toHaveTextContent ( AI_CHAT_ERRORS . tokenLimit ( ) )
45
47
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 ( )
47
50
} )
48
51
49
52
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 = [
26
26
CustomErrorCodes . AiQueryRateLimitToken ,
27
27
]
28
28
29
+ const ERROR_CODES_WITHOUT_REPORT_ISSUE = [
30
+ CustomErrorCodes . AiQueryRateLimitRequest ,
31
+ CustomErrorCodes . AiQueryRateLimitToken ,
32
+ CustomErrorCodes . AiQueryRateLimitMaxTokens ,
33
+ ]
34
+
29
35
const ErrorMessage = ( props : Props ) => {
30
36
const { error, onRestart } = props
31
37
@@ -51,21 +57,26 @@ const ErrorMessage = (props: Props) => {
51
57
52
58
const isShowRestart = ! ( error . errorCode && ERROR_CODES_WITHOUT_RESTART . includes ( error . errorCode ) )
53
59
&& error . statusCode !== ApiStatusCode . Timeout
60
+ const isShowReportIssue = ! ( error . errorCode && ERROR_CODES_WITHOUT_REPORT_ISSUE . includes ( error . errorCode ) )
54
61
55
62
return (
56
63
< >
57
64
< div className = { styles . errorMessage } data-testid = "ai-chat-error-message" >
58
65
{ 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
+ ) }
69
80
</ div >
70
81
{ isShowRestart && (
71
82
< RestartChat
You can’t perform that action at this time.
0 commit comments