@cccsaurora/howler-ui 3.1.0-dev.1656 → 3.1.0-dev.1675
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/api/action/execute.test.d.ts +1 -0
- package/api/action/execute.test.js +38 -0
- package/api/action/index.test.d.ts +1 -0
- package/api/action/index.test.js +59 -0
- package/api/action/operations.test.d.ts +1 -0
- package/api/action/operations.test.js +23 -0
- package/api/analytic/comments/index.test.d.ts +1 -0
- package/api/analytic/comments/index.test.js +43 -0
- package/api/analytic/comments/react.test.d.ts +1 -0
- package/api/analytic/comments/react.test.js +27 -0
- package/api/analytic/favourite.test.d.ts +1 -0
- package/api/analytic/favourite.test.js +20 -0
- package/api/analytic/index.test.d.ts +1 -0
- package/api/analytic/index.test.js +54 -0
- package/api/analytic/notebooks/index.test.d.ts +1 -0
- package/api/analytic/notebooks/index.test.js +31 -0
- package/api/analytic/owner.test.d.ts +1 -0
- package/api/analytic/owner.test.js +25 -0
- package/api/auth/apikey.test.d.ts +1 -0
- package/api/auth/apikey.test.js +34 -0
- package/api/auth/index.test.d.ts +1 -0
- package/api/auth/index.test.js +21 -0
- package/api/auth/login.test.d.ts +1 -0
- package/api/auth/login.test.js +53 -0
- package/api/configs/index.test.d.ts +1 -0
- package/api/configs/index.test.js +22 -0
- package/api/dossier/index.test.d.ts +1 -0
- package/api/dossier/index.test.js +57 -0
- package/api/help.test.d.ts +1 -0
- package/api/help.test.js +25 -0
- package/api/hit/assign.test.d.ts +1 -0
- package/api/hit/assign.test.js +22 -0
- package/api/hit/comments/index.test.d.ts +1 -0
- package/api/hit/comments/index.test.js +47 -0
- package/api/hit/comments/react.test.d.ts +1 -0
- package/api/hit/comments/react.test.js +27 -0
- package/api/hit/index.test.d.ts +1 -0
- package/api/hit/index.test.js +49 -0
- package/api/hit/labels.test.d.ts +1 -0
- package/api/hit/labels.test.js +29 -0
- package/api/hit/overwrite.test.d.ts +1 -0
- package/api/hit/overwrite.test.js +23 -0
- package/api/hit/transition.test.d.ts +1 -0
- package/api/hit/transition.test.js +24 -0
- package/api/index.test.d.ts +1 -0
- package/api/index.test.js +137 -0
- package/api/notebook/environments.test.d.ts +1 -0
- package/api/notebook/environments.test.js +22 -0
- package/api/notebook/index.test.d.ts +1 -0
- package/api/notebook/index.test.js +28 -0
- package/api/overview/index.test.d.ts +1 -0
- package/api/overview/index.test.js +42 -0
- package/api/search/fields/index.test.d.ts +1 -0
- package/api/search/fields/index.test.js +31 -0
- package/api/search/grouped/index.test.d.ts +1 -0
- package/api/search/grouped/index.test.js +18 -0
- package/api/search/grouped/user.test.d.ts +1 -0
- package/api/search/grouped/user.test.js +33 -0
- package/api/search/index.test.d.ts +1 -0
- package/api/search/index.test.js +41 -0
- package/api/search/user.test.d.ts +1 -0
- package/api/search/user.test.js +41 -0
- package/api/socket/index.test.d.ts +1 -0
- package/api/socket/index.test.js +15 -0
- package/api/template/index.test.d.ts +1 -0
- package/api/template/index.test.js +43 -0
- package/api/user/avatar/index.test.d.ts +1 -0
- package/api/user/avatar/index.test.js +22 -0
- package/api/user/groups.test.d.ts +1 -0
- package/api/user/groups.test.js +22 -0
- package/api/user/index.test.d.ts +1 -0
- package/api/user/index.test.js +37 -0
- package/api/user/whoami.test.d.ts +1 -0
- package/api/user/whoami.test.js +26 -0
- package/api/utils/createPermissionsApi.test.d.ts +1 -0
- package/api/utils/createPermissionsApi.test.js +30 -0
- package/api/v2/case/index.test.d.ts +1 -0
- package/api/v2/case/index.test.js +57 -0
- package/api/v2/case/items.test.d.ts +1 -0
- package/api/v2/case/items.test.js +37 -0
- package/api/v2/case/rules.test.d.ts +1 -0
- package/api/v2/case/rules.test.js +33 -0
- package/api/v2/fuzzy.test.d.ts +1 -0
- package/api/v2/fuzzy.test.js +30 -0
- package/api/v2/index.test.d.ts +1 -0
- package/api/v2/index.test.js +13 -0
- package/api/v2/search/index.test.d.ts +1 -0
- package/api/v2/search/index.test.js +42 -0
- package/api/view/index.test.d.ts +1 -0
- package/api/view/index.test.js +54 -0
- package/branding/AppBrand.test.d.ts +1 -0
- package/branding/AppBrand.test.js +29 -0
- package/components/app/drawers/ApiKeyDrawer.test.d.ts +1 -0
- package/components/app/drawers/ApiKeyDrawer.test.js +119 -0
- package/components/app/drawers/AssignUserDrawer.test.d.ts +1 -0
- package/components/app/drawers/AssignUserDrawer.test.js +75 -0
- package/components/app/hooks/useTitle.test.d.ts +1 -0
- package/components/app/hooks/useTitle.test.js +103 -0
- package/components/app/providers/AnalyticProvider.test.d.ts +1 -0
- package/components/app/providers/AnalyticProvider.test.js +58 -0
- package/components/app/providers/AppBarProvider.test.d.ts +1 -0
- package/components/app/providers/AppBarProvider.test.js +23 -0
- package/components/app/providers/AppDrawerProvider.test.d.ts +1 -0
- package/components/app/providers/AppDrawerProvider.test.js +42 -0
- package/components/app/providers/AvatarProvider.test.d.ts +1 -0
- package/components/app/providers/AvatarProvider.test.js +50 -0
- package/components/app/providers/CustomPluginProvider.test.d.ts +1 -0
- package/components/app/providers/CustomPluginProvider.test.js +29 -0
- package/components/app/providers/FavouritesProvider.test.d.ts +1 -0
- package/components/app/providers/FavouritesProvider.test.js +115 -0
- package/components/app/providers/FieldProvider.test.d.ts +1 -0
- package/components/app/providers/FieldProvider.test.js +28 -0
- package/components/app/providers/LocalStorageProvider.test.d.ts +1 -0
- package/components/app/providers/LocalStorageProvider.test.js +42 -0
- package/components/app/providers/ModalProvider.test.d.ts +1 -0
- package/components/app/providers/ModalProvider.test.js +35 -0
- package/components/app/providers/OverviewProvider.test.d.ts +1 -0
- package/components/app/providers/OverviewProvider.test.js +62 -0
- package/components/app/providers/RecordProvider.test.d.ts +1 -0
- package/components/app/providers/RecordProvider.test.js +66 -0
- package/components/app/providers/contextUtils.test.d.ts +1 -0
- package/components/app/providers/contextUtils.test.js +8 -0
- package/components/elements/Comment.test.d.ts +1 -0
- package/components/elements/Comment.test.js +109 -0
- package/components/elements/EditRow.test.d.ts +1 -0
- package/components/elements/EditRow.test.js +88 -0
- package/components/elements/MarkdownEditor.test.d.ts +1 -0
- package/components/elements/MarkdownEditor.test.js +75 -0
- package/components/elements/ObjectDetails.test.d.ts +1 -0
- package/components/elements/ObjectDetails.test.js +70 -0
- package/components/elements/PluginChip.d.ts +3 -2
- package/components/elements/PluginChip.js +2 -2
- package/components/elements/PluginChip.test.d.ts +1 -0
- package/components/elements/PluginChip.test.js +30 -0
- package/components/elements/ThemedEditor.test.d.ts +1 -0
- package/components/elements/ThemedEditor.test.js +66 -0
- package/components/elements/addons/layout/FlexPort.test.d.ts +1 -0
- package/components/elements/addons/layout/FlexPort.test.js +34 -0
- package/components/elements/addons/lists/TuiListBase.test.d.ts +1 -0
- package/components/elements/addons/lists/TuiListBase.test.js +44 -0
- package/components/elements/addons/lists/TuiListProvider.test.d.ts +1 -0
- package/components/elements/addons/lists/TuiListProvider.test.js +50 -0
- package/components/elements/addons/search/phrase/Phrase.test.d.ts +1 -0
- package/components/elements/addons/search/phrase/Phrase.test.js +77 -0
- package/components/elements/addons/search/phrase/PhraseLexer.test.d.ts +1 -0
- package/components/elements/addons/search/phrase/PhraseLexer.test.js +92 -0
- package/components/elements/addons/search/phrase/index.test.d.ts +1 -0
- package/components/elements/addons/search/phrase/index.test.js +20 -0
- package/components/elements/case/CaseCard.test.d.ts +1 -0
- package/components/elements/case/CaseCard.test.js +107 -0
- package/components/elements/display/ClassificationChip.test.d.ts +1 -0
- package/components/elements/display/ClassificationChip.test.js +60 -0
- package/components/elements/display/HandlebarsMarkdown.test.d.ts +1 -0
- package/components/elements/display/HandlebarsMarkdown.test.js +41 -0
- package/components/elements/display/HowlerAvatar.test.d.ts +1 -0
- package/components/elements/display/HowlerAvatar.test.js +54 -0
- package/components/elements/display/ItemManager.test.d.ts +1 -0
- package/components/elements/display/ItemManager.test.js +68 -0
- package/components/elements/display/UserPageWrapper.test.d.ts +1 -0
- package/components/elements/display/UserPageWrapper.test.js +22 -0
- package/components/elements/display/handlebars/helpers.test.d.ts +1 -0
- package/components/elements/display/handlebars/helpers.test.js +104 -0
- package/components/elements/display/icons/SocketBadge.test.d.ts +1 -0
- package/components/elements/display/icons/SocketBadge.test.js +49 -0
- package/components/elements/display/markdownPlugins/tabs.test.d.ts +1 -0
- package/components/elements/display/markdownPlugins/tabs.test.js +50 -0
- package/components/elements/hit/HitActions.js +1 -1
- package/components/elements/hit/HitActions.test.d.ts +1 -0
- package/components/elements/hit/HitActions.test.js +166 -0
- package/components/elements/hit/HitLabels.test.js +34 -3
- package/components/elements/hit/HitNotebooks.test.d.ts +1 -0
- package/components/elements/hit/HitNotebooks.test.js +138 -0
- package/components/elements/hit/HitSummary.test.d.ts +1 -0
- package/components/elements/hit/HitSummary.test.js +188 -0
- package/components/elements/hit/actions/ButtonActions.test.d.ts +1 -0
- package/components/elements/hit/actions/ButtonActions.test.js +51 -0
- package/components/elements/hit/actions/DropdownActions.test.d.ts +1 -0
- package/components/elements/hit/actions/DropdownActions.test.js +60 -0
- package/components/elements/hit/grid/AddColumnModal.test.d.ts +1 -0
- package/components/elements/hit/grid/AddColumnModal.test.js +88 -0
- package/components/elements/hit/grid/RecordTable.test.d.ts +1 -0
- package/components/elements/hit/grid/RecordTable.test.js +99 -0
- package/components/elements/record/RecordComments.test.d.ts +1 -0
- package/components/elements/record/RecordComments.test.js +151 -0
- package/components/elements/record/RecordRelated.test.d.ts +1 -0
- package/components/elements/record/RecordRelated.test.js +77 -0
- package/components/elements/record/RecordWorklog.test.d.ts +1 -0
- package/components/elements/record/RecordWorklog.test.js +77 -0
- package/components/hooks/useHitActions.test.d.ts +1 -0
- package/components/hooks/useHitActions.test.js +189 -0
- package/components/hooks/useMyApi.test.d.ts +1 -0
- package/components/hooks/useMyApi.test.js +31 -0
- package/components/hooks/useMyChart.test.d.ts +1 -0
- package/components/hooks/useMyChart.test.js +62 -0
- package/components/hooks/useMySearch.test.d.ts +1 -0
- package/components/hooks/useMySearch.test.js +96 -0
- package/components/hooks/useMySnackbar.test.d.ts +1 -0
- package/components/hooks/useMySnackbar.test.js +36 -0
- package/components/hooks/useMyUserFunctions.test.d.ts +1 -0
- package/components/hooks/useMyUserFunctions.test.js +142 -0
- package/components/hooks/useRecordSelection.test.d.ts +1 -0
- package/components/hooks/useRecordSelection.test.js +102 -0
- package/components/logins/Login.test.d.ts +1 -0
- package/components/logins/Login.test.js +67 -0
- package/components/logins/hooks/useLogin.test.d.ts +1 -0
- package/components/logins/hooks/useLogin.test.js +142 -0
- package/components/routes/action/shared/OperationEntry.test.d.ts +1 -0
- package/components/routes/action/shared/OperationEntry.test.js +80 -0
- package/components/routes/action/shared/OperationStep.test.d.ts +1 -0
- package/components/routes/action/shared/OperationStep.test.js +84 -0
- package/components/routes/action/useMyActionFunctions.test.d.ts +1 -0
- package/components/routes/action/useMyActionFunctions.test.js +217 -0
- package/components/routes/action/view/ActionDetails.test.d.ts +1 -0
- package/components/routes/action/view/ActionDetails.test.js +170 -0
- package/components/routes/action/view/ActionSearch.test.d.ts +1 -0
- package/components/routes/action/view/ActionSearch.test.js +185 -0
- package/components/routes/action/view/Integrations.test.d.ts +1 -0
- package/components/routes/action/view/Integrations.test.js +62 -0
- package/components/routes/admin/users/UserEditor.test.d.ts +1 -0
- package/components/routes/admin/users/UserEditor.test.js +74 -0
- package/components/routes/admin/users/UserSearch.test.d.ts +1 -0
- package/components/routes/admin/users/UserSearch.test.js +146 -0
- package/components/routes/advanced/QueryBuilder.test.d.ts +1 -0
- package/components/routes/advanced/QueryBuilder.test.js +185 -0
- package/components/routes/advanced/QueryEditor.test.d.ts +1 -0
- package/components/routes/advanced/QueryEditor.test.js +130 -0
- package/components/routes/advanced/completionProviders.test.d.ts +1 -0
- package/components/routes/advanced/completionProviders.test.js +144 -0
- package/components/routes/analytics/AnalyticComments.test.d.ts +1 -0
- package/components/routes/analytics/AnalyticComments.test.js +156 -0
- package/components/routes/analytics/AnalyticDetails.test.d.ts +1 -0
- package/components/routes/analytics/AnalyticDetails.test.js +161 -0
- package/components/routes/analytics/AnalyticNotebooks.test.d.ts +1 -0
- package/components/routes/analytics/AnalyticNotebooks.test.js +112 -0
- package/components/routes/analytics/AnalyticOverview.test.d.ts +1 -0
- package/components/routes/analytics/AnalyticOverview.test.js +97 -0
- package/components/routes/analytics/AnalyticOverviews.test.d.ts +1 -0
- package/components/routes/analytics/AnalyticOverviews.test.js +70 -0
- package/components/routes/analytics/AnalyticSearch.test.d.ts +1 -0
- package/components/routes/analytics/AnalyticSearch.test.js +167 -0
- package/components/routes/analytics/AnalyticTemplates.test.d.ts +1 -0
- package/components/routes/analytics/AnalyticTemplates.test.js +63 -0
- package/components/routes/analytics/TriageSettings.test.d.ts +1 -0
- package/components/routes/analytics/TriageSettings.test.js +89 -0
- package/components/routes/analytics/widgets/Assessment.test.d.ts +1 -0
- package/components/routes/analytics/widgets/Assessment.test.js +45 -0
- package/components/routes/analytics/widgets/Created.test.d.ts +1 -0
- package/components/routes/analytics/widgets/Created.test.js +41 -0
- package/components/routes/analytics/widgets/DetectionStatus.test.d.ts +1 -0
- package/components/routes/analytics/widgets/DetectionStatus.test.js +21 -0
- package/components/routes/analytics/widgets/Stacked.test.d.ts +1 -0
- package/components/routes/analytics/widgets/Stacked.test.js +51 -0
- package/components/routes/cases/Cases.test.d.ts +1 -0
- package/components/routes/cases/Cases.test.js +132 -0
- package/components/routes/dossiers/Dossiers.test.d.ts +1 -0
- package/components/routes/dossiers/Dossiers.test.js +150 -0
- package/components/routes/help/ActionDocumentation.test.d.ts +1 -0
- package/components/routes/help/ActionDocumentation.test.js +58 -0
- package/components/routes/help/ActionIntroductionDocumentation.test.d.ts +1 -0
- package/components/routes/help/ActionIntroductionDocumentation.test.js +68 -0
- package/components/routes/help/ApiDocumentation.test.d.ts +1 -0
- package/components/routes/help/ApiDocumentation.test.js +79 -0
- package/components/routes/help/AuthDocumentation.test.d.ts +1 -0
- package/components/routes/help/AuthDocumentation.test.js +34 -0
- package/components/routes/help/ClientDocumentation.test.d.ts +1 -0
- package/components/routes/help/ClientDocumentation.test.js +34 -0
- package/components/routes/help/Help.test.d.ts +1 -0
- package/components/routes/help/Help.test.js +57 -0
- package/components/routes/help/HitBannerDocumentation.test.d.ts +1 -0
- package/components/routes/help/HitBannerDocumentation.test.js +25 -0
- package/components/routes/help/HitDocumentation.test.d.ts +1 -0
- package/components/routes/help/HitDocumentation.test.js +53 -0
- package/components/routes/help/HitLabelsDocumentation.test.d.ts +1 -0
- package/components/routes/help/HitLabelsDocumentation.test.js +17 -0
- package/components/routes/help/HitLinksDocumentation.test.d.ts +1 -0
- package/components/routes/help/HitLinksDocumentation.test.js +27 -0
- package/components/routes/help/HitSchemaDocumentation.test.d.ts +1 -0
- package/components/routes/help/HitSchemaDocumentation.test.js +67 -0
- package/components/routes/help/NotebookDocumentation.test.d.ts +1 -0
- package/components/routes/help/NotebookDocumentation.test.js +34 -0
- package/components/routes/help/OverviewDocumentation.test.d.ts +1 -0
- package/components/routes/help/OverviewDocumentation.test.js +26 -0
- package/components/routes/help/RetentionDocumentation.test.d.ts +1 -0
- package/components/routes/help/RetentionDocumentation.test.js +61 -0
- package/components/routes/help/SearchDocumentation.test.d.ts +1 -0
- package/components/routes/help/SearchDocumentation.test.js +65 -0
- package/components/routes/help/TemplateDocumentation.test.d.ts +1 -0
- package/components/routes/help/TemplateDocumentation.test.js +58 -0
- package/components/routes/help/ViewDocumentation.test.d.ts +1 -0
- package/components/routes/help/ViewDocumentation.test.js +34 -0
- package/components/routes/help/components/HelpTabs.test.d.ts +1 -0
- package/components/routes/help/components/HelpTabs.test.js +26 -0
- package/components/routes/hits/search/InformationPane.test.d.ts +1 -0
- package/components/routes/hits/search/InformationPane.test.js +251 -0
- package/components/routes/hits/search/RecordBrowser.test.js +179 -51
- package/components/routes/hits/search/RecordQuery.test.d.ts +1 -0
- package/components/routes/hits/search/RecordQuery.test.js +117 -0
- package/components/routes/hits/search/SearchPane.test.d.ts +1 -0
- package/components/routes/hits/search/SearchPane.test.js +178 -0
- package/components/routes/hits/search/grid/RecordGrid.test.d.ts +1 -0
- package/components/routes/hits/search/grid/RecordGrid.test.js +107 -0
- package/components/routes/hits/search/shared/CustomSort.test.d.ts +1 -0
- package/components/routes/hits/search/shared/CustomSort.test.js +77 -0
- package/components/routes/hits/search/shared/HitFilter.test.d.ts +1 -0
- package/components/routes/hits/search/shared/HitFilter.test.js +83 -0
- package/components/routes/hits/search/shared/HitSort.test.d.ts +1 -0
- package/components/routes/hits/search/shared/HitSort.test.js +61 -0
- package/components/routes/hits/search/shared/LayoutSettings.test.d.ts +1 -0
- package/components/routes/hits/search/shared/LayoutSettings.test.js +84 -0
- package/components/routes/hits/search/shared/SearchSpan.test.d.ts +1 -0
- package/components/routes/hits/search/shared/SearchSpan.test.js +84 -0
- package/components/routes/home/AnalyticCard.test.d.ts +1 -0
- package/components/routes/home/AnalyticCard.test.js +87 -0
- package/components/routes/home/index.test.d.ts +1 -0
- package/components/routes/home/index.test.js +190 -0
- package/components/routes/overviews/OverviewViewer.test.d.ts +1 -0
- package/components/routes/overviews/OverviewViewer.test.js +151 -0
- package/components/routes/overviews/Overviews.test.d.ts +1 -0
- package/components/routes/overviews/Overviews.test.js +154 -0
- package/components/routes/settings/AdminSection.test.d.ts +1 -0
- package/components/routes/settings/AdminSection.test.js +26 -0
- package/components/routes/settings/LocalSection.test.d.ts +1 -0
- package/components/routes/settings/LocalSection.test.js +75 -0
- package/components/routes/settings/ProfileSection.test.d.ts +1 -0
- package/components/routes/settings/ProfileSection.test.js +95 -0
- package/components/routes/settings/SecuritySection.test.d.ts +1 -0
- package/components/routes/settings/SecuritySection.test.js +90 -0
- package/components/routes/settings/Settings.test.d.ts +1 -0
- package/components/routes/settings/Settings.test.js +60 -0
- package/components/routes/templates/TemplateEditor.test.d.ts +1 -0
- package/components/routes/templates/TemplateEditor.test.js +94 -0
- package/components/routes/templates/TemplateViewer.test.d.ts +1 -0
- package/components/routes/templates/TemplateViewer.test.js +145 -0
- package/components/routes/templates/Templates.test.d.ts +1 -0
- package/components/routes/templates/Templates.test.js +165 -0
- package/components/routes/views/ViewComposer.test.d.ts +1 -0
- package/components/routes/views/ViewComposer.test.js +320 -0
- package/components/routes/views/Views.test.d.ts +1 -0
- package/components/routes/views/Views.test.js +247 -0
- package/package.json +2 -2
- package/plugins/HowlerPlugin.test.d.ts +1 -0
- package/plugins/HowlerPlugin.test.js +103 -0
- package/plugins/clue/components/ClueChip.js +2 -2
- package/plugins/clue/helpers.test.d.ts +1 -0
- package/plugins/clue/helpers.test.js +100 -0
- package/plugins/store.test.d.ts +1 -0
- package/plugins/store.test.js +53 -0
- package/utils/classificationParser.test.d.ts +1 -0
- package/utils/classificationParser.test.js +199 -0
- package/utils/constants.test.d.ts +1 -0
- package/utils/constants.test.js +62 -0
- package/utils/typeUtils.test.d.ts +1 -0
- package/utils/typeUtils.test.js +22 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
3
|
import { describe, expect, it, vi } from 'vitest';
|
|
4
4
|
import HitLabels from './HitLabels';
|
|
5
5
|
/**
|
|
@@ -12,16 +12,18 @@ import HitLabels from './HitLabels';
|
|
|
12
12
|
* - Conditional display of the edit button based on readOnly mode
|
|
13
13
|
* - Safe rendering when no labels are present
|
|
14
14
|
*/
|
|
15
|
+
const mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
16
|
+
const mockUpdateRecord = vi.hoisted(() => vi.fn());
|
|
15
17
|
vi.mock('components/hooks/useMyApi', () => ({
|
|
16
18
|
default: () => ({
|
|
17
|
-
dispatchApi:
|
|
19
|
+
dispatchApi: mockDispatchApi
|
|
18
20
|
})
|
|
19
21
|
}));
|
|
20
22
|
vi.mock('components/app/providers/RecordProvider', () => ({
|
|
21
23
|
RecordContext: {}
|
|
22
24
|
}));
|
|
23
25
|
vi.mock('use-context-selector', () => ({
|
|
24
|
-
useContextSelector: () =>
|
|
26
|
+
useContextSelector: () => mockUpdateRecord
|
|
25
27
|
}));
|
|
26
28
|
vi.mock('react-i18next', () => ({
|
|
27
29
|
useTranslation: () => ({
|
|
@@ -31,6 +33,7 @@ vi.mock('react-i18next', () => ({
|
|
|
31
33
|
}));
|
|
32
34
|
vi.mock('utils/constants', () => ({
|
|
33
35
|
LABEL_TYPES: {
|
|
36
|
+
generic: { icon: null, color: '#0000ff' },
|
|
34
37
|
security: { icon: null, color: '#ff0000' },
|
|
35
38
|
system: { icon: null, color: '#00ff00' }
|
|
36
39
|
}
|
|
@@ -74,4 +77,32 @@ describe('HitLabels', () => {
|
|
|
74
77
|
const { container } = render(_jsx(HitLabels, { hit: emptyHit, readOnly: true }));
|
|
75
78
|
expect(container).toBeInTheDocument();
|
|
76
79
|
});
|
|
80
|
+
it('opens the drawer, validates empty input, and adds labels', async () => {
|
|
81
|
+
mockDispatchApi.mockResolvedValueOnce({
|
|
82
|
+
howler: { labels: { security: ['critical', 'high'], system: ['info'], generic: ['fresh'] } }
|
|
83
|
+
});
|
|
84
|
+
render(_jsx(HitLabels, { hit: baseHit, readOnly: false }));
|
|
85
|
+
fireEvent.click(screen.getByRole('button'));
|
|
86
|
+
fireEvent.keyDown(screen.getByLabelText('hit.label.edit.add.label'), { key: 'Enter' });
|
|
87
|
+
expect(screen.getByText('hit.label.edit.add.error.empty')).toBeInTheDocument();
|
|
88
|
+
fireEvent.change(screen.getByLabelText('hit.label.edit.add.label'), { target: { value: 'fresh' } });
|
|
89
|
+
fireEvent.keyDown(screen.getByLabelText('hit.label.edit.add.label'), { key: 'Enter' });
|
|
90
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({
|
|
91
|
+
op: 'put',
|
|
92
|
+
id: 'hit-1',
|
|
93
|
+
category: 'generic',
|
|
94
|
+
body: { value: ['fresh'] }
|
|
95
|
+
}));
|
|
96
|
+
expect(mockUpdateRecord).toHaveBeenCalled();
|
|
97
|
+
});
|
|
77
98
|
});
|
|
99
|
+
vi.mock('api', () => ({
|
|
100
|
+
default: {
|
|
101
|
+
hit: {
|
|
102
|
+
labels: {
|
|
103
|
+
put: (id, category, body) => ({ op: 'put', id, category, body }),
|
|
104
|
+
del: (id, category, body) => ({ op: 'del', id, category, body })
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
const mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
6
|
+
const mockShowErrorMessage = vi.hoisted(() => vi.fn());
|
|
7
|
+
const mockShowModal = vi.hoisted(() => vi.fn((node) => node.props.onConfirm()));
|
|
8
|
+
const mockNotebookPost = vi.hoisted(() => vi.fn((body) => body));
|
|
9
|
+
const mockEnvironmentsGet = vi.hoisted(() => vi.fn(() => ({ envs: true })));
|
|
10
|
+
const apiConfigContextToken = vi.hoisted(() => ({ name: 'api-config-context' }));
|
|
11
|
+
const modalContextToken = vi.hoisted(() => ({ name: 'modal-context' }));
|
|
12
|
+
let configValue = {
|
|
13
|
+
configuration: {
|
|
14
|
+
features: {
|
|
15
|
+
notebook: true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
vi.mock('@mui/material', () => ({
|
|
20
|
+
Avatar: ({ children }) => _jsx("div", { children: children }),
|
|
21
|
+
Backdrop: ({ children, open }) => (open ? _jsx("div", { children: children }) : null),
|
|
22
|
+
Box: ({ children }) => _jsx("div", { children: children }),
|
|
23
|
+
Button: ({ children, onClick, disabled }) => (_jsx("button", { onClick: onClick, disabled: disabled, children: children })),
|
|
24
|
+
Chip: ({ label }) => _jsx("span", { children: label }),
|
|
25
|
+
CircularProgress: () => _jsx("div", { children: "loading" }),
|
|
26
|
+
ClickAwayListener: ({ children }) => _jsx(_Fragment, { children: children }),
|
|
27
|
+
Fade: ({ children }) => _jsx(_Fragment, { children: children }),
|
|
28
|
+
MenuItem: ({ children, value, disabled }) => (_jsx("option", { value: value, disabled: disabled, children: children })),
|
|
29
|
+
Paper: ({ children }) => _jsx("div", { children: children }),
|
|
30
|
+
Popper: ({ children, open }) => (open ? children({ TransitionProps: {} }) : null),
|
|
31
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
32
|
+
TextField: ({ children, label, onChange, defaultValue, disabled, select }) => select ? (_jsxs("label", { children: [label, _jsx("select", { "aria-label": label, defaultValue: defaultValue, onChange: onChange, disabled: disabled, children: children })] })) : (_jsxs("label", { children: [label, _jsx("input", { "aria-label": label, onChange: onChange, disabled: disabled })] })),
|
|
33
|
+
Tooltip: ({ children }) => _jsx(_Fragment, { children: children })
|
|
34
|
+
}));
|
|
35
|
+
vi.mock('api', () => ({
|
|
36
|
+
default: {
|
|
37
|
+
notebook: {
|
|
38
|
+
environments: {
|
|
39
|
+
get: mockEnvironmentsGet
|
|
40
|
+
},
|
|
41
|
+
post: mockNotebookPost
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
vi.mock('components/app/providers/ApiConfigProvider', () => ({
|
|
46
|
+
ApiConfigContext: apiConfigContextToken
|
|
47
|
+
}));
|
|
48
|
+
vi.mock('components/app/providers/ModalProvider', () => ({
|
|
49
|
+
ModalContext: modalContextToken
|
|
50
|
+
}));
|
|
51
|
+
vi.mock('components/elements/display/HowlerCard', () => ({
|
|
52
|
+
default: ({ children, onClick }) => _jsx("button", { onClick: onClick, children: children })
|
|
53
|
+
}));
|
|
54
|
+
vi.mock('components/elements/hit/NotebookTooltip', () => ({
|
|
55
|
+
default: () => _jsx("div", { children: "tooltip" })
|
|
56
|
+
}));
|
|
57
|
+
vi.mock('components/elements/display/modals/ConfirmNotebookModal', () => ({
|
|
58
|
+
default: ({ onConfirm }) => _jsx("button", { onClick: onConfirm, children: "confirm notebook" })
|
|
59
|
+
}));
|
|
60
|
+
vi.mock('components/hooks/useMyApi', () => ({
|
|
61
|
+
default: () => ({ dispatchApi: mockDispatchApi })
|
|
62
|
+
}));
|
|
63
|
+
vi.mock('components/hooks/useMySnackbar', () => ({
|
|
64
|
+
default: () => ({ showErrorMessage: mockShowErrorMessage })
|
|
65
|
+
}));
|
|
66
|
+
vi.mock('react', async (importOriginal) => {
|
|
67
|
+
const actual = await importOriginal();
|
|
68
|
+
return {
|
|
69
|
+
...actual,
|
|
70
|
+
useContext: (context) => {
|
|
71
|
+
if (context === apiConfigContextToken)
|
|
72
|
+
return { config: configValue };
|
|
73
|
+
if (context === modalContextToken)
|
|
74
|
+
return { showModal: mockShowModal };
|
|
75
|
+
return actual.useContext(context);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
vi.mock('react-i18next', () => ({
|
|
80
|
+
useTranslation: () => ({ t: (key) => key })
|
|
81
|
+
}));
|
|
82
|
+
vi.mock('utils/stringUtils', async (importOriginal) => {
|
|
83
|
+
const actual = await importOriginal();
|
|
84
|
+
return {
|
|
85
|
+
...actual,
|
|
86
|
+
safeStringPropertyCompare: (key) => (a, b) => String(a[key] ?? '').localeCompare(String(b[key] ?? ''))
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
import HitNotebooks from './HitNotebooks';
|
|
90
|
+
describe('HitNotebooks', () => {
|
|
91
|
+
beforeEach(() => {
|
|
92
|
+
configValue = { configuration: { features: { notebook: true } } };
|
|
93
|
+
mockDispatchApi.mockReset();
|
|
94
|
+
mockShowErrorMessage.mockReset();
|
|
95
|
+
mockShowModal.mockClear();
|
|
96
|
+
mockNotebookPost.mockClear();
|
|
97
|
+
mockEnvironmentsGet.mockClear();
|
|
98
|
+
vi.stubGlobal('fetch', vi.fn());
|
|
99
|
+
vi.stubGlobal('open', vi.fn());
|
|
100
|
+
});
|
|
101
|
+
it('loads notebook content and opens jupyter when the notebook does not already exist', async () => {
|
|
102
|
+
mockDispatchApi
|
|
103
|
+
.mockResolvedValueOnce({
|
|
104
|
+
envs: [{ name: 'env', url: 'https://nb.example', default: true, user_interface: 'lab' }]
|
|
105
|
+
})
|
|
106
|
+
.mockResolvedValueOnce({ nb_content: { cells: [] }, name: 'Loaded Notebook' });
|
|
107
|
+
globalThis.fetch.mockResolvedValueOnce({ status: 404 }).mockResolvedValueOnce({ status: 200 });
|
|
108
|
+
render(_jsx(HitNotebooks, { analytic: { notebooks: [{ name: 'Notebook A', value: 'link-a', detection: 'det-b' }] }, selectedNotebook: "Notebook A", hit: { howler: { id: 'hit-1' } } }));
|
|
109
|
+
fireEvent.click(screen.getByRole('button', { name: /hit\.notebook\.tooltip/i }));
|
|
110
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledTimes(2));
|
|
111
|
+
expect(mockNotebookPost).toHaveBeenCalledWith(expect.objectContaining({
|
|
112
|
+
link: 'link-a',
|
|
113
|
+
hit: { howler: { id: 'hit-1' } }
|
|
114
|
+
}));
|
|
115
|
+
fireEvent.click(screen.getByText('hit.notebook.goTo'));
|
|
116
|
+
await waitFor(() => expect(globalThis.fetch).toHaveBeenCalledWith('https://nb.example/api/contents/Loaded Notebook - hit-1.ipynb', expect.any(Object)));
|
|
117
|
+
await waitFor(() => expect(globalThis.fetch).toHaveBeenCalledWith('https://nb.example/post/Loaded Notebook - hit-1.ipynb', expect.objectContaining({ method: 'post' })));
|
|
118
|
+
expect(globalThis.open).toHaveBeenCalledWith('https://nb.example/lab/tree/Loaded Notebook - hit-1.ipynb', '_blank');
|
|
119
|
+
});
|
|
120
|
+
it('confirms overwrite for existing notebooks and can hide itself when notebooks are disabled', async () => {
|
|
121
|
+
configValue = { configuration: { features: { notebook: false } } };
|
|
122
|
+
const { rerender } = render(_jsx(HitNotebooks, { analytic: { notebooks: [{ name: 'Notebook A', value: 'link-a' }] } }));
|
|
123
|
+
expect(screen.queryByText('hit.notebook.tooltip')).not.toBeInTheDocument();
|
|
124
|
+
configValue = { configuration: { features: { notebook: true } } };
|
|
125
|
+
mockDispatchApi
|
|
126
|
+
.mockResolvedValueOnce({
|
|
127
|
+
envs: [{ name: 'env', url: 'https://nb.example/', default: true, user_interface: 'lab' }]
|
|
128
|
+
})
|
|
129
|
+
.mockResolvedValueOnce({ nb_content: { cells: [] }, name: 'Notebook A' });
|
|
130
|
+
globalThis.fetch.mockResolvedValueOnce({ status: 200 }).mockResolvedValueOnce({ status: 200 });
|
|
131
|
+
rerender(_jsx(HitNotebooks, { analytic: { notebooks: [{ name: 'Notebook A', value: 'link-a' }] }, selectedNotebook: "Notebook A" }));
|
|
132
|
+
fireEvent.click(screen.getByRole('button', { name: /hit\.notebook\.tooltip/i }));
|
|
133
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledTimes(2));
|
|
134
|
+
fireEvent.click(screen.getByText('hit.notebook.goTo'));
|
|
135
|
+
await waitFor(() => expect(mockShowModal).toHaveBeenCalled());
|
|
136
|
+
await waitFor(() => expect(globalThis.fetch).toHaveBeenCalledWith('https://nb.example/post/Notebook A.ipynb', expect.objectContaining({ method: 'post' })));
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
const mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
6
|
+
const mockShowErrorMessage = vi.hoisted(() => vi.fn());
|
|
7
|
+
const mockSetQuery = vi.hoisted(() => vi.fn());
|
|
8
|
+
const mockGetFilters = vi.hoisted(() => vi.fn().mockResolvedValue(['status:open']));
|
|
9
|
+
const mockGetMatchingTemplate = vi.hoisted(() => vi.fn());
|
|
10
|
+
const fieldContextToken = vi.hoisted(() => ({ name: 'field-context' }));
|
|
11
|
+
const parameterContextToken = vi.hoisted(() => ({ name: 'parameter-context' }));
|
|
12
|
+
const recordSearchContextToken = vi.hoisted(() => ({ name: 'record-search-context' }));
|
|
13
|
+
let fieldContextValue;
|
|
14
|
+
let parameterContextValue;
|
|
15
|
+
let recordSearchContextValue;
|
|
16
|
+
vi.mock('@mui/icons-material', () => ({
|
|
17
|
+
Analytics: () => _jsx("div", { children: "analytics-icon" }),
|
|
18
|
+
InfoOutlined: () => _jsx("div", { children: "info-icon" })
|
|
19
|
+
}));
|
|
20
|
+
vi.mock('@mui/material', () => ({
|
|
21
|
+
Alert: ({ children }) => _jsx("div", { children: children }),
|
|
22
|
+
AlertTitle: ({ children }) => _jsx("div", { children: children }),
|
|
23
|
+
Autocomplete: ({ onChange, renderInput }) => (_jsxs("div", { children: [renderInput({}), _jsx("button", { onClick: () => onChange?.(null, ['custom.field']), children: "add-custom-field" })] })),
|
|
24
|
+
Box: ({ children }) => _jsx("div", { children: children }),
|
|
25
|
+
Button: ({ children, onClick, disabled }) => (_jsx("button", { onClick: onClick, disabled: disabled, children: children })),
|
|
26
|
+
Chip: ({ label, onClick }) => _jsx("button", { onClick: onClick, children: label }),
|
|
27
|
+
CircularProgress: () => _jsx("div", { children: "loading" }),
|
|
28
|
+
Divider: () => _jsx("div", { children: "divider" }),
|
|
29
|
+
Fade: ({ children }) => _jsx("div", { children: children }),
|
|
30
|
+
Grid: ({ children }) => _jsx("div", { children: children }),
|
|
31
|
+
LinearProgress: () => _jsx("div", { children: "progress" }),
|
|
32
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
33
|
+
TextField: ({ label }) => _jsx("div", { children: label }),
|
|
34
|
+
Tooltip: ({ children }) => _jsx(_Fragment, { children: children }),
|
|
35
|
+
Typography: ({ children }) => _jsx("div", { children: children })
|
|
36
|
+
}));
|
|
37
|
+
vi.mock('api', () => ({
|
|
38
|
+
default: {
|
|
39
|
+
search: {
|
|
40
|
+
facet: {
|
|
41
|
+
hit: {
|
|
42
|
+
post: (body) => body
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
vi.mock('components/app/hooks/useMatchers', () => ({
|
|
49
|
+
default: () => ({ getMatchingTemplate: mockGetMatchingTemplate })
|
|
50
|
+
}));
|
|
51
|
+
vi.mock('components/app/providers/FieldProvider', () => ({
|
|
52
|
+
FieldContext: fieldContextToken
|
|
53
|
+
}));
|
|
54
|
+
vi.mock('components/app/providers/ParameterProvider', () => ({
|
|
55
|
+
ParameterContext: parameterContextToken
|
|
56
|
+
}));
|
|
57
|
+
vi.mock('components/app/providers/RecordSearchProvider', () => ({
|
|
58
|
+
RecordSearchContext: recordSearchContextToken
|
|
59
|
+
}));
|
|
60
|
+
vi.mock('components/hooks/useMyApi', () => ({
|
|
61
|
+
default: () => ({ dispatchApi: mockDispatchApi })
|
|
62
|
+
}));
|
|
63
|
+
vi.mock('components/hooks/useMyLocalStorage', () => ({
|
|
64
|
+
useMyLocalStorageItem: (key, fallback) => [key === 'SHOW_HIT_SUMMARY_GRAPH' ? true : fallback]
|
|
65
|
+
}));
|
|
66
|
+
vi.mock('components/hooks/useMySnackbar', () => ({
|
|
67
|
+
default: () => ({ showErrorMessage: mockShowErrorMessage })
|
|
68
|
+
}));
|
|
69
|
+
vi.mock('lodash-es', () => ({
|
|
70
|
+
isEmpty: (value) => value == null ||
|
|
71
|
+
(Array.isArray(value) ? value.length === 0 : typeof value === 'object' ? Object.keys(value).length === 0 : !value)
|
|
72
|
+
}));
|
|
73
|
+
vi.mock('react-i18next', () => ({
|
|
74
|
+
useTranslation: () => ({ t: (key) => key })
|
|
75
|
+
}));
|
|
76
|
+
vi.mock('use-context-selector', () => ({
|
|
77
|
+
useContextSelector: (context, selector) => {
|
|
78
|
+
if (context === parameterContextToken)
|
|
79
|
+
return selector(parameterContextValue);
|
|
80
|
+
if (context === recordSearchContextToken)
|
|
81
|
+
return selector(recordSearchContextValue);
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
vi.mock('utils/constants', () => ({
|
|
86
|
+
StorageKey: {
|
|
87
|
+
PAGE_COUNT: 'PAGE_COUNT',
|
|
88
|
+
SHOW_HIT_SUMMARY_GRAPH: 'SHOW_HIT_SUMMARY_GRAPH'
|
|
89
|
+
}
|
|
90
|
+
}));
|
|
91
|
+
vi.mock('utils/typeUtils', () => ({
|
|
92
|
+
isHit: (item) => item?.__index === 'hit'
|
|
93
|
+
}));
|
|
94
|
+
vi.mock('utils/utils', () => ({
|
|
95
|
+
getTimeRange: (values) => [values[0], values[values.length - 1]],
|
|
96
|
+
notNil: (value) => value != null
|
|
97
|
+
}));
|
|
98
|
+
vi.mock('react', async (importOriginal) => {
|
|
99
|
+
const actual = await importOriginal();
|
|
100
|
+
return {
|
|
101
|
+
...actual,
|
|
102
|
+
useContext: (context) => {
|
|
103
|
+
if (context === fieldContextToken)
|
|
104
|
+
return fieldContextValue;
|
|
105
|
+
return actual.useContext(context);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
vi.mock('../PluginChip', () => ({
|
|
110
|
+
default: ({ label, onClick }) => _jsx("button", { onClick: onClick, children: label })
|
|
111
|
+
}));
|
|
112
|
+
vi.mock('./aggregate/HitGraph', () => ({
|
|
113
|
+
default: () => _jsx("div", { children: "hit-graph" })
|
|
114
|
+
}));
|
|
115
|
+
import HitSummary from './HitSummary';
|
|
116
|
+
describe('HitSummary', () => {
|
|
117
|
+
beforeEach(() => {
|
|
118
|
+
fieldContextValue = {
|
|
119
|
+
hitFields: [
|
|
120
|
+
{ key: 'severity', type: 'keyword' },
|
|
121
|
+
{ key: 'event.created', type: 'date' }
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
parameterContextValue = {
|
|
125
|
+
query: 'status:open',
|
|
126
|
+
setQuery: mockSetQuery,
|
|
127
|
+
views: []
|
|
128
|
+
};
|
|
129
|
+
recordSearchContextValue = {
|
|
130
|
+
searching: false,
|
|
131
|
+
error: '',
|
|
132
|
+
getFilters: mockGetFilters
|
|
133
|
+
};
|
|
134
|
+
mockDispatchApi.mockReset();
|
|
135
|
+
mockShowErrorMessage.mockReset();
|
|
136
|
+
mockSetQuery.mockReset();
|
|
137
|
+
mockGetFilters.mockClear();
|
|
138
|
+
mockGetMatchingTemplate.mockReset();
|
|
139
|
+
});
|
|
140
|
+
it('aggregates template keys, supports ad hoc fields, and updates the search query from results', async () => {
|
|
141
|
+
mockGetMatchingTemplate
|
|
142
|
+
.mockResolvedValueOnce({ analytic: 'Analytic A', detection: 'Rule A', keys: ['severity', 'howler.id'] })
|
|
143
|
+
.mockResolvedValueOnce({ analytic: 'Analytic A', detection: 'Rule B', keys: ['event.created'] });
|
|
144
|
+
mockDispatchApi
|
|
145
|
+
.mockResolvedValueOnce({
|
|
146
|
+
severity: { high: 2, low: 1 },
|
|
147
|
+
'event.created': { '2026-01-01T00:00:00Z': 1, '2026-01-02T00:00:00Z': 1 }
|
|
148
|
+
})
|
|
149
|
+
.mockResolvedValueOnce({
|
|
150
|
+
severity: { high: 2 },
|
|
151
|
+
'event.created': { '2026-01-01T00:00:00Z': 1, '2026-01-02T00:00:00Z': 1 },
|
|
152
|
+
'custom.field': { custom: 3 }
|
|
153
|
+
});
|
|
154
|
+
render(_jsx(HitSummary, { response: {
|
|
155
|
+
items: [
|
|
156
|
+
{ __index: 'hit', howler: { id: 'hit-1' } },
|
|
157
|
+
{ __index: 'hit', howler: { id: 'hit-2' } }
|
|
158
|
+
]
|
|
159
|
+
} }));
|
|
160
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({
|
|
161
|
+
fields: ['severity', 'event.created'],
|
|
162
|
+
query: 'status:open',
|
|
163
|
+
rows: 25,
|
|
164
|
+
filters: ['status:open']
|
|
165
|
+
}, { throwError: false, logError: true, showError: false }));
|
|
166
|
+
expect(screen.getByText('hit-graph')).toBeInTheDocument();
|
|
167
|
+
expect(screen.getByText('severity')).toBeInTheDocument();
|
|
168
|
+
fireEvent.click(screen.getByText('high (2)'));
|
|
169
|
+
expect(mockSetQuery).toHaveBeenCalledWith('severity:"high"');
|
|
170
|
+
fireEvent.click(screen.getByText('add-custom-field'));
|
|
171
|
+
fireEvent.click(screen.getByText('button.aggregate'));
|
|
172
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenLastCalledWith({
|
|
173
|
+
fields: ['custom.field'],
|
|
174
|
+
query: 'status:open',
|
|
175
|
+
rows: 25,
|
|
176
|
+
filters: ['status:open']
|
|
177
|
+
}, { throwError: false, logError: true, showError: false }));
|
|
178
|
+
expect(screen.getByText('custom.field')).toBeInTheDocument();
|
|
179
|
+
});
|
|
180
|
+
it('shows the empty state and reports aggregation failures', async () => {
|
|
181
|
+
mockGetMatchingTemplate.mockResolvedValueOnce({ analytic: 'Analytic A', detection: 'Rule A', keys: ['severity'] });
|
|
182
|
+
mockDispatchApi.mockRejectedValueOnce(new Error('aggregate failed'));
|
|
183
|
+
render(_jsx(HitSummary, { response: { items: [{ __index: 'hit', howler: { id: 'hit-1' } }] } }));
|
|
184
|
+
await waitFor(() => expect(mockShowErrorMessage).toHaveBeenCalledWith('aggregate failed'));
|
|
185
|
+
expect(screen.getByText('hit.summary.aggregate.nokeys.title')).toBeInTheDocument();
|
|
186
|
+
expect(screen.getByText('hit.summary.aggregate.nokeys.description')).toBeInTheDocument();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
vi.mock('@mui/material', () => ({
|
|
6
|
+
Badge: ({ children, badgeContent }) => (_jsxs("div", { children: [badgeContent, children] })),
|
|
7
|
+
Button: ({ children, onClick, disabled }) => (_jsx("button", { onClick: onClick, disabled: disabled, children: children })),
|
|
8
|
+
FormControl: ({ children }) => _jsx("div", { children: children }),
|
|
9
|
+
FormControlLabel: ({ label, onClick }) => _jsx("button", { onClick: onClick, children: label }),
|
|
10
|
+
FormLabel: ({ children }) => _jsx("div", { children: children }),
|
|
11
|
+
Radio: () => _jsx("div", { children: "radio" }),
|
|
12
|
+
RadioGroup: ({ children }) => _jsx("div", { children: children }),
|
|
13
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
14
|
+
Tooltip: ({ children }) => _jsx(_Fragment, { children: children }),
|
|
15
|
+
styled: (_component) => (styles) => {
|
|
16
|
+
void styles;
|
|
17
|
+
return ({ children, badgeContent }) => (_jsxs("div", { children: [badgeContent, children] }));
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
vi.mock('@mui/material/colors', () => ({
|
|
21
|
+
blueGrey: { 400: '#789' }
|
|
22
|
+
}));
|
|
23
|
+
vi.mock('react-i18next', () => ({
|
|
24
|
+
useTranslation: () => ({ t: (key) => key })
|
|
25
|
+
}));
|
|
26
|
+
import { HitShortcuts } from '../HitShortcuts';
|
|
27
|
+
import ButtonActions from './ButtonActions';
|
|
28
|
+
describe('ButtonActions', () => {
|
|
29
|
+
it('renders actions, assessments, and votes with shortcut badges and handles clicks', () => {
|
|
30
|
+
const actionFn = vi.fn();
|
|
31
|
+
const assessFn = vi.fn();
|
|
32
|
+
const voteFn = vi.fn();
|
|
33
|
+
render(_jsx(ButtonActions, { actions: [
|
|
34
|
+
{ type: 'action', name: 'Transition', actionFunction: actionFn, key: 'T' },
|
|
35
|
+
{ type: 'assessment', name: 'legitimate', actionFunction: assessFn, key: 'A' },
|
|
36
|
+
{ type: 'vote', name: 'Benign', actionFunction: voteFn, key: 'Q' }
|
|
37
|
+
], loading: false, orientation: "horizontal", shortcuts: HitShortcuts.SHORTCUTS_HINT, currentVote: "benign" }));
|
|
38
|
+
expect(screen.getByText('hit.details.actions.action')).toBeInTheDocument();
|
|
39
|
+
expect(screen.getByText('hit.details.actions.assessment')).toBeInTheDocument();
|
|
40
|
+
expect(screen.getByText('hit.details.actions.vote')).toBeInTheDocument();
|
|
41
|
+
expect(screen.getByText('T')).toBeInTheDocument();
|
|
42
|
+
expect(screen.getByText('A')).toBeInTheDocument();
|
|
43
|
+
expect(screen.getByText('Q')).toBeInTheDocument();
|
|
44
|
+
fireEvent.click(screen.getByText('Transition'));
|
|
45
|
+
fireEvent.click(screen.getByText('legitimate'));
|
|
46
|
+
fireEvent.click(screen.getByText('Benign'));
|
|
47
|
+
expect(actionFn).toHaveBeenCalled();
|
|
48
|
+
expect(assessFn).toHaveBeenCalled();
|
|
49
|
+
expect(voteFn).toHaveBeenCalled();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
const apiConfigContextToken = vi.hoisted(() => ({ name: 'api-config-context' }));
|
|
6
|
+
let configValue = {};
|
|
7
|
+
vi.mock('@mui/material', () => ({
|
|
8
|
+
FormControl: ({ children, disabled }) => _jsx("fieldset", { disabled: disabled, children: children }),
|
|
9
|
+
formControlClasses: { root: 'MuiFormControl-root' },
|
|
10
|
+
Grid: ({ children }) => _jsx("div", { children: children }),
|
|
11
|
+
InputLabel: ({ children }) => _jsx("label", { children: children }),
|
|
12
|
+
MenuItem: ({ children, onClick }) => _jsx("button", { onClick: onClick, children: children }),
|
|
13
|
+
Select: ({ children }) => _jsx("div", { children: children }),
|
|
14
|
+
Skeleton: () => _jsx("div", { children: "loading" }),
|
|
15
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
16
|
+
Typography: ({ children }) => _jsx("div", { children: children })
|
|
17
|
+
}));
|
|
18
|
+
vi.mock('components/app/providers/ApiConfigProvider', () => ({
|
|
19
|
+
ApiConfigContext: apiConfigContextToken
|
|
20
|
+
}));
|
|
21
|
+
vi.mock('lodash-es', () => ({
|
|
22
|
+
capitalize: (value) => value.charAt(0).toUpperCase() + value.slice(1)
|
|
23
|
+
}));
|
|
24
|
+
vi.mock('react-i18next', () => ({
|
|
25
|
+
useTranslation: () => ({ t: (key) => key })
|
|
26
|
+
}));
|
|
27
|
+
vi.mock('react', async (importOriginal) => {
|
|
28
|
+
const actual = await importOriginal();
|
|
29
|
+
return {
|
|
30
|
+
...actual,
|
|
31
|
+
useContext: (context) => {
|
|
32
|
+
if (context === apiConfigContextToken)
|
|
33
|
+
return { config: configValue };
|
|
34
|
+
return actual.useContext(context);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
import DropdownActions from './DropdownActions';
|
|
39
|
+
describe('DropdownActions', () => {
|
|
40
|
+
it('renders skeletons without lookups and action menus with lookups', () => {
|
|
41
|
+
const actionFn = vi.fn();
|
|
42
|
+
const assessFn = vi.fn();
|
|
43
|
+
const voteFn = vi.fn();
|
|
44
|
+
configValue = {};
|
|
45
|
+
const { rerender } = render(_jsx(DropdownActions, { actions: [], currentAssessment: "", currentStatus: "open", currentVote: "", loading: false, orientation: "horizontal" }));
|
|
46
|
+
expect(screen.getAllByText('loading')).toHaveLength(3);
|
|
47
|
+
configValue = { lookups: { any: true } };
|
|
48
|
+
rerender(_jsx(DropdownActions, { actions: [
|
|
49
|
+
{ type: 'action', name: 'Transition', actionFunction: actionFn },
|
|
50
|
+
{ type: 'assessment', name: 'false-positive', actionFunction: assessFn },
|
|
51
|
+
{ type: 'vote', name: 'Benign', actionFunction: voteFn }
|
|
52
|
+
], currentAssessment: "", currentStatus: "open", currentVote: "", loading: false, orientation: "vertical" }));
|
|
53
|
+
fireEvent.click(screen.getByText('Transition'));
|
|
54
|
+
fireEvent.click(screen.getByText('False Positive'));
|
|
55
|
+
fireEvent.click(screen.getByText('Benign'));
|
|
56
|
+
expect(actionFn).toHaveBeenCalled();
|
|
57
|
+
expect(assessFn).toHaveBeenCalled();
|
|
58
|
+
expect(voteFn).toHaveBeenCalled();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
const mockGetMatchingTemplate = vi.hoisted(() => vi.fn());
|
|
6
|
+
const fieldContextToken = vi.hoisted(() => ({ name: 'field-context' }));
|
|
7
|
+
const recordSearchContextToken = vi.hoisted(() => ({ name: 'record-search-context' }));
|
|
8
|
+
let fieldContextValue;
|
|
9
|
+
let responseValue;
|
|
10
|
+
vi.mock('@mui/icons-material', () => ({
|
|
11
|
+
Add: () => _jsx("div", { children: "add-icon" }),
|
|
12
|
+
Check: () => _jsx("div", { children: "check-icon" }),
|
|
13
|
+
Settings: () => _jsx("div", { children: "settings-icon" }),
|
|
14
|
+
TableChart: () => _jsx("div", { children: "table-icon" })
|
|
15
|
+
}));
|
|
16
|
+
vi.mock('@mui/material', () => ({
|
|
17
|
+
Autocomplete: ({ options, value, onChange, renderInput }) => (_jsxs("div", { children: [renderInput({}), _jsx("button", { onClick: () => onChange?.(null, options[0] ?? null), children: value ?? 'pick-field' })] })),
|
|
18
|
+
Chip: ({ label, onClick, disabled }) => (_jsx("button", { onClick: onClick, disabled: disabled, children: label })),
|
|
19
|
+
Divider: () => _jsx("div", { children: "divider" }),
|
|
20
|
+
Grid: ({ children }) => _jsx("div", { children: children }),
|
|
21
|
+
IconButton: ({ children, onClick, disabled }) => (_jsx("button", { onClick: onClick, disabled: disabled, children: children })),
|
|
22
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
23
|
+
TextField: ({ placeholder }) => _jsx("div", { children: placeholder })
|
|
24
|
+
}));
|
|
25
|
+
vi.mock('components/app/hooks/useMatchers', () => ({
|
|
26
|
+
default: () => ({ getMatchingTemplate: mockGetMatchingTemplate })
|
|
27
|
+
}));
|
|
28
|
+
vi.mock('components/app/providers/FieldProvider', () => ({
|
|
29
|
+
FieldContext: fieldContextToken
|
|
30
|
+
}));
|
|
31
|
+
vi.mock('components/app/providers/RecordSearchProvider', () => ({
|
|
32
|
+
RecordSearchContext: recordSearchContextToken
|
|
33
|
+
}));
|
|
34
|
+
vi.mock('components/elements/display/ChipPopper', () => ({
|
|
35
|
+
default: ({ children }) => _jsx("div", { children: children })
|
|
36
|
+
}));
|
|
37
|
+
vi.mock('lodash-es', () => ({
|
|
38
|
+
sortBy: (values, key) => [...values].sort((a, b) => Number(a[key]) - Number(b[key])),
|
|
39
|
+
uniq: (values) => [...new Set(values)]
|
|
40
|
+
}));
|
|
41
|
+
vi.mock('react-i18next', () => ({
|
|
42
|
+
useTranslation: () => ({ t: (key) => key })
|
|
43
|
+
}));
|
|
44
|
+
vi.mock('use-context-selector', () => ({
|
|
45
|
+
useContextSelector: (context, selector) => {
|
|
46
|
+
if (context === recordSearchContextToken)
|
|
47
|
+
return selector({ response: responseValue });
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
vi.mock('utils/typeUtils', () => ({
|
|
52
|
+
isHit: (record) => record?.__index === 'hit'
|
|
53
|
+
}));
|
|
54
|
+
vi.mock('react', async (importOriginal) => {
|
|
55
|
+
const actual = await importOriginal();
|
|
56
|
+
return {
|
|
57
|
+
...actual,
|
|
58
|
+
useContext: (context) => {
|
|
59
|
+
if (context === fieldContextToken)
|
|
60
|
+
return fieldContextValue;
|
|
61
|
+
return actual.useContext(context);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
import AddColumnModal from './AddColumnModal';
|
|
66
|
+
describe('AddColumnModal', () => {
|
|
67
|
+
beforeEach(() => {
|
|
68
|
+
fieldContextValue = { hitFields: [{ key: 'severity' }, { key: 'event.created' }] };
|
|
69
|
+
responseValue = {
|
|
70
|
+
items: [
|
|
71
|
+
{ __index: 'hit', howler: { id: 'hit-1' } },
|
|
72
|
+
{ __index: 'event', howler: { id: 'event-1' } }
|
|
73
|
+
]
|
|
74
|
+
};
|
|
75
|
+
mockGetMatchingTemplate.mockReset().mockResolvedValue({ keys: ['severity', 'custom.field', 'custom.field'] });
|
|
76
|
+
});
|
|
77
|
+
it('adds explicit columns and suggested columns while disabling used suggestions', async () => {
|
|
78
|
+
const addColumn = vi.fn();
|
|
79
|
+
render(_jsx(AddColumnModal, { addColumn: addColumn, columns: ['severity'] }));
|
|
80
|
+
await waitFor(() => expect(mockGetMatchingTemplate).toHaveBeenCalledTimes(1));
|
|
81
|
+
fireEvent.click(screen.getByText('pick-field'));
|
|
82
|
+
fireEvent.click(screen.getAllByText('add-icon')[0].parentElement);
|
|
83
|
+
expect(addColumn).toHaveBeenCalledWith('severity');
|
|
84
|
+
expect(screen.getByText('severity')).toBeDisabled();
|
|
85
|
+
fireEvent.click(screen.getByText('custom.field'));
|
|
86
|
+
expect(addColumn).toHaveBeenCalledWith('custom.field');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|