-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security solution] Improve AI connector error handling (#167674)
- Loading branch information
1 parent
40c3ebb
commit 2174a95
Showing
20 changed files
with
312 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
x-pack/plugins/security_solution/public/assistant/get_comments/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getComments } from '.'; | ||
import type { ConversationRole } from '@kbn/elastic-assistant/impl/assistant_context/types'; | ||
|
||
const user: ConversationRole = 'user'; | ||
describe('getComments', () => { | ||
it('Does not add error state message has no error', () => { | ||
const currentConversation = { | ||
apiConfig: {}, | ||
id: '1', | ||
messages: [ | ||
{ | ||
role: user, | ||
content: 'Hello {name}', | ||
timestamp: '2022-01-01', | ||
isError: false, | ||
}, | ||
], | ||
}; | ||
const lastCommentRef = { current: null }; | ||
const showAnonymizedValues = false; | ||
|
||
const result = getComments({ currentConversation, lastCommentRef, showAnonymizedValues }); | ||
expect(result[0].eventColor).toEqual(undefined); | ||
}); | ||
it('Adds error state when message has error', () => { | ||
const currentConversation = { | ||
apiConfig: {}, | ||
id: '1', | ||
messages: [ | ||
{ | ||
role: user, | ||
content: 'Hello {name}', | ||
timestamp: '2022-01-01', | ||
isError: true, | ||
}, | ||
], | ||
}; | ||
const lastCommentRef = { current: null }; | ||
const showAnonymizedValues = false; | ||
|
||
const result = getComments({ currentConversation, lastCommentRef, showAnonymizedValues }); | ||
expect(result[0].eventColor).toEqual('danger'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.