[SIEM] fix tooltip of notes (#71342)
* fix tooltip of notes * fix unit test * update notes tooltip * fix unit test Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
781220e071
commit
cb4020f3fc
|
@ -9,8 +9,10 @@ import { useSelector } from 'react-redux';
|
|||
|
||||
import { TestProviders, mockTimelineModel } from '../../../../../common/mock';
|
||||
import { DEFAULT_ACTIONS_COLUMN_WIDTH } from '../constants';
|
||||
import * as i18n from '../translations';
|
||||
|
||||
import { Actions } from '.';
|
||||
import { TimelineType } from '../../../../../../common/types/timeline';
|
||||
|
||||
jest.mock('react-redux', () => {
|
||||
const origin = jest.requireActual('react-redux');
|
||||
|
@ -202,6 +204,73 @@ describe('Actions', () => {
|
|||
expect(toggleShowNotes).toBeCalled();
|
||||
});
|
||||
|
||||
test('it renders correct tooltip for NotesButton - timeline', () => {
|
||||
const toggleShowNotes = jest.fn();
|
||||
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<Actions
|
||||
actionsColumnWidth={DEFAULT_ACTIONS_COLUMN_WIDTH}
|
||||
associateNote={jest.fn()}
|
||||
checked={false}
|
||||
expanded={false}
|
||||
eventId="abc"
|
||||
eventIsPinned={false}
|
||||
getNotesByIds={jest.fn()}
|
||||
loading={false}
|
||||
loadingEventIds={[]}
|
||||
noteIds={[]}
|
||||
onEventToggled={jest.fn()}
|
||||
onPinClicked={jest.fn()}
|
||||
onRowSelected={jest.fn()}
|
||||
showCheckboxes={false}
|
||||
showNotes={false}
|
||||
toggleShowNotes={toggleShowNotes}
|
||||
updateNote={jest.fn()}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
expect(wrapper.find('[data-test-subj="add-note"]').prop('toolTip')).toEqual(i18n.NOTES_TOOLTIP);
|
||||
});
|
||||
|
||||
test('it renders correct tooltip for NotesButton - timeline template', () => {
|
||||
(useSelector as jest.Mock).mockReturnValue({
|
||||
...mockTimelineModel,
|
||||
timelineType: TimelineType.template,
|
||||
});
|
||||
const toggleShowNotes = jest.fn();
|
||||
|
||||
const wrapper = mount(
|
||||
<TestProviders>
|
||||
<Actions
|
||||
actionsColumnWidth={DEFAULT_ACTIONS_COLUMN_WIDTH}
|
||||
associateNote={jest.fn()}
|
||||
checked={false}
|
||||
expanded={false}
|
||||
eventId="abc"
|
||||
eventIsPinned={false}
|
||||
getNotesByIds={jest.fn()}
|
||||
loading={false}
|
||||
loadingEventIds={[]}
|
||||
noteIds={[]}
|
||||
onEventToggled={jest.fn()}
|
||||
onPinClicked={jest.fn()}
|
||||
onRowSelected={jest.fn()}
|
||||
showCheckboxes={false}
|
||||
showNotes={false}
|
||||
toggleShowNotes={toggleShowNotes}
|
||||
updateNote={jest.fn()}
|
||||
/>
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
expect(wrapper.find('[data-test-subj="add-note"]').prop('toolTip')).toEqual(
|
||||
i18n.NOTES_DISABLE_TOOLTIP
|
||||
);
|
||||
(useSelector as jest.Mock).mockReturnValue(mockTimelineModel);
|
||||
});
|
||||
|
||||
test('it does NOT render a pin button when isEventViewer is true', () => {
|
||||
const onPinClicked = jest.fn();
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import { EuiButtonIcon, EuiCheckbox, EuiLoadingSpinner, EuiToolTip } from '@elas
|
|||
|
||||
import { Note } from '../../../../../common/lib/note';
|
||||
import { StoreState } from '../../../../../common/store/types';
|
||||
import { TimelineType } from '../../../../../../common/types/timeline';
|
||||
|
||||
import { TimelineModel } from '../../../../store/timeline/model';
|
||||
|
||||
|
@ -170,7 +171,11 @@ export const Actions = React.memo<Props>(
|
|||
status={timeline.status}
|
||||
timelineType={timeline.timelineType}
|
||||
toggleShowNotes={toggleShowNotes}
|
||||
toolTip={timeline.timelineType ? i18n.NOTES_DISABLE_TOOLTIP : i18n.NOTES_TOOLTIP}
|
||||
toolTip={
|
||||
timeline.timelineType === TimelineType.template
|
||||
? i18n.NOTES_DISABLE_TOOLTIP
|
||||
: i18n.NOTES_TOOLTIP
|
||||
}
|
||||
updateNote={updateNote}
|
||||
/>
|
||||
</EventsTdContent>
|
||||
|
|
|
@ -223,7 +223,7 @@ describe('helpers', () => {
|
|||
eventHasNotes: false,
|
||||
timelineType: TimelineType.template,
|
||||
})
|
||||
).toEqual('This event cannot be pinned because it is filtered by a timeline template');
|
||||
).toEqual('This event may not be pinned while editing a template timeline');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ import { i18n } from '@kbn/i18n';
|
|||
export const NOTES_TOOLTIP = i18n.translate(
|
||||
'xpack.securitySolution.timeline.body.notes.addOrViewNotesForThisEventTooltip',
|
||||
{
|
||||
defaultMessage: 'Add or view notes for this event',
|
||||
defaultMessage: 'Add notes for this event',
|
||||
}
|
||||
);
|
||||
|
||||
export const NOTES_DISABLE_TOOLTIP = i18n.translate(
|
||||
'xpack.securitySolution.timeline.body.notes.disableEventTooltip',
|
||||
{
|
||||
defaultMessage: 'Add notes for event filtered by a timeline template is not allowed',
|
||||
defaultMessage: 'Notes may not be added here while editing a template timeline',
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -48,7 +48,7 @@ export const PINNED_WITH_NOTES = i18n.translate(
|
|||
export const DISABLE_PIN = i18n.translate(
|
||||
'xpack.securitySolution.timeline.body.pinning.disablePinnnedTooltip',
|
||||
{
|
||||
defaultMessage: 'This event cannot be pinned because it is filtered by a timeline template',
|
||||
defaultMessage: 'This event may not be pinned while editing a template timeline',
|
||||
}
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue