@cccsaurora/howler-ui 2.19.0-dev.999 → 2.20.0-dev.1352
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/index.d.ts +5 -4
- package/api/action/index.js +8 -8
- package/api/analytic/index.d.ts +5 -5
- package/api/analytic/index.js +5 -6
- package/api/analytic/owner.d.ts +2 -1
- package/api/analytic/owner.js +2 -2
- package/api/dossier/index.d.ts +4 -3
- package/api/dossier/index.js +6 -6
- package/api/hit/index.d.ts +3 -2
- package/api/hit/index.js +4 -4
- package/api/hit/labels.d.ts +3 -2
- package/api/hit/labels.js +4 -4
- package/api/hit/overwrite.d.ts +2 -1
- package/api/hit/overwrite.js +2 -2
- package/api/hit/transition.d.ts +2 -1
- package/api/hit/transition.js +2 -2
- package/api/index.d.ts +10 -5
- package/api/index.js +18 -10
- package/api/overview/index.d.ts +4 -3
- package/api/overview/index.js +6 -6
- package/api/search/action.js +1 -1
- package/api/search/analytic.js +1 -1
- package/api/search/case.d.ts +4 -0
- package/api/search/case.js +8 -0
- package/api/search/count/hit.js +1 -1
- package/api/search/dossier.js +1 -1
- package/api/search/eql/hit.js +1 -1
- package/api/search/explain/hit.js +1 -1
- package/api/search/facet/hit.d.ts +1 -3
- package/api/search/facet/hit.js +1 -1
- package/api/search/facet/index.d.ts +3 -1
- package/api/search/grouped/hit.js +1 -1
- package/api/search/grouped/user.js +1 -1
- package/api/search/histogram/hit.js +1 -1
- package/api/search/hit.js +1 -1
- package/api/search/index.d.ts +3 -1
- package/api/search/index.js +2 -1
- package/api/search/overview.d.ts +2 -2
- package/api/search/overview.js +1 -1
- package/api/search/sigma/hit.js +1 -1
- package/api/search/template.js +1 -1
- package/api/search/user.js +1 -1
- package/api/search/view.js +1 -1
- package/api/socket/index.d.ts +3 -0
- package/api/socket/index.js +6 -0
- package/api/socket/viewers.d.ts +2 -0
- package/api/socket/viewers.js +8 -0
- package/api/socket/viewers.test.js +44 -0
- package/api/template/index.d.ts +4 -3
- package/api/template/index.js +6 -6
- package/api/user/index.d.ts +2 -1
- package/api/user/index.js +2 -2
- package/api/v2/case/index.d.ts +9 -0
- package/api/v2/case/index.js +21 -0
- package/api/v2/case/items.d.ts +9 -0
- package/api/v2/case/items.js +19 -0
- package/api/v2/case/rules.d.ts +6 -0
- package/api/v2/case/rules.js +18 -0
- package/api/v2/fuzzy.d.ts +17 -0
- package/api/v2/fuzzy.js +11 -0
- package/api/v2/index.d.ts +5 -0
- package/api/v2/index.js +7 -0
- package/api/v2/search/facet.d.ts +3 -0
- package/api/v2/search/facet.js +12 -0
- package/api/v2/search/index.d.ts +6 -0
- package/api/v2/search/index.js +24 -0
- package/api/view/index.d.ts +4 -3
- package/api/view/index.js +6 -6
- package/branding/AppBrand.d.ts +2 -2
- package/commons/components/app/AppSkeleton.js +1 -1
- package/commons/components/app/hooks/useAppConfigs.d.ts +2 -2
- package/commons/components/app/hooks/useAppSitemap.d.ts +5 -2
- package/commons/components/breadcrumbs/BreadcrumbIcon.js +1 -1
- package/commons/components/breadcrumbs/Breadcrumbs.d.ts +3 -2
- package/commons/components/display/AppToc.d.ts +2 -1
- package/commons/components/display/AppToc.js +1 -1
- package/commons/components/display/hooks/useAppColor.d.ts +1 -1
- package/commons/components/leftnav/LeftNavDrawer.d.ts +2 -1
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/commons/components/leftnav/LeftNavGroup.d.ts +2 -1
- package/commons/components/leftnav/LeftNavItem.d.ts +2 -1
- package/commons/components/leftnav/LeftNavItem.js +1 -1
- package/commons/components/notification/Notification.js +1 -1
- package/commons/components/notification/elements/NotificationHeader.js +1 -1
- package/commons/components/notification/elements/NotificationItems.js +1 -1
- package/commons/components/notification/elements/item/NotificationItemAuthor.js +1 -1
- package/commons/components/pages/PageCenter.d.ts +2 -1
- package/commons/components/pages/PageContent.d.ts +2 -1
- package/commons/components/pages/PageFullScreen.d.ts +2 -1
- package/commons/components/search/AppSearch.js +1 -1
- package/commons/components/search/AppSearchInput.d.ts +2 -1
- package/commons/components/search/AppSearchResult.d.ts +2 -1
- package/commons/components/topnav/AppBar.d.ts +2 -1
- package/commons/components/topnav/AppName.d.ts +3 -2
- package/commons/components/topnav/AppSwitcher.d.ts +2 -1
- package/commons/components/topnav/ThemeSelection.d.ts +2 -1
- package/commons/components/topnav/ThemeSelection.js +1 -1
- package/commons/components/topnav/UserProfile.d.ts +2 -1
- package/commons/components/topnav/UserProfile.js +1 -1
- package/commons/components/utils/hooks/useThemeBuilder.d.ts +1 -1
- package/components/app/App.js +52 -12
- package/components/app/drawers/ApiKeyDrawer.js +1 -1
- package/components/app/hooks/useMatchers.d.ts +1 -1
- package/components/app/hooks/useMatchers.js +27 -15
- package/components/app/hooks/useMatchers.test.js +22 -22
- package/components/app/hooks/useTitle.js +6 -6
- package/components/app/providers/AnalyticProvider.js +1 -1
- package/components/app/providers/AvatarProvider.js +1 -1
- package/components/app/providers/FavouritesProvider.js +3 -3
- package/components/app/providers/GridColumnsProvider.d.ts +52 -0
- package/components/app/providers/GridColumnsProvider.js +177 -0
- package/components/app/providers/GridColumnsProvider.test.js +255 -0
- package/components/app/providers/ModalProvider.d.ts +1 -0
- package/components/app/providers/OverviewProvider.js +1 -1
- package/components/app/providers/ParameterProvider.d.ts +25 -3
- package/components/app/providers/ParameterProvider.js +163 -226
- package/components/app/providers/ParameterProvider.test.js +358 -94
- package/components/app/providers/RecordProvider.d.ts +23 -0
- package/components/app/providers/{HitProvider.js → RecordProvider.js} +47 -43
- package/components/app/providers/{HitSearchProvider.d.ts → RecordSearchProvider.d.ts} +6 -6
- package/components/app/providers/{HitSearchProvider.js → RecordSearchProvider.js} +24 -37
- package/components/app/providers/{HitSearchProvider.test.js → RecordSearchProvider.test.js} +52 -71
- package/components/app/providers/SearchResponseProvider.d.ts +21 -0
- package/components/app/providers/SearchResponseProvider.js +81 -0
- package/components/app/providers/SearchResponseProvider.test.d.ts +1 -0
- package/components/app/providers/SearchResponseProvider.test.js +406 -0
- package/components/app/providers/SocketProvider.d.ts +11 -2
- package/components/app/providers/SocketProvider.js +21 -8
- package/components/app/providers/UserListProvider.js +28 -8
- package/components/app/providers/UserListProvider.test.d.ts +1 -0
- package/components/app/providers/UserListProvider.test.js +150 -0
- package/components/app/providers/ViewProvider.js +3 -3
- package/components/app/providers/ViewProvider.test.js +4 -1
- package/components/elements/Comment.js +2 -2
- package/components/elements/ContextMenu.d.ts +56 -0
- package/components/elements/ContextMenu.js +113 -0
- package/components/elements/ContextMenu.test.d.ts +1 -0
- package/components/elements/ContextMenu.test.js +215 -0
- package/components/elements/EditRow.js +4 -4
- package/components/{routes/overviews/OverviewEditor.js → elements/MarkdownEditor.js} +3 -3
- package/components/elements/ObjectDetails.d.ts +6 -0
- package/components/elements/{hit/HitDetails.js → ObjectDetails.js} +17 -17
- package/components/elements/PluginChip.d.ts +1 -1
- package/components/elements/PluginChip.js +0 -1
- package/components/elements/PluginTypography.d.ts +2 -1
- package/components/elements/PluginTypography.js +3 -2
- package/components/elements/UserList.d.ts +5 -2
- package/components/elements/UserList.js +34 -17
- package/components/elements/UserList.test.d.ts +1 -0
- package/components/elements/UserList.test.js +122 -0
- package/components/elements/addons/buttons/CustomIconButton.test.d.ts +1 -0
- package/components/elements/addons/buttons/CustomIconButton.test.js +81 -0
- package/components/elements/addons/buttons/index.d.ts +1 -1
- package/components/elements/addons/layout/FlexOne.d.ts +3 -2
- package/components/elements/addons/layout/FlexPort.d.ts +2 -1
- package/components/elements/addons/layout/FlexVertical.d.ts +2 -1
- package/components/elements/addons/layout/FlexVertical.test.d.ts +1 -0
- package/components/elements/addons/layout/FlexVertical.test.js +32 -0
- package/components/elements/addons/layout/vsbox/VSBoxContent.test.d.ts +1 -0
- package/components/elements/addons/layout/vsbox/VSBoxContent.test.js +26 -0
- package/components/elements/addons/layout/vsbox/VSBoxElement.d.ts +2 -1
- package/components/elements/addons/lists/TuiList.d.ts +2 -1
- package/components/elements/addons/lists/TuiListBase.d.ts +2 -1
- package/components/elements/addons/lists/TuiListElement.d.ts +3 -2
- package/components/elements/addons/lists/TuiListElement.js +0 -1
- package/components/elements/addons/lists/TuiListMenu.d.ts +2 -1
- package/components/elements/addons/lists/TuiListMenu.js +1 -1
- package/components/elements/addons/lists/table/TuiTableHeader.d.ts +3 -2
- package/components/elements/addons/lists/table/index.d.ts +1 -1
- package/components/elements/addons/search/SearchPagination.d.ts +2 -1
- package/components/elements/addons/search/SearchPagination.js +4 -4
- package/components/elements/addons/search/SearchTotal.js +1 -1
- package/components/elements/addons/search/SearchTotal.test.js +5 -3
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/addons/search/phrase/WordLexer.test.d.ts +1 -0
- package/components/elements/addons/search/phrase/WordLexer.test.js +55 -0
- package/components/elements/case/CaseCard.d.ts +12 -0
- package/components/elements/case/CaseCard.js +43 -0
- package/components/elements/case/CasePreview.d.ts +6 -0
- package/components/elements/case/CasePreview.js +17 -0
- package/components/elements/case/StatusIcon.d.ts +5 -0
- package/components/elements/case/StatusIcon.js +13 -0
- package/components/elements/display/ActionButton.js +1 -1
- package/components/elements/display/ChipPopper.d.ts +1 -1
- package/components/elements/display/ChipPopper.js +7 -6
- package/components/elements/display/Classification.js +1 -1
- package/components/elements/display/ClassificationChip.d.ts +14 -0
- package/components/elements/display/ClassificationChip.js +36 -0
- package/components/elements/display/HandlebarsMarkdown.js +38 -3
- package/components/elements/display/HowlerAvatar.js +2 -2
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/HowlerCard.test.js +5 -9
- package/components/elements/display/Image.js +3 -3
- package/components/elements/display/ItemManager.d.ts +2 -2
- package/components/elements/display/ItemManager.js +3 -3
- package/components/elements/display/Markdown.js +2 -2
- package/components/elements/display/Modal.js +2 -0
- package/components/elements/display/QueryResultText.d.ts +1 -0
- package/components/elements/display/QueryResultText.js +2 -2
- package/components/elements/display/handlebars/helpers.d.ts +4 -0
- package/components/elements/display/handlebars/helpers.js +134 -35
- package/components/elements/display/json/JSONViewer.js +2 -2
- package/components/elements/display/modals/RationaleModal.js +2 -2
- package/components/elements/display/modals/RationaleModal.test.js +1 -1
- package/components/elements/event/EventCard.d.ts +6 -0
- package/components/elements/event/EventCard.js +22 -0
- package/components/elements/event/EventPreview.d.ts +6 -0
- package/components/elements/event/EventPreview.js +12 -0
- package/components/elements/hit/HitActions.d.ts +1 -1
- package/components/elements/hit/HitActions.js +5 -5
- package/components/elements/hit/HitBanner.d.ts +1 -0
- package/components/elements/hit/HitBanner.js +32 -50
- package/components/elements/hit/HitCard.d.ts +4 -0
- package/components/elements/hit/HitCard.js +7 -7
- package/components/elements/hit/HitLabels.js +3 -3
- package/components/elements/hit/HitLabels.test.d.ts +1 -0
- package/components/elements/hit/HitLabels.test.js +77 -0
- package/components/elements/hit/HitLinks.d.ts +5 -4
- package/components/elements/hit/HitLinks.js +28 -10
- package/components/elements/hit/HitNotebooks.js +32 -31
- package/components/elements/hit/HitOutline.d.ts +1 -0
- package/components/elements/hit/HitOutline.js +4 -4
- package/components/elements/hit/HitOverview.js +2 -2
- package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
- package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +11 -5
- package/components/elements/hit/HitSummary.d.ts +2 -1
- package/components/elements/hit/HitSummary.js +8 -7
- package/components/elements/hit/NotebookTooltip.d.ts +3 -0
- package/components/elements/hit/NotebookTooltip.js +8 -0
- package/components/elements/hit/PivotTooltip.d.ts +7 -0
- package/components/elements/hit/PivotTooltip.js +9 -0
- package/components/elements/hit/RelatedLinkTooltip.d.ts +6 -0
- package/components/elements/hit/RelatedLinkTooltip.js +8 -0
- package/components/elements/hit/ResolvePivotUrl.d.ts +4 -0
- package/components/elements/hit/ResolvePivotUrl.js +22 -0
- package/components/elements/hit/actions/ButtonActions.js +1 -3
- package/components/elements/hit/aggregate/HitGraph.js +9 -9
- package/components/elements/hit/elements/AnalyticLink.d.ts +9 -0
- package/components/elements/hit/elements/AnalyticLink.js +22 -0
- package/components/elements/hit/elements/{HitUsers.d.ts → Assigned.d.ts} +2 -4
- package/components/elements/hit/elements/Assigned.js +35 -0
- package/components/elements/hit/elements/Assigned.test.d.ts +1 -0
- package/components/elements/hit/elements/Assigned.test.js +65 -0
- package/components/{routes/hits/search → elements/hit}/grid/AddColumnModal.js +6 -5
- package/components/{routes/hits/search → elements/hit}/grid/ColumnHeader.d.ts +2 -1
- package/components/{routes/hits/search → elements/hit}/grid/ColumnHeader.js +3 -3
- package/components/{routes/hits/search → elements/hit}/grid/EnhancedCell.d.ts +2 -1
- package/components/{routes/hits/search → elements/hit}/grid/EnhancedCell.js +2 -2
- package/components/{routes/hits/search/grid/HitRow.d.ts → elements/hit/grid/RecordRow.d.ts} +4 -3
- package/components/{routes/hits/search/grid/HitRow.js → elements/hit/grid/RecordRow.js} +12 -10
- package/components/elements/hit/grid/RecordTable.d.ts +13 -0
- package/components/elements/hit/grid/RecordTable.js +84 -0
- package/components/elements/hit/outlines/DefaultOutline.js +2 -4
- package/components/elements/hit/related/PivotLink.d.ts +3 -0
- package/components/elements/hit/related/PivotLink.js +6 -3
- package/components/elements/hit/related/RelatedLink.d.ts +1 -0
- package/components/elements/hit/related/RelatedLink.js +18 -15
- package/components/elements/hit/related/RelatedRecords.js +63 -0
- package/components/elements/{hit/HitComments.d.ts → record/RecordComments.d.ts} +5 -4
- package/components/elements/{hit/HitComments.js → record/RecordComments.js} +33 -34
- package/components/{routes/hits/search/HitContextMenu.d.ts → elements/record/RecordContextMenu.d.ts} +3 -3
- package/components/elements/record/RecordContextMenu.js +268 -0
- package/components/elements/record/RecordContextMenu.test.d.ts +1 -0
- package/components/{routes/hits/search/HitContextMenu.test.js → elements/record/RecordContextMenu.test.js} +143 -49
- package/components/elements/record/RecordRelated.d.ts +7 -0
- package/components/elements/record/RecordRelated.js +34 -0
- package/components/elements/{hit/HitWorklog.d.ts → record/RecordWorklog.d.ts} +4 -3
- package/components/elements/{hit/HitWorklog.js → record/RecordWorklog.js} +16 -14
- package/components/elements/search/FuzzySearchBar.d.ts +7 -0
- package/components/elements/search/FuzzySearchBar.js +33 -0
- package/components/elements/search/FuzzySearchBar.test.d.ts +1 -0
- package/components/elements/search/FuzzySearchBar.test.js +87 -0
- package/components/elements/view/LayoutToggle.d.ts +8 -0
- package/components/elements/view/LayoutToggle.js +12 -0
- package/components/elements/view/ViewTitle.d.ts +4 -0
- package/components/elements/view/ViewTitle.js +13 -3
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +5 -5
- package/components/hooks/useLocalStorage.js +1 -1
- package/components/hooks/useLocalStorageItem.test.js +2 -2
- package/components/hooks/useMyApi.d.ts +1 -1
- package/components/hooks/useMyChart.d.ts +23 -23
- package/components/hooks/useMyPreferences.js +10 -1
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +3 -1
- package/components/hooks/useMySnackbar.js +1 -1
- package/components/hooks/useMyTheme.js +9 -2
- package/components/hooks/useMyTheme.test.d.ts +1 -0
- package/components/hooks/useMyTheme.test.js +35 -0
- package/components/hooks/useMyUserFunctions.d.ts +21 -21
- package/components/hooks/{useHitSelection.d.ts → useRecordSelection.d.ts} +2 -2
- package/components/hooks/{useHitSelection.js → useRecordSelection.js} +12 -33
- package/components/hooks/useRelatedRecords.d.ts +13 -0
- package/components/hooks/useRelatedRecords.js +32 -0
- package/components/logins/Login.js +1 -1
- package/components/logins/auth/OAuthLogin.js +1 -1
- package/components/logins/hooks/useLogin.js +2 -2
- package/components/routes/ErrorBoundary.d.ts +2 -13
- package/components/routes/ErrorBoundary.js +12 -1
- package/components/routes/ErrorBoundary.test.js +27 -4
- package/components/routes/action/edit/ActionEditor.js +6 -6
- package/components/routes/action/shared/OperationEntry.js +1 -1
- package/components/routes/action/shared/OperationStep.js +1 -1
- package/components/routes/action/useMyActionFunctions.js +6 -3
- package/components/routes/action/view/ActionDetails.js +9 -3
- package/components/routes/action/view/ActionSearch.js +25 -19
- package/components/routes/admin/users/UserEditor.js +1 -1
- package/components/routes/admin/users/UserSearch.js +5 -5
- package/components/routes/advanced/QueryBuilder.js +6 -29
- package/components/routes/advanced/QueryEditor.js +3 -3
- package/components/routes/advanced/eqlTokenProvider.test.d.ts +1 -0
- package/components/routes/advanced/eqlTokenProvider.test.js +34 -0
- package/components/routes/advanced/historyCompletionProvider.js +3 -3
- package/components/routes/advanced/luceneCompletionProvider.js +1 -1
- package/components/routes/advanced/luceneTokenProvider.test.d.ts +1 -0
- package/components/routes/advanced/luceneTokenProvider.test.js +34 -0
- package/components/routes/analytics/AnalyticComments.js +3 -5
- package/components/routes/analytics/AnalyticDetails.js +8 -56
- package/components/routes/analytics/AnalyticHitComments.js +1 -1
- package/components/routes/analytics/AnalyticHitComments.test.js +1 -1
- package/components/routes/analytics/AnalyticOverview.js +2 -2
- package/components/routes/analytics/AnalyticOverviews.js +1 -1
- package/components/routes/analytics/AnalyticSearch.js +16 -25
- package/components/routes/analytics/AnalyticTemplates.js +1 -1
- package/components/routes/analytics/TriageSettings.js +2 -2
- package/components/routes/analytics/widgets/Assessment.js +1 -1
- package/components/routes/analytics/widgets/Created.js +1 -1
- package/components/routes/analytics/widgets/Escalation.js +1 -1
- package/components/routes/analytics/widgets/Stacked.js +1 -1
- package/components/routes/cases/CaseViewer.d.ts +2 -0
- package/components/routes/cases/CaseViewer.js +44 -0
- package/components/routes/cases/CaseViewer.test.d.ts +1 -0
- package/components/routes/cases/CaseViewer.test.js +156 -0
- package/components/routes/cases/Cases.d.ts +2 -0
- package/components/routes/cases/Cases.js +140 -0
- package/components/routes/cases/constants.d.ts +6 -0
- package/components/routes/cases/constants.js +6 -0
- package/components/routes/cases/detail/AlertPanel.d.ts +6 -0
- package/components/routes/cases/detail/AlertPanel.js +34 -0
- package/components/routes/cases/detail/AlertPanel.test.d.ts +1 -0
- package/components/routes/cases/detail/AlertPanel.test.js +107 -0
- package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
- package/components/routes/cases/detail/CaseDashboard.js +66 -0
- package/components/routes/cases/detail/CaseDashboard.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseDashboard.test.js +218 -0
- package/components/routes/cases/detail/CaseDetails.d.ts +6 -0
- package/components/routes/cases/detail/CaseDetails.js +79 -0
- package/components/routes/cases/detail/CaseDetails.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseDetails.test.js +145 -0
- package/components/routes/cases/detail/CaseObservables.d.ts +6 -0
- package/components/routes/cases/detail/CaseObservables.js +127 -0
- package/components/routes/cases/detail/CaseObservables.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseObservables.test.js +167 -0
- package/components/routes/cases/detail/CaseOverview.d.ts +7 -0
- package/components/routes/cases/detail/CaseOverview.js +40 -0
- package/components/routes/cases/detail/CaseRules.d.ts +7 -0
- package/components/routes/cases/detail/CaseRules.js +55 -0
- package/components/routes/cases/detail/CaseRules.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseRules.test.js +238 -0
- package/components/routes/cases/detail/CaseSearch.d.ts +3 -0
- package/components/routes/cases/detail/CaseSearch.js +78 -0
- package/components/routes/cases/detail/CaseSearch.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseSearch.test.js +154 -0
- package/components/routes/cases/detail/CaseSidebar.d.ts +8 -0
- package/components/routes/cases/detail/CaseSidebar.js +147 -0
- package/components/routes/cases/detail/CaseSidebar.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseSidebar.test.js +155 -0
- package/components/routes/cases/detail/CaseTask.d.ts +14 -0
- package/components/routes/cases/detail/CaseTask.js +71 -0
- package/components/routes/cases/detail/CaseTask.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseTask.test.js +143 -0
- package/components/routes/cases/detail/CaseTimeline.d.ts +12 -0
- package/components/routes/cases/detail/CaseTimeline.js +120 -0
- package/components/routes/cases/detail/CaseTimeline.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseTimeline.test.js +319 -0
- package/components/routes/cases/detail/CreateRuleDialog.d.ts +9 -0
- package/components/routes/cases/detail/CreateRuleDialog.js +145 -0
- package/components/routes/cases/detail/CreateRuleDialog.test.d.ts +1 -0
- package/components/routes/cases/detail/CreateRuleDialog.test.js +218 -0
- package/components/routes/cases/detail/ItemPage.d.ts +6 -0
- package/components/routes/cases/detail/ItemPage.js +100 -0
- package/components/routes/cases/detail/ItemPage.test.d.ts +1 -0
- package/components/routes/cases/detail/ItemPage.test.js +238 -0
- package/components/routes/cases/detail/MarkdownPage.d.ts +8 -0
- package/components/routes/cases/detail/MarkdownPage.js +63 -0
- package/components/routes/cases/detail/MarkdownPage.test.d.ts +1 -0
- package/components/routes/cases/detail/MarkdownPage.test.js +116 -0
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +6 -0
- package/components/routes/cases/detail/RelatedCasePanel.js +34 -0
- package/components/routes/cases/detail/RelatedCasePanel.test.d.ts +1 -0
- package/components/routes/cases/detail/RelatedCasePanel.test.js +115 -0
- package/components/routes/cases/detail/TaskPanel.d.ts +7 -0
- package/components/routes/cases/detail/TaskPanel.js +95 -0
- package/components/routes/cases/detail/TaskPanel.test.d.ts +1 -0
- package/components/routes/cases/detail/TaskPanel.test.js +145 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +11 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +24 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +6 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +26 -0
- package/components/routes/cases/detail/observables/Observable.d.ts +8 -0
- package/components/routes/cases/detail/observables/Observable.js +14 -0
- package/components/routes/cases/detail/observables/Observable.test.d.ts +1 -0
- package/components/routes/cases/detail/observables/Observable.test.js +80 -0
- package/components/routes/cases/detail/observables/ObservableTable.d.ts +7 -0
- package/components/routes/cases/detail/observables/ObservableTable.js +61 -0
- package/components/routes/cases/detail/observables/ObservableTable.test.d.ts +1 -0
- package/components/routes/cases/detail/observables/ObservableTable.test.js +97 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +22 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.js +105 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.test.js +98 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.d.ts +32 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.js +99 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.js +117 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.d.ts +25 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.js +89 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.test.js +81 -0
- package/components/routes/cases/detail/sidebar/RootDropZone.d.ts +5 -0
- package/components/routes/cases/detail/sidebar/RootDropZone.js +33 -0
- package/components/routes/cases/detail/sidebar/types.d.ts +9 -0
- package/components/routes/cases/detail/sidebar/utils.d.ts +10 -0
- package/components/routes/cases/detail/sidebar/utils.js +51 -0
- package/components/routes/cases/detail/sidebar/utils.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/utils.test.js +82 -0
- package/components/routes/cases/detail/types.d.ts +22 -0
- package/components/routes/cases/detail/utils.d.ts +28 -0
- package/components/routes/cases/detail/utils.js +117 -0
- package/components/routes/cases/detail/utils.test.d.ts +1 -0
- package/components/routes/cases/detail/utils.test.js +166 -0
- package/components/routes/cases/hooks/useCase.d.ts +13 -0
- package/components/routes/cases/hooks/useCase.js +67 -0
- package/components/routes/cases/hooks/useCase.test.d.ts +1 -0
- package/components/routes/cases/hooks/useCase.test.js +170 -0
- package/components/routes/cases/modals/AddRecordToCaseModal.d.ts +7 -0
- package/components/routes/cases/modals/AddRecordToCaseModal.js +57 -0
- package/components/routes/cases/modals/AddRecordToCaseModal.test.d.ts +1 -0
- package/components/routes/cases/modals/AddRecordToCaseModal.test.js +309 -0
- package/components/routes/cases/modals/AddToCaseModal.d.ts +9 -0
- package/components/routes/cases/modals/AddToCaseModal.js +72 -0
- package/components/routes/cases/modals/CaseRecordRow.d.ts +9 -0
- package/components/routes/cases/modals/CaseRecordRow.js +14 -0
- package/components/routes/cases/modals/CreateCaseModal.d.ts +7 -0
- package/components/routes/cases/modals/CreateCaseModal.js +53 -0
- package/components/routes/cases/modals/CreateCaseModal.test.d.ts +1 -0
- package/components/routes/cases/modals/CreateCaseModal.test.js +319 -0
- package/components/routes/cases/modals/RenameItemModal.d.ts +9 -0
- package/components/routes/cases/modals/RenameItemModal.js +44 -0
- package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
- package/components/routes/cases/modals/ResolveModal.js +120 -0
- package/components/routes/cases/modals/ResolveModal.test.d.ts +1 -0
- package/components/routes/cases/modals/ResolveModal.test.js +520 -0
- package/components/routes/cases/modals/hooks.d.ts +7 -0
- package/components/routes/cases/modals/hooks.js +40 -0
- package/components/routes/cases/modals/types.d.ts +13 -0
- package/components/routes/cases/search/CaseAssigneeFilter.d.ts +6 -0
- package/components/routes/cases/search/CaseAssigneeFilter.js +33 -0
- package/components/routes/cases/search/CaseAssigneeFilter.test.d.ts +1 -0
- package/components/routes/cases/search/CaseAssigneeFilter.test.js +127 -0
- package/components/routes/cases/search/CaseDateFilter.d.ts +13 -0
- package/components/routes/cases/search/CaseDateFilter.js +26 -0
- package/components/routes/cases/search/CaseDateFilter.test.d.ts +1 -0
- package/components/routes/cases/search/CaseDateFilter.test.js +115 -0
- package/components/routes/cases/search/CaseStatusFilter.d.ts +6 -0
- package/components/routes/cases/search/CaseStatusFilter.js +13 -0
- package/components/routes/cases/search/CaseStatusFilter.test.d.ts +1 -0
- package/components/routes/cases/search/CaseStatusFilter.test.js +86 -0
- package/components/routes/cases/utils.d.ts +3 -0
- package/components/routes/cases/utils.js +21 -0
- package/components/routes/dossiers/DossierEditor.js +4 -4
- package/components/routes/dossiers/DossierEditor.test.js +2 -2
- package/components/routes/dossiers/Dossiers.js +16 -14
- package/components/routes/dossiers/PivotForm.js +2 -4
- package/components/routes/events/EventViewer.d.ts +7 -0
- package/components/routes/events/EventViewer.js +24 -0
- package/components/routes/help/ApiDocumentation.js +2 -2
- package/components/routes/help/HitBannerDocumentation.js +2 -1
- package/components/routes/help/HitDocumentation.js +1 -3
- package/components/routes/help/HitSchemaDocumentation.js +1 -1
- package/components/routes/help/OverviewDocumentation.d.ts +1 -1
- package/components/routes/help/OverviewDocumentation.js +0 -1
- package/components/routes/help/RetentionDocumentation.js +2 -2
- package/components/routes/help/SearchDocumentation.js +1 -1
- package/components/routes/help/markdown/en/client.md.js +1 -1
- package/components/routes/help/markdown/fr/client.md.js +1 -1
- package/components/routes/hits/search/InformationPane.d.ts +1 -0
- package/components/routes/hits/search/InformationPane.js +52 -65
- package/components/routes/hits/search/QuerySettings.js +2 -1
- package/components/routes/hits/search/QuerySettings.test.js +19 -17
- package/components/routes/hits/search/{HitBrowser.js → RecordBrowser.js} +13 -12
- package/components/routes/hits/search/{HitQuery.d.ts → RecordQuery.d.ts} +2 -2
- package/components/routes/hits/search/{HitQuery.js → RecordQuery.js} +6 -6
- package/components/routes/hits/search/SearchPane.js +28 -50
- package/components/routes/hits/search/ViewLink.js +7 -6
- package/components/routes/hits/search/ViewLink.test.js +8 -9
- package/components/routes/hits/search/grid/RecordGrid.d.ts +3 -0
- package/components/routes/hits/search/grid/RecordGrid.js +64 -0
- package/components/routes/hits/search/shared/CustomSort.js +1 -1
- package/components/routes/hits/search/shared/CustomSpan.test.js +3 -4
- package/components/routes/hits/search/shared/HitFilter.d.ts +1 -1
- package/components/routes/hits/search/shared/HitSort.d.ts +1 -1
- package/components/routes/hits/search/shared/HitSort.js +2 -1
- package/components/routes/hits/search/shared/IndexPicker.d.ts +8 -0
- package/components/routes/hits/search/shared/IndexPicker.js +21 -0
- package/components/routes/hits/search/shared/LayoutSettings.js +25 -0
- package/components/routes/hits/search/shared/SearchActionMenu.d.ts +4 -0
- package/components/routes/hits/search/shared/SearchActionMenu.js +11 -0
- package/components/routes/hits/search/shared/SearchSpan.d.ts +1 -1
- package/components/routes/hits/search/shared/SearchSpan.js +1 -1
- package/components/routes/hits/view/HitViewer.js +16 -17
- package/components/routes/home/AddNewCard.js +2 -2
- package/components/routes/home/AddNewCard.test.js +20 -2
- package/components/routes/home/AnalyticCard.js +1 -1
- package/components/routes/home/EntryWrapper.js +1 -1
- package/components/routes/home/HomeSettings.js +1 -1
- package/components/routes/home/HomeSettings.test.d.ts +1 -0
- package/components/routes/home/HomeSettings.test.js +44 -0
- package/components/routes/home/ViewCard.js +52 -46
- package/components/routes/home/ViewRefresh.test.js +1 -1
- package/components/routes/home/index.js +2 -2
- package/components/routes/overviews/OverviewCard.js +1 -1
- package/components/routes/overviews/OverviewViewer.js +13 -10
- package/components/routes/overviews/Overviews.js +16 -14
- package/components/routes/overviews/markdownExtendedTokenProvider.js +15 -15
- package/components/routes/overviews/markdownExtendedTokenProvider.test.d.ts +1 -0
- package/components/routes/overviews/markdownExtendedTokenProvider.test.js +50 -0
- package/components/routes/settings/ProfileSection.js +2 -2
- package/components/routes/templates/TemplateEditor.d.ts +3 -2
- package/components/routes/templates/TemplateEditor.js +1 -1
- package/components/routes/templates/TemplateViewer.js +10 -5
- package/components/routes/templates/Templates.js +19 -14
- package/components/routes/views/ViewComposer.js +78 -26
- package/components/routes/views/Views.js +17 -14
- package/i18n.js +1 -1
- package/index.css +4 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/locales/en/translation.json +188 -34
- package/locales/fr/translation.json +186 -32
- package/models/WithMetadata.d.ts +2 -1
- package/models/entities/generated/Analytic.d.ts +0 -3
- package/models/entities/generated/ApiType.d.ts +3 -1
- package/models/entities/generated/AttachmentsFile.d.ts +12 -0
- package/models/entities/generated/Case.d.ts +29 -0
- package/models/entities/generated/Column.d.ts +7 -0
- package/models/entities/generated/DestinationOriginal.d.ts +19 -0
- package/models/entities/generated/ECSEvent.d.ts +31 -0
- package/models/entities/generated/EmailAttachment.d.ts +8 -0
- package/models/entities/generated/EmailParent.d.ts +19 -0
- package/models/entities/generated/Enrichments.d.ts +7 -0
- package/models/entities/generated/EnrichmentsIndicator.d.ts +21 -0
- package/models/entities/generated/Event.d.ts +80 -26
- package/models/entities/generated/EventCloud.d.ts +20 -0
- package/models/entities/generated/EventDestination.d.ts +23 -0
- package/models/entities/generated/EventEmail.d.ts +30 -0
- package/models/entities/generated/EventFile.d.ts +36 -0
- package/models/entities/generated/EventHowler.d.ts +42 -0
- package/models/entities/generated/EventHttp.d.ts +11 -0
- package/models/entities/generated/EventObserver.d.ts +21 -0
- package/models/entities/generated/EventOrganization.d.ts +7 -0
- package/models/entities/generated/EventProcess.d.ts +34 -0
- package/models/entities/generated/EventSource.d.ts +23 -0
- package/models/entities/generated/EventThreat.d.ts +21 -0
- package/models/entities/generated/EventTls.d.ts +12 -0
- package/models/entities/generated/Hit.d.ts +3 -2
- package/models/entities/generated/Host.d.ts +1 -0
- package/models/entities/generated/Howler.d.ts +1 -6
- package/models/entities/generated/HttpResponse.d.ts +11 -0
- package/models/entities/generated/Item.d.ts +12 -0
- package/models/entities/generated/ObserverIngress.d.ts +9 -0
- package/models/entities/generated/Rule.d.ts +8 -9
- package/models/entities/generated/Settings.d.ts +4 -0
- package/models/entities/generated/Task.d.ts +10 -0
- package/models/entities/generated/Threat.d.ts +2 -2
- package/models/entities/generated/{Enrichment.d.ts → ThreatEnrichment.d.ts} +1 -1
- package/models/entities/generated/View.d.ts +1 -0
- package/models/socket/CaseUpdate.d.ts +5 -0
- package/models/socket/ViewersUpdate.d.ts +4 -0
- package/package.json +156 -137
- package/plugins/clue/components/ClueLeadForm.js +1 -1
- package/plugins/clue/components/CluePivotForm.js +2 -2
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/helpers.js +4 -4
- package/plugins/clue/index.d.ts +3 -2
- package/plugins/clue/index.js +0 -1
- package/plugins/clue/utils.d.ts +2 -1
- package/rest/AxiosClient.test.d.ts +1 -0
- package/rest/AxiosClient.test.js +185 -0
- package/tests/mocks.d.ts +11 -1
- package/tests/mocks.js +12 -7
- package/tests/server-handlers.js +11 -1
- package/tests/utils.d.ts +4 -0
- package/tests/utils.js +21 -0
- package/utils/Throttler.test.js +2 -2
- package/utils/actionUtils.d.ts +3 -3
- package/utils/classificationParser.d.ts +195 -0
- package/utils/classificationParser.js +680 -0
- package/utils/constants.d.ts +4 -3
- package/utils/constants.js +6 -0
- package/utils/localStorage.js +1 -1
- package/utils/menuUtils.js +0 -4
- package/utils/recordFunctions.d.ts +3 -0
- package/utils/recordFunctions.js +8 -0
- package/utils/recordFunctions.test.d.ts +1 -0
- package/utils/{hitFunctions.test.js → recordFunctions.test.js} +1 -1
- package/utils/socketUtils.d.ts +14 -0
- package/utils/socketUtils.js +17 -1
- package/utils/socketUtils.test.js +49 -16
- package/utils/stringUtils.d.ts +1 -0
- package/utils/stringUtils.js +7 -0
- package/utils/stringUtils.test.js +22 -2
- package/utils/typeUtils.d.ts +7 -0
- package/utils/typeUtils.js +27 -0
- package/utils/utils.d.ts +1 -1
- package/utils/utils.js +2 -2
- package/utils/utils.test.js +119 -2
- package/utils/viewUtils.js +3 -0
- package/utils/xsrf.js +1 -1
- package/api/analytic/rules.d.ts +0 -3
- package/api/analytic/rules.js +0 -8
- package/components/app/providers/HitProvider.d.ts +0 -22
- package/components/elements/display/icons/BundleButton.d.ts +0 -6
- package/components/elements/display/icons/BundleButton.js +0 -32
- package/components/elements/hit/HitRelated.d.ts +0 -6
- package/components/elements/hit/HitRelated.js +0 -7
- package/components/elements/hit/elements/HitUsers.js +0 -33
- package/components/routes/advanced/RuleModal.d.ts +0 -7
- package/components/routes/advanced/RuleModal.js +0 -83
- package/components/routes/analytics/RuleView.d.ts +0 -8
- package/components/routes/analytics/RuleView.js +0 -48
- package/components/routes/help/BundleDocumentation.d.ts +0 -3
- package/components/routes/help/BundleDocumentation.js +0 -12
- package/components/routes/help/markdown/en/bundles.md.js +0 -1
- package/components/routes/help/markdown/fr/bundles.md.js +0 -1
- package/components/routes/hits/search/BundleParentMenu.d.ts +0 -6
- package/components/routes/hits/search/BundleParentMenu.js +0 -32
- package/components/routes/hits/search/BundleScroller.d.ts +0 -2
- package/components/routes/hits/search/BundleScroller.js +0 -6
- package/components/routes/hits/search/HitContextMenu.js +0 -239
- package/components/routes/hits/search/LayoutSettings.js +0 -24
- package/components/routes/hits/search/grid/HitGrid.d.ts +0 -3
- package/components/routes/hits/search/grid/HitGrid.js +0 -132
- package/utils/hitFunctions.d.ts +0 -2
- package/utils/hitFunctions.js +0 -8
- /package/{components/app/providers/HitSearchProvider.test.d.ts → api/socket/viewers.test.d.ts} +0 -0
- /package/components/{routes/hits/search/HitContextMenu.test.d.ts → app/providers/GridColumnsProvider.test.d.ts} +0 -0
- /package/{utils/hitFunctions.test.d.ts → components/app/providers/RecordSearchProvider.test.d.ts} +0 -0
- /package/components/{routes/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.d.ts} +0 -0
- /package/components/{routes/hits/search → elements/hit}/grid/AddColumnModal.d.ts +0 -0
- /package/components/elements/hit/{HitDetails.d.ts → related/RelatedRecords.d.ts} +0 -0
- /package/components/routes/hits/search/{HitBrowser.d.ts → RecordBrowser.d.ts} +0 -0
- /package/components/routes/hits/search/{LayoutSettings.d.ts → shared/LayoutSettings.d.ts} +0 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import { setupReactRouterMock } from '@cccsaurora/howler-ui/tests/mocks';
|
|
5
|
+
import { createMockCase } from '@cccsaurora/howler-ui/tests/utils';
|
|
6
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
7
|
+
const mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
8
|
+
const mockApiGet = vi.hoisted(() => vi.fn());
|
|
9
|
+
vi.mock('components/hooks/useMyApi', () => ({
|
|
10
|
+
default: () => ({ dispatchApi: mockDispatchApi })
|
|
11
|
+
}));
|
|
12
|
+
vi.mock('api', () => ({
|
|
13
|
+
default: {
|
|
14
|
+
v2: {
|
|
15
|
+
case: {
|
|
16
|
+
get: mockApiGet
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
vi.mock('components/routes/404', () => ({
|
|
22
|
+
default: () => _jsx("div", { id: "not-found", children: "Not Found" })
|
|
23
|
+
}));
|
|
24
|
+
vi.mock('components/routes/hits/search/InformationPane', () => ({
|
|
25
|
+
default: ({ selected }) => _jsx("div", { id: "information-pane", children: selected })
|
|
26
|
+
}));
|
|
27
|
+
vi.mock('./CaseDashboard', () => ({
|
|
28
|
+
default: ({ caseId }) => _jsx("div", { id: "case-dashboard", children: caseId })
|
|
29
|
+
}));
|
|
30
|
+
vi.mock('./MarkdownPage', () => ({
|
|
31
|
+
default: ({ item }) => _jsx("div", { id: "markdown-page", children: item?.value })
|
|
32
|
+
}));
|
|
33
|
+
vi.mock('../hooks/useCase', () => ({
|
|
34
|
+
default: () => ({ case: undefined, loading: false, missing: false })
|
|
35
|
+
}));
|
|
36
|
+
const { mockParams } = setupReactRouterMock();
|
|
37
|
+
const { default: ItemPage } = await import('./ItemPage');
|
|
38
|
+
describe('ItemPage', () => {
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
vi.clearAllMocks();
|
|
41
|
+
// Default to no wildcard path unless a test sets it
|
|
42
|
+
mockParams['*'] = '';
|
|
43
|
+
});
|
|
44
|
+
it('renders NotFoundPage when no subPath is provided', async () => {
|
|
45
|
+
const _case = createMockCase({ case_id: 'case-1', items: [] });
|
|
46
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
47
|
+
await waitFor(() => {
|
|
48
|
+
expect(screen.getByTestId('not-found')).toBeInTheDocument();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
it('renders MarkdownPage when a markdown item path is resolved', async () => {
|
|
52
|
+
const markdownItem = {
|
|
53
|
+
id: 'item-1',
|
|
54
|
+
parent: null,
|
|
55
|
+
type: 'markdown',
|
|
56
|
+
name: 'Notes',
|
|
57
|
+
value: 'Initial markdown',
|
|
58
|
+
classification: 'TLP:CLEAR'
|
|
59
|
+
};
|
|
60
|
+
const _case = createMockCase({ case_id: 'case-1', items: [markdownItem] });
|
|
61
|
+
mockParams['*'] = 'Notes';
|
|
62
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
63
|
+
await waitFor(() => {
|
|
64
|
+
expect(screen.getByTestId('markdown-page')).toHaveTextContent('Initial markdown');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
it('normalizes leading/trailing slashes in subPath', async () => {
|
|
68
|
+
const markdownItem = {
|
|
69
|
+
id: 'item-1',
|
|
70
|
+
parent: null,
|
|
71
|
+
type: 'markdown',
|
|
72
|
+
name: 'Notes',
|
|
73
|
+
value: 'Normalized markdown',
|
|
74
|
+
classification: 'TLP:CLEAR'
|
|
75
|
+
};
|
|
76
|
+
const _case = createMockCase({ case_id: 'case-1', items: [markdownItem] });
|
|
77
|
+
mockParams['*'] = '/Notes/';
|
|
78
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
79
|
+
await waitFor(() => {
|
|
80
|
+
expect(screen.getByTestId('markdown-page')).toHaveTextContent('Normalized markdown');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
it('renders InformationPane for hit item paths', async () => {
|
|
84
|
+
const hitItem = {
|
|
85
|
+
id: 'hit-1',
|
|
86
|
+
parent: null,
|
|
87
|
+
type: 'hit',
|
|
88
|
+
name: 'Alert',
|
|
89
|
+
value: 'selected-hit-id'
|
|
90
|
+
};
|
|
91
|
+
const _case = createMockCase({ case_id: 'case-1', items: [hitItem] });
|
|
92
|
+
mockParams['*'] = 'Alert';
|
|
93
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
94
|
+
await waitFor(() => {
|
|
95
|
+
expect(screen.getByTestId('information-pane')).toHaveTextContent('selected-hit-id');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
it('resolves nested case segments and renders downstream item', async () => {
|
|
99
|
+
const nestedMarkdown = {
|
|
100
|
+
id: 'n-md-1',
|
|
101
|
+
parent: null,
|
|
102
|
+
type: 'markdown',
|
|
103
|
+
name: 'NestedNotes',
|
|
104
|
+
value: 'Nested markdown content'
|
|
105
|
+
};
|
|
106
|
+
const childCase = createMockCase({ case_id: 'child-case-123', items: [nestedMarkdown] });
|
|
107
|
+
const caseLink = {
|
|
108
|
+
id: 'case-link-1',
|
|
109
|
+
parent: null,
|
|
110
|
+
type: 'case',
|
|
111
|
+
name: 'Child',
|
|
112
|
+
value: 'child-case-123'
|
|
113
|
+
};
|
|
114
|
+
const _case = createMockCase({ case_id: 'root-case', items: [caseLink] });
|
|
115
|
+
mockDispatchApi.mockResolvedValueOnce(childCase);
|
|
116
|
+
mockParams['*'] = 'Child/NestedNotes';
|
|
117
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
expect(mockDispatchApi).toHaveBeenCalledOnce();
|
|
120
|
+
expect(screen.getByTestId('markdown-page')).toHaveTextContent('Nested markdown content');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
it('returns NotFound when nested case has no value', async () => {
|
|
124
|
+
const caseLink = {
|
|
125
|
+
id: 'case-link-1',
|
|
126
|
+
parent: null,
|
|
127
|
+
type: 'case',
|
|
128
|
+
name: 'Child',
|
|
129
|
+
value: undefined
|
|
130
|
+
};
|
|
131
|
+
const _case = createMockCase({ case_id: 'root-case', items: [caseLink] });
|
|
132
|
+
mockParams['*'] = 'Child/Anything';
|
|
133
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
134
|
+
await waitFor(() => {
|
|
135
|
+
expect(screen.getByTestId('not-found')).toBeInTheDocument();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
it('returns NotFound when nested case cannot be fetched', async () => {
|
|
139
|
+
const caseLink = {
|
|
140
|
+
id: 'case-link-1',
|
|
141
|
+
parent: null,
|
|
142
|
+
type: 'case',
|
|
143
|
+
name: 'Child',
|
|
144
|
+
value: 'child-case-123'
|
|
145
|
+
};
|
|
146
|
+
const _case = createMockCase({ case_id: 'root-case', items: [caseLink] });
|
|
147
|
+
mockDispatchApi.mockResolvedValueOnce(null);
|
|
148
|
+
mockParams['*'] = 'Child/NestedNotes';
|
|
149
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
150
|
+
await waitFor(() => {
|
|
151
|
+
expect(mockDispatchApi).toHaveBeenCalledOnce();
|
|
152
|
+
expect(screen.getByTestId('not-found')).toBeInTheDocument();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
it('renders CaseDashboard when path equals nested case id', async () => {
|
|
156
|
+
const caseLink = {
|
|
157
|
+
id: 'Child/NestedCase',
|
|
158
|
+
parent: null,
|
|
159
|
+
type: 'case',
|
|
160
|
+
name: 'Child',
|
|
161
|
+
value: 'child-case-123'
|
|
162
|
+
};
|
|
163
|
+
const _case = createMockCase({ case_id: 'root-case', items: [caseLink] });
|
|
164
|
+
mockParams['*'] = 'Child/NestedCase';
|
|
165
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
166
|
+
await waitFor(() => {
|
|
167
|
+
expect(mockDispatchApi).not.toHaveBeenCalled();
|
|
168
|
+
expect(screen.getByTestId('case-dashboard')).toHaveTextContent('child-case-123');
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
it('resolves hierarchical non-case parent via buildPathFromID', async () => {
|
|
172
|
+
const folder = {
|
|
173
|
+
id: 'folder-1',
|
|
174
|
+
parent: null,
|
|
175
|
+
type: 'markdown',
|
|
176
|
+
name: 'Folder'
|
|
177
|
+
};
|
|
178
|
+
const doc = {
|
|
179
|
+
id: 'doc-1',
|
|
180
|
+
parent: 'folder-1',
|
|
181
|
+
type: 'markdown',
|
|
182
|
+
name: 'Doc',
|
|
183
|
+
value: 'Child content'
|
|
184
|
+
};
|
|
185
|
+
const _case = createMockCase({ case_id: 'case-1', items: [folder, doc] });
|
|
186
|
+
mockParams['*'] = 'Folder/Doc';
|
|
187
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
188
|
+
await waitFor(() => {
|
|
189
|
+
expect(screen.getByTestId('markdown-page')).toHaveTextContent('Child content');
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
it('renders InformationPane for event item paths', async () => {
|
|
193
|
+
const eventItem = {
|
|
194
|
+
id: 'event-1',
|
|
195
|
+
parent: null,
|
|
196
|
+
type: 'event',
|
|
197
|
+
name: 'Incident',
|
|
198
|
+
value: 'selected-event-id'
|
|
199
|
+
};
|
|
200
|
+
const _case = createMockCase({ case_id: 'case-1', items: [eventItem] });
|
|
201
|
+
mockParams['*'] = 'Incident';
|
|
202
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
203
|
+
await waitFor(() => {
|
|
204
|
+
expect(screen.getByTestId('information-pane')).toHaveTextContent('selected-event-id');
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
it('falls back to JSON render for unknown item types', async () => {
|
|
208
|
+
const otherItem = {
|
|
209
|
+
id: 'other-1',
|
|
210
|
+
parent: null,
|
|
211
|
+
type: 'other',
|
|
212
|
+
name: 'Other',
|
|
213
|
+
value: 'misc'
|
|
214
|
+
};
|
|
215
|
+
const _case = createMockCase({ case_id: 'case-1', items: [otherItem] });
|
|
216
|
+
mockParams['*'] = 'Other';
|
|
217
|
+
const { container } = render(_jsx(ItemPage, { case: _case }));
|
|
218
|
+
await waitFor(() => {
|
|
219
|
+
expect(container.querySelector('h1')).toBeTruthy();
|
|
220
|
+
expect(container.querySelector('h1')?.textContent).toContain('other-1');
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
it('renders NotFoundPage when no item matches the given path', async () => {
|
|
224
|
+
const otherItem = {
|
|
225
|
+
id: 'item-2',
|
|
226
|
+
parent: null,
|
|
227
|
+
type: 'markdown',
|
|
228
|
+
name: 'Other',
|
|
229
|
+
value: 'Other content'
|
|
230
|
+
};
|
|
231
|
+
const _case = createMockCase({ case_id: 'case-1', items: [otherItem] });
|
|
232
|
+
mockParams['*'] = 'UnknownPath';
|
|
233
|
+
render(_jsx(ItemPage, { case: _case }));
|
|
234
|
+
await waitFor(() => {
|
|
235
|
+
expect(screen.getByTestId('not-found')).toBeInTheDocument();
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Case } from '@cccsaurora/howler-ui/models/entities/generated/Case';
|
|
2
|
+
import type { Item } from '@cccsaurora/howler-ui/models/entities/generated/Item';
|
|
3
|
+
import { type FC } from 'react';
|
|
4
|
+
declare const MarkdownPage: FC<{
|
|
5
|
+
case: Case;
|
|
6
|
+
item: Item;
|
|
7
|
+
}>;
|
|
8
|
+
export default MarkdownPage;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Cancel, Edit, Save } from '@mui/icons-material';
|
|
3
|
+
import { Box, Divider, IconButton, Stack, Tooltip, Typography } from '@mui/material';
|
|
4
|
+
import ThemedEditor from '@cccsaurora/howler-ui/components/elements/ThemedEditor';
|
|
5
|
+
import ClassificationChip from '@cccsaurora/howler-ui/components/elements/display/ClassificationChip';
|
|
6
|
+
import Markdown from '@cccsaurora/howler-ui/components/elements/display/Markdown';
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { useTranslation } from 'react-i18next';
|
|
9
|
+
import useCase from '../hooks/useCase';
|
|
10
|
+
import { buildPathFromID } from '../utils';
|
|
11
|
+
const MarkdownPage = ({ case: _case, item }) => {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const [isEditing, setIsEditing] = useState(false);
|
|
14
|
+
const [markdown, setMarkdown] = useState(item.value ?? '');
|
|
15
|
+
const [saving, setSaving] = useState(false);
|
|
16
|
+
const { update } = useCase({ case: _case });
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setMarkdown(item.value ?? '');
|
|
19
|
+
setIsEditing(false);
|
|
20
|
+
}, [item.id, item.value]);
|
|
21
|
+
const path = useMemo(() => buildPathFromID(_case, item.parent), [_case, item.parent]);
|
|
22
|
+
const handleCancel = useCallback(() => {
|
|
23
|
+
setMarkdown(item.value ?? '');
|
|
24
|
+
setIsEditing(false);
|
|
25
|
+
}, [item.value]);
|
|
26
|
+
const handleSave = useCallback(async () => {
|
|
27
|
+
if (!_case.case_id || !item.id) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const nextItems = (_case.items ?? []).map(_item => {
|
|
31
|
+
if (_item.id === item.id) {
|
|
32
|
+
return {
|
|
33
|
+
..._item,
|
|
34
|
+
value: markdown
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return _item;
|
|
38
|
+
});
|
|
39
|
+
try {
|
|
40
|
+
setSaving(true);
|
|
41
|
+
await update({ items: nextItems });
|
|
42
|
+
setIsEditing(false);
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
setSaving(false);
|
|
46
|
+
}
|
|
47
|
+
}, [_case.case_id, _case.items, item.id, markdown, update]);
|
|
48
|
+
return (_jsxs(Box, { p: 1, sx: { mt: -1, minHeight: 'calc(100vh - 64px)', display: 'flex', flexDirection: 'column' }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [_jsxs(Stack, { direction: "row", children: [_jsxs(Typography, { variant: "h6", color: "text.secondary", children: [path, "/"] }), _jsx(Typography, { variant: "h6", children: item.name })] }), item.classification && _jsx(ClassificationChip, { classification: item.classification, format: "long" }), _jsx("div", { style: { flex: 1 } }), isEditing && (_jsx(Tooltip, { title: t('button.save'), children: _jsx(IconButton, { size: "small", color: "success", onClick: handleSave, disabled: saving, children: _jsx(Save, { fontSize: "small" }) }) })), _jsx(Tooltip, { title: isEditing ? t('button.cancel') : t('edit'), children: _jsx(IconButton, { size: "small", color: isEditing ? 'error' : 'default', onClick: isEditing ? handleCancel : () => setIsEditing(true), disabled: saving, children: isEditing ? _jsx(Cancel, { fontSize: "small" }) : _jsx(Edit, { fontSize: "small" }) }) })] }), _jsx(Divider, {}), isEditing ? (_jsxs(Stack, { direction: { xs: 'column', md: 'row' }, spacing: 1, sx: { mt: 1, flex: 1, minHeight: 0 }, children: [_jsx(Box, { sx: {
|
|
49
|
+
flex: 1,
|
|
50
|
+
minHeight: 0,
|
|
51
|
+
border: theme => `1px solid ${theme.palette.divider}`,
|
|
52
|
+
borderRadius: 1,
|
|
53
|
+
overflow: 'hidden'
|
|
54
|
+
}, children: _jsx(ThemedEditor, { id: "markdown-editor", language: "markdown", value: markdown, onChange: value => setMarkdown(value ?? ''), options: { wordWrap: 'on', scrollBeyondLastLine: false }, height: "100%" }) }), _jsx(Box, { sx: {
|
|
55
|
+
flex: 1,
|
|
56
|
+
minHeight: 0,
|
|
57
|
+
border: theme => `1px solid ${theme.palette.divider}`,
|
|
58
|
+
borderRadius: 1,
|
|
59
|
+
p: 1,
|
|
60
|
+
overflow: 'auto'
|
|
61
|
+
}, children: _jsx(Markdown, { md: markdown }) })] })) : (_jsx(Markdown, { md: markdown }))] }));
|
|
62
|
+
};
|
|
63
|
+
export default MarkdownPage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import userEvent, {} from '@testing-library/user-event';
|
|
5
|
+
import { createMockCase } from '@cccsaurora/howler-ui/tests/utils';
|
|
6
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
7
|
+
const mockUpdate = vi.hoisted(() => vi.fn().mockResolvedValue(undefined));
|
|
8
|
+
vi.mock('../hooks/useCase', () => ({
|
|
9
|
+
default: ({ case: c }) => ({
|
|
10
|
+
case: c,
|
|
11
|
+
update: mockUpdate,
|
|
12
|
+
loading: false,
|
|
13
|
+
missing: false
|
|
14
|
+
})
|
|
15
|
+
}));
|
|
16
|
+
vi.mock('components/elements/display/ClassificationChip', () => ({
|
|
17
|
+
default: () => _jsx("span", { id: "classification-chip" })
|
|
18
|
+
}));
|
|
19
|
+
vi.mock('components/elements/display/Markdown', () => ({
|
|
20
|
+
default: ({ md }) => _jsx("div", { id: "markdown-preview", children: md })
|
|
21
|
+
}));
|
|
22
|
+
vi.mock('components/elements/ThemedEditor', () => ({
|
|
23
|
+
default: ({ id, value, onChange }) => (_jsx("textarea", { id: id ?? 'themed-editor', value: value ?? '', onChange: ev => onChange?.(ev.target.value) }))
|
|
24
|
+
}));
|
|
25
|
+
const { default: MarkdownPage } = await import('./MarkdownPage');
|
|
26
|
+
describe('MarkdownPage', () => {
|
|
27
|
+
let user;
|
|
28
|
+
let markdownItem;
|
|
29
|
+
let _case;
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
user = userEvent.setup();
|
|
32
|
+
vi.clearAllMocks();
|
|
33
|
+
markdownItem = {
|
|
34
|
+
id: 'item-1',
|
|
35
|
+
parent: null,
|
|
36
|
+
type: 'markdown',
|
|
37
|
+
name: 'Analyst Notes',
|
|
38
|
+
value: 'Initial markdown value',
|
|
39
|
+
classification: 'TLP:CLEAR'
|
|
40
|
+
};
|
|
41
|
+
_case = createMockCase({
|
|
42
|
+
case_id: 'case-1',
|
|
43
|
+
items: [
|
|
44
|
+
markdownItem,
|
|
45
|
+
{
|
|
46
|
+
id: 'item-2',
|
|
47
|
+
parent: null,
|
|
48
|
+
type: 'markdown',
|
|
49
|
+
name: 'Other Item',
|
|
50
|
+
value: 'Keep this value'
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
it('renders read mode by default', () => {
|
|
56
|
+
render(_jsx(MarkdownPage, { case: _case, item: markdownItem }));
|
|
57
|
+
expect(screen.getByText('Initial markdown value')).toBeInTheDocument();
|
|
58
|
+
expect(screen.queryByRole('textbox')).toBeNull();
|
|
59
|
+
expect(screen.getByRole('button', { name: 'edit' })).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
it('enters edit mode and updates preview as content changes', async () => {
|
|
62
|
+
render(_jsx(MarkdownPage, { case: _case, item: markdownItem }));
|
|
63
|
+
await user.click(screen.getByRole('button', { name: 'edit' }));
|
|
64
|
+
const editor = screen.getByRole('textbox');
|
|
65
|
+
expect(editor).toHaveValue('Initial markdown value');
|
|
66
|
+
await user.clear(editor);
|
|
67
|
+
await user.type(editor, 'Updated markdown preview');
|
|
68
|
+
expect(screen.getByTestId('markdown-preview')).toHaveTextContent('Updated markdown preview');
|
|
69
|
+
});
|
|
70
|
+
it('cancels edits and restores the original item value', async () => {
|
|
71
|
+
render(_jsx(MarkdownPage, { case: _case, item: markdownItem }));
|
|
72
|
+
await user.click(screen.getByRole('button', { name: 'edit' }));
|
|
73
|
+
const editor = screen.getByRole('textbox');
|
|
74
|
+
await user.clear(editor);
|
|
75
|
+
await user.type(editor, 'Unsaved value');
|
|
76
|
+
await user.click(screen.getByRole('button', { name: 'button.cancel' }));
|
|
77
|
+
expect(screen.queryByRole('textbox')).toBeNull();
|
|
78
|
+
expect(screen.getByText('Initial markdown value')).toBeInTheDocument();
|
|
79
|
+
await user.click(screen.getByRole('button', { name: 'edit' }));
|
|
80
|
+
expect(screen.getByRole('textbox')).toHaveValue('Initial markdown value');
|
|
81
|
+
});
|
|
82
|
+
it('saves edits through update and exits edit mode', async () => {
|
|
83
|
+
render(_jsx(MarkdownPage, { case: _case, item: markdownItem }));
|
|
84
|
+
await user.click(screen.getByRole('button', { name: 'edit' }));
|
|
85
|
+
const editor = screen.getByRole('textbox');
|
|
86
|
+
await user.clear(editor);
|
|
87
|
+
await user.type(editor, 'Persisted value');
|
|
88
|
+
await user.click(screen.getByRole('button', { name: 'button.save' }));
|
|
89
|
+
await waitFor(() => {
|
|
90
|
+
expect(mockUpdate).toHaveBeenCalledOnce();
|
|
91
|
+
});
|
|
92
|
+
expect(mockUpdate).toHaveBeenCalledWith({
|
|
93
|
+
items: [
|
|
94
|
+
{
|
|
95
|
+
id: 'item-1',
|
|
96
|
+
parent: null,
|
|
97
|
+
type: 'markdown',
|
|
98
|
+
name: 'Analyst Notes',
|
|
99
|
+
value: 'Persisted value',
|
|
100
|
+
classification: 'TLP:CLEAR'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: 'item-2',
|
|
104
|
+
parent: null,
|
|
105
|
+
type: 'markdown',
|
|
106
|
+
name: 'Other Item',
|
|
107
|
+
value: 'Keep this value'
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
});
|
|
111
|
+
await waitFor(() => {
|
|
112
|
+
expect(screen.queryByRole('textbox')).toBeNull();
|
|
113
|
+
});
|
|
114
|
+
expect(screen.getByText('Persisted value')).toBeInTheDocument();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Divider, Pagination, Skeleton, Stack, Typography, useTheme } from '@mui/material';
|
|
3
|
+
import { chunk, uniq } from 'lodash-es';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { Link } from 'react-router-dom';
|
|
7
|
+
import CaseCard from '../../../elements/case/CaseCard';
|
|
8
|
+
const RelatedCasePanel = ({ case: _case }) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const [casePage, setCasePage] = useState(1);
|
|
12
|
+
const casePages = useMemo(() => chunk(uniq((_case?.items ?? []).filter(item => item.type === 'case')), 5), [_case?.items]);
|
|
13
|
+
if (!_case) {
|
|
14
|
+
return _jsx(Skeleton, { height: 240 });
|
|
15
|
+
}
|
|
16
|
+
if (casePages.length < 1) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return (_jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", children: [_jsx(Typography, { flex: 1, variant: "h4", children: t('page.cases.dashboard.cases') }), _jsx(Pagination, { count: casePages.length, page: casePage, onChange: (_, page) => setCasePage(page) })] }), _jsx(Divider, {}), casePages[casePage - 1]?.map(item => (_jsxs(Box, { position: "relative", children: [_jsx(CaseCard, { caseId: item.value }), _jsx(Box, { component: Link, to: `/cases/${item.value}`, sx: {
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
top: 0,
|
|
22
|
+
left: 0,
|
|
23
|
+
width: '100%',
|
|
24
|
+
height: '100%',
|
|
25
|
+
cursor: 'pointer',
|
|
26
|
+
zIndex: 100,
|
|
27
|
+
borderRadius: '4px',
|
|
28
|
+
'&:hover': {
|
|
29
|
+
background: theme.palette.divider,
|
|
30
|
+
border: `thin solid ${theme.palette.primary.light}`
|
|
31
|
+
}
|
|
32
|
+
} })] }, item.id ?? item.value)))] }));
|
|
33
|
+
};
|
|
34
|
+
export default RelatedCasePanel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import { createMockCase } from '@cccsaurora/howler-ui/tests/utils';
|
|
5
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Hoisted mocks
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
const mockCaseCardProps = vi.hoisted(() => ({ current: [] }));
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Module mocks
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
vi.mock('react-i18next', () => ({
|
|
14
|
+
useTranslation: () => ({
|
|
15
|
+
t: (key) => key
|
|
16
|
+
})
|
|
17
|
+
}));
|
|
18
|
+
vi.mock('react-router-dom', async () => {
|
|
19
|
+
const actual = await vi.importActual('react-router-dom');
|
|
20
|
+
return {
|
|
21
|
+
...actual,
|
|
22
|
+
Link: ({ to, children, ...props }) => (_jsx("a", { href: to, ...props, children: children }))
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
vi.mock('../../../elements/case/CaseCard', () => ({
|
|
26
|
+
default: (props) => {
|
|
27
|
+
mockCaseCardProps.current.push(props);
|
|
28
|
+
return _jsx("div", { id: `case-card-${String(props.caseId)}` });
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Imports after mocks
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
import RelatedCasePanel from './RelatedCasePanel';
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Helpers
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
const renderPanel = (caseValue) => {
|
|
39
|
+
return render(_jsx(MemoryRouter, { children: _jsx(RelatedCasePanel, { case: caseValue }) }));
|
|
40
|
+
};
|
|
41
|
+
const makeCaseItem = (value, id = value) => ({
|
|
42
|
+
type: 'case',
|
|
43
|
+
value,
|
|
44
|
+
id,
|
|
45
|
+
name: null,
|
|
46
|
+
parent: null
|
|
47
|
+
});
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Setup
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
mockCaseCardProps.current = [];
|
|
53
|
+
});
|
|
54
|
+
// ---------------------------------------------------------------------------
|
|
55
|
+
// Tests
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
describe('RelatedCasePanel', () => {
|
|
58
|
+
it('renders a skeleton when the case is null', () => {
|
|
59
|
+
const { container } = renderPanel(null);
|
|
60
|
+
expect(container.querySelector('.MuiSkeleton-root')).toBeTruthy();
|
|
61
|
+
});
|
|
62
|
+
it('renders nothing when the case has no case-type items', () => {
|
|
63
|
+
const baseCase = createMockCase({ case_id: 'case-no-cases', items: [{ type: 'hit', value: 'hit-1' }] });
|
|
64
|
+
const { container } = renderPanel(baseCase);
|
|
65
|
+
expect(container).toBeEmptyDOMElement();
|
|
66
|
+
});
|
|
67
|
+
it('renders the translated heading key', () => {
|
|
68
|
+
const _case = createMockCase({ case_id: 'case-1', items: [makeCaseItem('child-1')] });
|
|
69
|
+
renderPanel(_case);
|
|
70
|
+
expect(screen.getByText('page.cases.dashboard.cases')).toBeInTheDocument();
|
|
71
|
+
});
|
|
72
|
+
it('renders CaseCard only for unique case items on the current page', () => {
|
|
73
|
+
const duplicate = makeCaseItem('child-1', '/cases/test/path-a');
|
|
74
|
+
const _case = createMockCase({
|
|
75
|
+
case_id: 'case-2',
|
|
76
|
+
items: [
|
|
77
|
+
duplicate,
|
|
78
|
+
duplicate,
|
|
79
|
+
makeCaseItem('child-2', '/cases/test/path-b'),
|
|
80
|
+
{ type: 'event', value: 'event-1' }
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
renderPanel(_case);
|
|
84
|
+
expect(screen.getByTestId('case-card-child-1')).toBeInTheDocument();
|
|
85
|
+
expect(screen.getByTestId('case-card-child-2')).toBeInTheDocument();
|
|
86
|
+
expect(screen.queryByTestId('case-card-event-1')).not.toBeInTheDocument();
|
|
87
|
+
expect(mockCaseCardProps.current).toHaveLength(2);
|
|
88
|
+
expect(mockCaseCardProps.current[0]).toEqual(expect.objectContaining({
|
|
89
|
+
caseId: 'child-1'
|
|
90
|
+
}));
|
|
91
|
+
});
|
|
92
|
+
it('renders overlay links that target each case path', () => {
|
|
93
|
+
const _case = createMockCase({
|
|
94
|
+
case_id: 'case-3',
|
|
95
|
+
items: [makeCaseItem('child-1', '/cases/case-3/path-one'), makeCaseItem('child-2', '/cases/case-3/path-two')]
|
|
96
|
+
});
|
|
97
|
+
const { container } = renderPanel(_case);
|
|
98
|
+
const links = Array.from(container.querySelectorAll('a'));
|
|
99
|
+
expect(links).toHaveLength(2);
|
|
100
|
+
expect(links[0]).toHaveAttribute('href', '/cases/child-1');
|
|
101
|
+
expect(links[1]).toHaveAttribute('href', '/cases/child-2');
|
|
102
|
+
});
|
|
103
|
+
it('shows pagination with multiple pages and switches to page 2 items', () => {
|
|
104
|
+
const items = Array.from({ length: 6 }, (_, idx) => makeCaseItem(`child-${idx + 1}`, `/cases/test/child-${idx + 1}`));
|
|
105
|
+
const _case = createMockCase({ case_id: 'case-4', items });
|
|
106
|
+
renderPanel(_case);
|
|
107
|
+
expect(screen.getByTestId('case-card-child-1')).toBeInTheDocument();
|
|
108
|
+
expect(screen.getByTestId('case-card-child-5')).toBeInTheDocument();
|
|
109
|
+
expect(screen.queryByTestId('case-card-child-6')).not.toBeInTheDocument();
|
|
110
|
+
const pageTwoButton = screen.getByRole('button', { name: 'Go to page 2' });
|
|
111
|
+
fireEvent.click(pageTwoButton);
|
|
112
|
+
expect(screen.getByTestId('case-card-child-6')).toBeInTheDocument();
|
|
113
|
+
expect(screen.queryByTestId('case-card-child-1')).not.toBeInTheDocument();
|
|
114
|
+
});
|
|
115
|
+
});
|