@cccsaurora/howler-ui 2.17.0-dev.494 → 2.17.0-dev.497
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/elements/hit/HitBanner.js +1 -1
- package/components/routes/help/BundleDocumentation.d.ts +3 -0
- package/components/routes/help/BundleDocumentation.js +12 -0
- package/components/routes/help/HitDocumentation.js +3 -1
- package/components/routes/help/markdown/en/bundles.md.js +1 -0
- package/components/routes/help/markdown/fr/bundles.md.js +1 -0
- package/components/routes/hits/search/HitContextMenu.js +25 -1
- package/components/routes/hits/search/HitContextMenu.test.js +140 -0
- package/locales/en/translation.json +1 -0
- package/locales/fr/translation.json +1 -0
- package/package.json +1 -1
|
@@ -116,6 +116,6 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
|
|
|
116
116
|
width: theme.spacing(3)
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
], children: [_jsx(HitTimestamp, { hit: hit, layout: layout }), showAssigned && _jsx(Assigned, { hit: hit, layout: layout }), _jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, children: [_jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status) && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, size: layout !== HitLayout.COMFY ? 'small' : 'medium', color: "primary" })), _jsx(Chip, { size: layout !== HitLayout.COMFY ? 'small' : 'medium', label: t('hit.header.bundlesize', { hits: hit.howler.
|
|
119
|
+
], children: [_jsx(HitTimestamp, { hit: hit, layout: layout }), showAssigned && _jsx(Assigned, { hit: hit, layout: layout }), _jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, children: [_jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status) && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, size: layout !== HitLayout.COMFY ? 'small' : 'medium', color: "primary" })), hit.howler.is_bundle && (_jsx(Chip, { size: layout !== HitLayout.COMFY ? 'small' : 'medium', label: t('hit.header.bundlesize', { hits: hit.howler.hits.length }) }))] }), howlerPluginStore.plugins.flatMap(plugin => pluginStore.executeFunction(`${plugin}.status`, { hit, layout }))] })] }));
|
|
120
120
|
};
|
|
121
121
|
export default HitBanner;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Markdown from '@cccsaurora/howler-ui/components/elements/display/Markdown';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import BUNDLES_EN from './markdown/en/bundles.md';
|
|
6
|
+
import BUNDLES_FR from './markdown/fr/bundles.md';
|
|
7
|
+
const BundleDocumentation = () => {
|
|
8
|
+
const { i18n } = useTranslation();
|
|
9
|
+
const md = useMemo(() => (i18n.language === 'en' ? BUNDLES_EN : BUNDLES_FR), [i18n.language]);
|
|
10
|
+
return _jsx(Markdown, { md: md });
|
|
11
|
+
};
|
|
12
|
+
export default BundleDocumentation;
|
|
@@ -5,6 +5,7 @@ import { useScrollRestoration } from '@cccsaurora/howler-ui/components/hooks/use
|
|
|
5
5
|
import { useCallback, useState } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { useSearchParams } from 'react-router-dom';
|
|
8
|
+
import BundleDocumentation from './BundleDocumentation';
|
|
8
9
|
import HelpTabs from './components/HelpTabs';
|
|
9
10
|
import HitBannerDocumentation from './HitBannerDocumentation';
|
|
10
11
|
import HitLabelsDocumentation from './HitLabelsDocumentation';
|
|
@@ -22,7 +23,8 @@ const HitDocumentation = () => {
|
|
|
22
23
|
searchParams.set('tab', _tab);
|
|
23
24
|
setSearchParams(new URLSearchParams(searchParams));
|
|
24
25
|
}, [searchParams, setSearchParams]);
|
|
25
|
-
return (_jsx(PageCenter, { margin: 4, width: "100%", maxWidth: "1750px", textAlign: "left", children: _jsxs(Stack, { sx: { flexDirection: useHorizontal ? 'column' : 'row', '& h1': { mt: 0 } }, children: [_jsxs(HelpTabs, { value: tab, children: [_jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.schema.title') }), value: "schema", onClick: () => onChange('schema') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.banner.title') }), value: "header", onClick: () => onChange('header') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.links.title') }), value: "links", onClick: () => onChange('links') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.labels.title') }), value: "labels", onClick: () => onChange('labels') })] }), _jsx(Box, { children: {
|
|
26
|
+
return (_jsx(PageCenter, { margin: 4, width: "100%", maxWidth: "1750px", textAlign: "left", children: _jsxs(Stack, { sx: { flexDirection: useHorizontal ? 'column' : 'row', '& h1': { mt: 0 } }, children: [_jsxs(HelpTabs, { value: tab, children: [_jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.schema.title') }), value: "schema", onClick: () => onChange('schema') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.banner.title') }), value: "header", onClick: () => onChange('header') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.bundle.title') }), value: "bundle", onClick: () => onChange('bundle') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.links.title') }), value: "links", onClick: () => onChange('links') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.labels.title') }), value: "labels", onClick: () => onChange('labels') })] }), _jsx(Box, { children: {
|
|
27
|
+
bundle: () => _jsx(BundleDocumentation, {}),
|
|
26
28
|
header: () => _jsx(HitBannerDocumentation, {}),
|
|
27
29
|
links: () => _jsx(HitLinksDocumentation, {}),
|
|
28
30
|
labels: () => _jsx(HitLabelsDocumentation, {}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "<!-- docs/ingestion/bundles.md -->\n\n# Howler Hit Bundles\n\nHit bundles can be used to easily package together a large number of similar alerts, allowing analysts to easily triage them as a single incident. For example, consider a single computer that repeatedly makes a network call to `baddomain.ru` - while an alert may be generated for every instance of this computer hitting that domain, it makes sense for analysts to treat all these alerts as a single case.\n\n## Creating bundles through the Howler Client\n\nThere are a couple of ways to create a bundle through the howler client:\n\n```python\nfrom howler_client import get_client\n\nhowler = get_client(\"https://howler.dev.analysis.cyber.gc.ca\")\n\n\"\"\"Creating a howler bundle and the hits at the same time\"\"\"\nhowler.bundle.create(\n # First argument is the bundle hit\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n },\n # Second argument is a hit or list of hits to include in the bundle\n [\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n },\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n }\n ]\n)\n\n\"\"\"Creating a howler bundle from existing hits\"\"\"\nhowler.bundle.create(\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0,\n \"howler.hits\": [\"YcUsL8QsjmwwIdstieROk\", \"6s7MztwuSvz6tM0PgGJhvz\"]\n },\n # Note: In future releases, you won't need to include this argument\n []\n)\n\n\n\"\"\"Creating from a map\"\"\"\nbundle_hit = {\n \"score\": 0,\n \"bundle\": True\n}\n\nmap = {\n \"score\": [\"howler.score\"],\n \"bundle\": [\"howler.is_bundle\"]\n}\n\nhowler.bundle.create_from_map(\"example-test\", bundle_hit, map, [{\"score\": 0}])\n```\n\n## Viewing bundles on the Howler UI\n\nIn order to view created bundles on the Howler UI, you can use the query `howler.is_bundle:true`. This will provide a list of created bundles you can look through.\n\nClicking on a bundle will open up a slightly different search UI to normal. In this case, we automatically filter the search results to include only hits that are included in the bundle. To make this obvious, the header representing the bundle will appear above the search bar.\n\nYou can continue to filter through hits using the same queries as usual, and view them as usual. When triaging a bundle, assessing it will apply this assessment to all hits in the bundle, **except those that have already been triaged**. That is, if the bundle is open, all open hits will be assessed when you assess it.\n\nBundles also have a **Summary** tab not available for regular hits. This summary tab will aid you in aggregating data about all the hits in the bundle. Simply open the tab and click \"Create Summary\". Note that this may take some time, as a large number of queries are being run to aggregate the data.\n"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "<!-- docs/ingestion/bundles.fr.md -->\n\n# Les groupes des hits Howler\n\nLes groupes des hits peuvent \u00eatre utilis\u00e9s pour regrouper facilement un grand nombre d'alertes similaires, ce qui permet aux analystes de les traiter comme un seul incident. Prenons l'exemple d'un ordinateur qui effectue \u00e0 plusieurs reprises un appel r\u00e9seau vers `baddomain.ru` - bien qu'une alerte puisse \u00eatre g\u00e9n\u00e9r\u00e9e pour chaque cas o\u00f9 cet ordinateur acc\u00e8de \u00e0 ce domaine, il est logique que les analystes traitent toutes ces alertes comme un seul et m\u00eame cas.\n\n## Cr\u00e9ation de groupes via le client Howler\n\nIl y a plusieurs fa\u00e7ons de cr\u00e9er un groupe via le client Howler:\n\n```python\nfrom howler_client import get_client\n\nhowler = get_client(\"https://howler.dev.analysis.cyber.gc.ca\")\n\n\"\"\"Cr\u00e9ation simultan\u00e9e d'un groupe howler et de hits\"\"\"\nhowler.bundle.create(\n # Le premier argument est le hit de l'offre group\u00e9e\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n },\n # Le deuxi\u00e8me argument est un hit ou une liste de hits \u00e0 inclure dans l'offre group\u00e9e.\n [\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n },\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n }\n ]\n)\n\n\"\"\"Cr\u00e9ation d'un groupe howler \u00e0 partir de hits existants\"\"\"\nhowler.bundle.create(\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0,\n \"howler.hits\": [\"YcUsL8QsjmwwIdstieROk\", \"6s7MztwuSvz6tM0PgGJhvz\"]\n },\n # Noter: Dans les prochaines versions, vous n'aurez plus besoin d'inclure cet argument.\n []\n)\n\n\n\"\"\"Cr\u00e9ation \u00e0 partir d'une carte\"\"\"\nbundle_hit = {\n \"score\": 0,\n \"bundle\": True\n}\n\nmap = {\n \"score\": [\"howler.score\"],\n \"bundle\": [\"howler.is_bundle\"]\n}\n\nhowler.bundle.create_from_map(\"example-test\", bundle_hit, map, [{\"score\": 0}])\n```\n\n## Visualiser les groupes sur l'interface utilisateur de Howler\n\nAfin de visualiser les groupes cr\u00e9\u00e9s sur l'interface utilisateur de Howler, vous pouvez utiliser la requ\u00eate `howler.is_bundle:true`. Cela fournira une liste de groupes cr\u00e9\u00e9s que vous pourrez consulter.\n\nEn cliquant sur un groupe, vous ouvrirez une interface de recherche l\u00e9g\u00e8rement diff\u00e9rente de l'interface normale. Dans ce cas, nous filtrons automatiquement les r\u00e9sultats de la recherche pour n'inclure que les r\u00e9sultats inclus dans le groupe. Pour que cela soit \u00e9vident, l'en-t\u00eate repr\u00e9sentant le groupe appara\u00eet au-dessus de la barre de recherche.\n\nVous pouvez continuer \u00e0 filtrer les r\u00e9sultats en utilisant les m\u00eames requ\u00eates que d'habitude et \u00e0 les visualiser comme d'habitude. Lors du triage d'un groupe, son \u00e9valuation s'appliquera \u00e0 tous les hits du groupe, **sauf ceux qui ont d\u00e9j\u00e0 \u00e9t\u00e9 tri\u00e9s**. En d'autres termes, si le groupe est ouvert, tous les hits ouverts seront \u00e9valu\u00e9s lorsque vous l'\u00e9valuerez.\n\nLes groupes disposent \u00e9galement d'un onglet **R\u00e9sum\u00e9** qui n'est pas disponible pour les hits ordinaires. Cet onglet vous aidera \u00e0 regrouper les donn\u00e9es relatives \u00e0 tous les r\u00e9sultats du groupe. Il suffit d'ouvrir l'onglet et de cliquer sur \"Cr\u00e9er un sommaire\". Notez que cette op\u00e9ration peut prendre un certain temps, car un grand nombre de requ\u00eates sont ex\u00e9cut\u00e9es pour agr\u00e9ger les donn\u00e9es.\n"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Assignment, Edit, HowToVote, KeyboardArrowRight, OpenInNew, QueryStats, RemoveCircleOutline, SettingsSuggest, Terminal } from '@mui/icons-material';
|
|
2
|
+
import { AddCircleOutline, Assignment, Edit, HowToVote, KeyboardArrowRight, OpenInNew, QueryStats, RemoveCircleOutline, SettingsSuggest, Terminal } from '@mui/icons-material';
|
|
3
3
|
import { Box, Divider, Fade, ListItemIcon, ListItemText, Menu, MenuItem, MenuList, Paper } from '@mui/material';
|
|
4
4
|
import api from '@cccsaurora/howler-ui/api';
|
|
5
5
|
import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
|
|
@@ -198,6 +198,30 @@ const HitContextMenu = ({ children, getSelectedId, Component = Box }) => {
|
|
|
198
198
|
newQuery += `-${key}:"${sanitizeLuceneQuery(value.toString())}"`;
|
|
199
199
|
}
|
|
200
200
|
return (_jsx(MenuItem, { onClick: () => setQuery(newQuery), children: _jsx(ListItemText, { children: key }) }, key));
|
|
201
|
+
}) }) }) })] }), _jsxs(MenuItem, { id: "includes-menu-item", sx: { position: 'relative' }, onMouseEnter: ev => setShow(_show => ({ ..._show, includes: ev.target })), onMouseLeave: () => setShow(_show => ({ ..._show, includes: null })), children: [_jsx(ListItemIcon, { children: _jsx(AddCircleOutline, {}) }), _jsx(ListItemText, { sx: { flex: 1 }, children: t('hit.panel.include') }), _jsx(KeyboardArrowRight, { fontSize: "small", sx: { color: 'text.secondary', mr: -1 } }), _jsx(Fade, { in: !!show.includes, unmountOnExit: true, children: _jsx(Paper, { id: "includes-submenu", sx: calculateSubMenuStyles(show.includes), elevation: 8, children: _jsx(MenuList, { sx: { p: 0 }, dense: true, role: "group", children: template?.keys.map(key => {
|
|
202
|
+
// Build inclusion query based on current query and field vacccccbkrcudeecdukjjikjinhbknblnuhnbhvdjcrdhj
|
|
203
|
+
// lue. If default, we include default query
|
|
204
|
+
let newQuery = `(${query}) AND `;
|
|
205
|
+
const value = get(hit, key);
|
|
206
|
+
if (!value) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
else if (Array.isArray(value)) {
|
|
210
|
+
// Handle array values by including all items
|
|
211
|
+
const sanitizedValues = value
|
|
212
|
+
.map(toString)
|
|
213
|
+
.filter(val => !!val)
|
|
214
|
+
.map(val => `"${sanitizeLuceneQuery(val)}"`);
|
|
215
|
+
if (sanitizedValues.length < 1) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
newQuery += `${key}:(${sanitizedValues.join(' OR ')})`;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
// Handle single value
|
|
222
|
+
newQuery += `${key}:"${sanitizeLuceneQuery(value.toString())}"`;
|
|
223
|
+
}
|
|
224
|
+
return (_jsx(MenuItem, { onClick: () => setQuery(newQuery), children: _jsx(ListItemText, { children: key }) }, key));
|
|
201
225
|
}) }) }) })] })] }))] })] }));
|
|
202
226
|
};
|
|
203
227
|
export default HitContextMenu;
|
|
@@ -623,6 +623,132 @@ describe('HitContextMenu', () => {
|
|
|
623
623
|
});
|
|
624
624
|
});
|
|
625
625
|
});
|
|
626
|
+
describe('Inclusion Filter Functionality', () => {
|
|
627
|
+
beforeEach(() => {
|
|
628
|
+
mockGetMatchingTemplate.mockResolvedValue(createMockTemplate({
|
|
629
|
+
keys: ['howler.detection', 'event.id']
|
|
630
|
+
}));
|
|
631
|
+
rerender(_jsx(Wrapper, { children: _jsx(HitContextMenu, { getSelectedId: mockGetSelectedId, children: _jsx("div", { children: "Test Content" }) }) }));
|
|
632
|
+
});
|
|
633
|
+
it('should render inclusion submenu with template keys', async () => {
|
|
634
|
+
act(() => {
|
|
635
|
+
const contextMenuWrapper = screen.getByText('Test Content').parentElement;
|
|
636
|
+
fireEvent.contextMenu(contextMenuWrapper);
|
|
637
|
+
});
|
|
638
|
+
await waitFor(() => {
|
|
639
|
+
expect(screen.getByRole('menu')).toBeInTheDocument();
|
|
640
|
+
});
|
|
641
|
+
act(() => {
|
|
642
|
+
const includesMenuItem = screen.getByText('Include By');
|
|
643
|
+
fireEvent.mouseEnter(includesMenuItem);
|
|
644
|
+
});
|
|
645
|
+
await waitFor(() => {
|
|
646
|
+
const submenu = screen.getByTestId('includes-submenu');
|
|
647
|
+
expect(submenu).toBeInTheDocument();
|
|
648
|
+
expect(submenu.textContent).toContain('howler.detection');
|
|
649
|
+
expect(submenu.textContent).toContain('event.id');
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
it('should generate inclusion query for single value', async () => {
|
|
653
|
+
act(() => {
|
|
654
|
+
const contextMenuWrapper = screen.getByText('Test Content').parentElement;
|
|
655
|
+
fireEvent.contextMenu(contextMenuWrapper);
|
|
656
|
+
});
|
|
657
|
+
await waitFor(() => {
|
|
658
|
+
expect(screen.getByRole('menu')).toBeInTheDocument();
|
|
659
|
+
});
|
|
660
|
+
act(() => {
|
|
661
|
+
const includesMenuItem = screen.getByText('Include By');
|
|
662
|
+
fireEvent.mouseEnter(includesMenuItem);
|
|
663
|
+
});
|
|
664
|
+
await waitFor(() => {
|
|
665
|
+
expect(screen.getByTestId('includes-submenu')).toBeInTheDocument();
|
|
666
|
+
});
|
|
667
|
+
await act(async () => {
|
|
668
|
+
const detectionKey = screen.getByText('howler.detection');
|
|
669
|
+
await user.click(detectionKey);
|
|
670
|
+
});
|
|
671
|
+
await waitFor(() => {
|
|
672
|
+
expect(mockParameterContext.setQuery).toHaveBeenCalledWith('(howler.status:open) AND howler.detection:"Test Detection"');
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
it('should generate inclusion query for array values', async () => {
|
|
676
|
+
mockGetMatchingTemplate.mockResolvedValue(createMockTemplate({
|
|
677
|
+
keys: ['howler.outline.indicators']
|
|
678
|
+
}));
|
|
679
|
+
rerender(_jsx(Wrapper, { children: _jsx(HitContextMenu, { getSelectedId: mockGetSelectedId, children: _jsx("div", { children: "Test Content" }) }) }));
|
|
680
|
+
act(() => {
|
|
681
|
+
const contextMenuWrapper = screen.getByText('Test Content').parentElement;
|
|
682
|
+
fireEvent.contextMenu(contextMenuWrapper);
|
|
683
|
+
});
|
|
684
|
+
await waitFor(() => {
|
|
685
|
+
const includesMenuItem = screen.getByText('Include By');
|
|
686
|
+
fireEvent.mouseEnter(includesMenuItem);
|
|
687
|
+
});
|
|
688
|
+
await waitFor(() => {
|
|
689
|
+
expect(screen.getByTestId('includes-submenu')).toBeInTheDocument();
|
|
690
|
+
});
|
|
691
|
+
await act(async () => {
|
|
692
|
+
const tagsKey = screen.getByText('howler.outline.indicators');
|
|
693
|
+
await user.click(tagsKey);
|
|
694
|
+
});
|
|
695
|
+
await waitFor(() => {
|
|
696
|
+
expect(mockParameterContext.setQuery).toHaveBeenCalledWith('(howler.status:open) AND howler.outline.indicators:("a" OR "b" OR "c")');
|
|
697
|
+
});
|
|
698
|
+
});
|
|
699
|
+
it('should preserve existing query when adding inclusion', async () => {
|
|
700
|
+
mockParameterContext.query = 'howler.status:open';
|
|
701
|
+
const contextMenuWrapper = screen.getByText('Test Content').parentElement;
|
|
702
|
+
fireEvent.contextMenu(contextMenuWrapper);
|
|
703
|
+
await waitFor(() => {
|
|
704
|
+
const includesMenuItem = screen.getByText('Include By');
|
|
705
|
+
fireEvent.mouseEnter(includesMenuItem);
|
|
706
|
+
});
|
|
707
|
+
await waitFor(() => {
|
|
708
|
+
expect(screen.getByTestId('includes-submenu')).toBeInTheDocument();
|
|
709
|
+
});
|
|
710
|
+
await act(async () => {
|
|
711
|
+
const detectionKey = screen.getByText('howler.detection');
|
|
712
|
+
await user.click(detectionKey);
|
|
713
|
+
});
|
|
714
|
+
await waitFor(() => {
|
|
715
|
+
expect(mockParameterContext.setQuery).toHaveBeenCalledWith('(howler.status:open) AND howler.detection:"Test Detection"');
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
it('should not render inclusion menu when template has no keys', async () => {
|
|
719
|
+
mockGetMatchingTemplate.mockResolvedValue(createMockTemplate({
|
|
720
|
+
keys: []
|
|
721
|
+
}));
|
|
722
|
+
rerender(_jsx(Wrapper, { children: _jsx(HitContextMenu, { getSelectedId: mockGetSelectedId, children: _jsx("div", { children: "Test Content" }) }) }));
|
|
723
|
+
act(() => {
|
|
724
|
+
const contextMenuWrapper = screen.getByText('Test Content').parentElement;
|
|
725
|
+
fireEvent.contextMenu(contextMenuWrapper);
|
|
726
|
+
});
|
|
727
|
+
await waitFor(() => {
|
|
728
|
+
expect(screen.getByRole('menu')).toBeInTheDocument();
|
|
729
|
+
});
|
|
730
|
+
expect(screen.queryByText('Include By')).toBeNull();
|
|
731
|
+
});
|
|
732
|
+
it('should skip null field values in inclusion menu', async () => {
|
|
733
|
+
act(() => {
|
|
734
|
+
mockHitContext.hits['test-hit-1'].event = {};
|
|
735
|
+
});
|
|
736
|
+
act(() => {
|
|
737
|
+
const contextMenuWrapper = screen.getByText('Test Content').parentElement;
|
|
738
|
+
fireEvent.contextMenu(contextMenuWrapper);
|
|
739
|
+
});
|
|
740
|
+
await waitFor(() => {
|
|
741
|
+
const includesMenuItem = screen.getByText('Include By');
|
|
742
|
+
fireEvent.mouseEnter(includesMenuItem);
|
|
743
|
+
});
|
|
744
|
+
await waitFor(() => {
|
|
745
|
+
const submenu = screen.getByTestId('includes-submenu');
|
|
746
|
+
expect(submenu).toBeInTheDocument();
|
|
747
|
+
expect(submenu.textContent).toContain('howler.detection');
|
|
748
|
+
expect(submenu.textContent).not.toContain('event.id');
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
});
|
|
626
752
|
describe('Multiple Hit Selection', () => {
|
|
627
753
|
it('should use selectedHits when current hit is included', async () => {
|
|
628
754
|
act(() => {
|
|
@@ -721,6 +847,20 @@ describe('HitContextMenu', () => {
|
|
|
721
847
|
expect(screen.queryByText('Exclude By')).toBeNull();
|
|
722
848
|
});
|
|
723
849
|
});
|
|
850
|
+
it('should not render inclusion menu when template is null', async () => {
|
|
851
|
+
mockGetMatchingTemplate.mockResolvedValue(null);
|
|
852
|
+
rerender(_jsx(Wrapper, { children: _jsx(HitContextMenu, { getSelectedId: mockGetSelectedId, children: _jsx("div", { children: "Test Content" }) }) }));
|
|
853
|
+
act(() => {
|
|
854
|
+
const contextMenuWrapper = screen.getByText('Test Content').parentElement;
|
|
855
|
+
fireEvent.contextMenu(contextMenuWrapper);
|
|
856
|
+
});
|
|
857
|
+
await waitFor(() => {
|
|
858
|
+
expect(screen.getByRole('menu')).toBeInTheDocument();
|
|
859
|
+
});
|
|
860
|
+
await waitFor(() => {
|
|
861
|
+
expect(screen.queryByText('Include By')).toBeNull();
|
|
862
|
+
});
|
|
863
|
+
});
|
|
724
864
|
it('should handle API failure gracefully', async () => {
|
|
725
865
|
mockDispatchApi.mockResolvedValue(null);
|
|
726
866
|
rerender(_jsx(Wrapper, { children: _jsx(HitContextMenu, { getSelectedId: mockGetSelectedId, children: _jsx("div", { children: "Test Content" }) }) }));
|
|
@@ -182,6 +182,7 @@
|
|
|
182
182
|
"hit.panel.close": "Close",
|
|
183
183
|
"hit.panel.hit.noselection": "No hit has been selected",
|
|
184
184
|
"hit.panel.exclude": "Exclude By",
|
|
185
|
+
"hit.panel.include": "Include By",
|
|
185
186
|
"hit.panel.details.cluster": "Cluster Size",
|
|
186
187
|
"hit.panel.details.cluster.description": "Size of the cluster",
|
|
187
188
|
"hit.panel.details.no.subjects": "No subjects found",
|
|
@@ -183,6 +183,7 @@
|
|
|
183
183
|
"hit.panel.close": "Fermer",
|
|
184
184
|
"hit.panel.hit.noselection": "Aucun résultat n'a été sélectionné",
|
|
185
185
|
"hit.panel.exclude": "Exclure par",
|
|
186
|
+
"hit.panel.include": "Inclure par",
|
|
186
187
|
"hit.panel.details.cluster": "Taille de la grappe",
|
|
187
188
|
"hit.panel.details.cluster.description": "Taille de la grappe",
|
|
188
189
|
"hit.panel.details.no.subjects": "Aucun sujet trouvé",
|