-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security Solution] expanded flyout - right section - json tab implementation #152935
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import type { Story } from '@storybook/react'; | ||
import { RightPanelContext } from '../context'; | ||
import { JsonTab } from './json_tab'; | ||
|
||
export default { | ||
component: JsonTab, | ||
title: 'Flyout/JsonTab', | ||
}; | ||
|
||
export const Default: Story<void> = () => { | ||
const contextValue = { | ||
searchHit: { | ||
some_field: 'some_value', | ||
}, | ||
} as unknown as RightPanelContext; | ||
|
||
return ( | ||
<RightPanelContext.Provider value={contextValue}> | ||
<JsonTab /> | ||
</RightPanelContext.Provider> | ||
); | ||
}; | ||
|
||
export const Error: Story<void> = () => { | ||
const contextValue = { | ||
searchHit: null, | ||
} as unknown as RightPanelContext; | ||
|
||
return ( | ||
<RightPanelContext.Provider value={contextValue}> | ||
<JsonTab /> | ||
</RightPanelContext.Provider> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { RightPanelContext } from '../context'; | ||
import { JsonTab } from './json_tab'; | ||
import { JSON_TAB_ERROR_TEST_ID, JSON_TAB_CONTENT_TEST_ID } from './test_ids'; | ||
|
||
describe('<JsonTab />', () => { | ||
it('should render code block component', () => { | ||
const contextValue = { | ||
searchHit: { | ||
some_field: 'some_value', | ||
}, | ||
} as unknown as RightPanelContext; | ||
|
||
const { getByTestId } = render( | ||
<RightPanelContext.Provider value={contextValue}> | ||
<JsonTab /> | ||
</RightPanelContext.Provider> | ||
); | ||
|
||
expect(getByTestId(JSON_TAB_CONTENT_TEST_ID)).toBeInTheDocument(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth it to make sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same reasoning I was having with the table, as I'm reusing the existing |
||
}); | ||
|
||
it('should render error message on invalid searchHit', () => { | ||
const contextValue = { | ||
searchHit: null, | ||
} as unknown as RightPanelContext; | ||
|
||
const { getByTestId, getByText } = render( | ||
<RightPanelContext.Provider value={contextValue}> | ||
<JsonTab /> | ||
</RightPanelContext.Provider> | ||
); | ||
|
||
expect(getByTestId(JSON_TAB_ERROR_TEST_ID)).toBeInTheDocument(); | ||
expect(getByText('Unable to display document information')).toBeInTheDocument(); | ||
expect( | ||
getByText('There was an error displaying the document fields and values') | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const ERROR_TITLE = i18n.translate( | ||
'xpack.securitySolution.flyout.documentDetails.errorTitle', | ||
{ | ||
defaultMessage: 'Unable to display document information', | ||
} | ||
); | ||
|
||
export const ERROR_MESSAGE = i18n.translate( | ||
'xpack.securitySolution.flyout.documentDetails.errorMessage', | ||
{ defaultMessage: 'There was an error displaying the document fields and values' } | ||
); |
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.
👍🏾