@cccsaurora/howler-ui 3.1.0-dev.1656 → 3.1.0-dev.1657
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 +1 -1
- 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
|
@@ -0,0 +1,112 @@
|
|
|
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 mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
6
|
+
let appUserValue = { user: { username: 'demo', roles: ['admin'] } };
|
|
7
|
+
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
8
|
+
const actual = await importOriginal();
|
|
9
|
+
return {
|
|
10
|
+
...actual,
|
|
11
|
+
Add: () => _jsx("div", { children: "add-icon" }),
|
|
12
|
+
Delete: () => _jsx("div", { children: "delete-icon" }),
|
|
13
|
+
Label: () => _jsx("div", { children: "label-icon" }),
|
|
14
|
+
LinkRounded: () => _jsx("div", { children: "link-icon" }),
|
|
15
|
+
Plagiarism: () => _jsx("div", { children: "plagiarism-icon" })
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
vi.mock('@mui/material', () => ({
|
|
19
|
+
Box: ({ children }) => _jsx("div", { children: children }),
|
|
20
|
+
Card: ({ children }) => _jsx("div", { children: children }),
|
|
21
|
+
CircularProgress: () => _jsx("div", { children: "loading" }),
|
|
22
|
+
Divider: () => _jsx("div", { children: "divider" }),
|
|
23
|
+
FormControl: ({ children }) => _jsx("div", { children: children }),
|
|
24
|
+
Grid: ({ children }) => _jsx("div", { children: children }),
|
|
25
|
+
IconButton: ({ children, onClick, disabled }) => (_jsx("button", { disabled: disabled, onClick: onClick, children: children })),
|
|
26
|
+
InputAdornment: ({ children }) => _jsx("div", { children: children }),
|
|
27
|
+
InputLabel: ({ children }) => _jsx("div", { children: children }),
|
|
28
|
+
MenuItem: ({ children }) => _jsx("div", { children: children }),
|
|
29
|
+
Select: ({ onChange }) => (_jsx("button", { onClick: () => onChange({ target: { value: 'Det-2' } }), children: "set-detection" })),
|
|
30
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
31
|
+
TextField: ({ label, value, onChange }) => (_jsxs("label", { children: [label, _jsx("input", { "aria-label": label, value: value, onChange: onChange })] })),
|
|
32
|
+
Tooltip: ({ children }) => _jsx("div", { children: children }),
|
|
33
|
+
Typography: ({ children }) => _jsx("div", { children: children })
|
|
34
|
+
}));
|
|
35
|
+
vi.mock('@tui/core', () => ({
|
|
36
|
+
useAppUser: () => appUserValue
|
|
37
|
+
}));
|
|
38
|
+
vi.mock('api', () => ({
|
|
39
|
+
default: {
|
|
40
|
+
analytic: {
|
|
41
|
+
notebooks: {
|
|
42
|
+
post: (id, payload) => ({ id, payload, op: 'post' }),
|
|
43
|
+
del: (id, notebookIds) => ({ id, notebookIds, op: 'del' })
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
vi.mock('components/elements/addons/layout/FlexOne', () => ({
|
|
49
|
+
default: () => _jsx("div", { children: "flex" })
|
|
50
|
+
}));
|
|
51
|
+
vi.mock('components/elements/display/HowlerAvatar', () => ({
|
|
52
|
+
default: ({ userId }) => _jsx("div", { children: `avatar:${userId}` })
|
|
53
|
+
}));
|
|
54
|
+
vi.mock('components/elements/hit/HitNotebooks', () => ({
|
|
55
|
+
default: ({ selectedNotebook }) => _jsx("div", { children: `hits:${selectedNotebook}` })
|
|
56
|
+
}));
|
|
57
|
+
vi.mock('components/hooks/useMyApi', () => ({
|
|
58
|
+
default: () => ({ dispatchApi: mockDispatchApi })
|
|
59
|
+
}));
|
|
60
|
+
vi.mock('react-i18next', () => ({
|
|
61
|
+
useTranslation: () => ({ t: (key) => key })
|
|
62
|
+
}));
|
|
63
|
+
import AnalyticNotebooks from './AnalyticNotebooks';
|
|
64
|
+
describe('AnalyticNotebooks', () => {
|
|
65
|
+
beforeEach(() => {
|
|
66
|
+
appUserValue = { user: { username: 'demo', roles: ['admin'] } };
|
|
67
|
+
mockDispatchApi.mockReset();
|
|
68
|
+
});
|
|
69
|
+
it('adds notebooks and clears the form when the request succeeds', async () => {
|
|
70
|
+
const setAnalytic = vi.fn();
|
|
71
|
+
mockDispatchApi.mockResolvedValueOnce({ analytic_id: 'an-1', notebooks: [] });
|
|
72
|
+
render(_jsx(AnalyticNotebooks, { analytic: { analytic_id: 'an-1', detections: ['Det-1', 'Det-2'], notebooks: [] }, setAnalytic: setAnalytic }));
|
|
73
|
+
fireEvent.click(screen.getByText('set-detection'));
|
|
74
|
+
fireEvent.change(screen.getByLabelText('analytic.notebook.name'), { target: { value: 'Notebook 1' } });
|
|
75
|
+
fireEvent.change(screen.getByLabelText('analytic.notebook.link'), { target: { value: 'https://example.test' } });
|
|
76
|
+
fireEvent.click(screen.getByText('add-icon'));
|
|
77
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({
|
|
78
|
+
id: 'an-1',
|
|
79
|
+
op: 'post',
|
|
80
|
+
payload: {
|
|
81
|
+
detection: 'Det-2',
|
|
82
|
+
link: 'https://example.test',
|
|
83
|
+
name: 'Notebook 1',
|
|
84
|
+
value: 'https://example.test'
|
|
85
|
+
}
|
|
86
|
+
}, expect.any(Object)));
|
|
87
|
+
expect(setAnalytic).toHaveBeenCalledWith({ analytic_id: 'an-1', notebooks: [] });
|
|
88
|
+
expect(screen.getByLabelText('analytic.notebook.name')).toHaveValue('');
|
|
89
|
+
expect(screen.getByLabelText('analytic.notebook.link')).toHaveValue('');
|
|
90
|
+
});
|
|
91
|
+
it('renders notebooks in detection order and deletes removable entries', async () => {
|
|
92
|
+
const setAnalytic = vi.fn();
|
|
93
|
+
const analytic = {
|
|
94
|
+
analytic_id: 'an-1',
|
|
95
|
+
detections: ['Det-1', 'Det-2'],
|
|
96
|
+
notebooks: [
|
|
97
|
+
{ id: 'n2', detection: 'Det-2', name: 'Second', value: 'link-2', user: 'other' },
|
|
98
|
+
{ id: 'n1', detection: 'Det-1', name: 'First', value: 'link-1', user: 'demo' }
|
|
99
|
+
]
|
|
100
|
+
};
|
|
101
|
+
render(_jsx(AnalyticNotebooks, { analytic: analytic, setAnalytic: setAnalytic }));
|
|
102
|
+
expect(screen.getByText('avatar:demo')).toBeInTheDocument();
|
|
103
|
+
expect(screen.getByText('hits:First')).toBeInTheDocument();
|
|
104
|
+
expect(screen.getByText('Det-1')).toBeInTheDocument();
|
|
105
|
+
fireEvent.click(screen.getAllByText('delete-icon')[0]);
|
|
106
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({ id: 'an-1', notebookIds: ['n1'], op: 'del' }));
|
|
107
|
+
expect(setAnalytic).toHaveBeenCalledWith({
|
|
108
|
+
...analytic,
|
|
109
|
+
notebooks: [{ id: 'n2', detection: 'Det-2', name: 'Second', value: 'link-2', user: 'other' }]
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx } 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 mockShowSuccessMessage = vi.hoisted(() => vi.fn());
|
|
7
|
+
const mockCountPost = vi.hoisted(() => vi.fn());
|
|
8
|
+
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
9
|
+
const actual = await importOriginal();
|
|
10
|
+
return {
|
|
11
|
+
...actual,
|
|
12
|
+
Check: () => _jsx("div", { children: "check-icon" }),
|
|
13
|
+
Edit: () => _jsx("div", { children: "edit-icon" })
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
vi.mock('@mui/material', () => ({
|
|
17
|
+
Alert: ({ children }) => _jsx("div", { children: children }),
|
|
18
|
+
AlertTitle: ({ children }) => _jsx("div", { children: children }),
|
|
19
|
+
Box: ({ children }) => _jsx("div", { children: children }),
|
|
20
|
+
Card: ({ children }) => _jsx("div", { children: children }),
|
|
21
|
+
CardContent: ({ children }) => _jsx("div", { children: children }),
|
|
22
|
+
CircularProgress: () => _jsx("div", { children: "loading-indicator" }),
|
|
23
|
+
Divider: () => _jsx("div", { children: "divider" }),
|
|
24
|
+
IconButton: ({ children, onClick }) => _jsx("button", { onClick: onClick, children: children }),
|
|
25
|
+
Skeleton: () => _jsx("div", { children: "loading" }),
|
|
26
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
27
|
+
TextField: ({ value, onChange }) => _jsx("textarea", { "aria-label": "edit-description", value: value, onChange: onChange }),
|
|
28
|
+
Typography: ({ children }) => _jsx("div", { children: children }),
|
|
29
|
+
useMediaQuery: () => false,
|
|
30
|
+
useTheme: () => ({ breakpoints: { down: () => 'md' }, spacing: (n) => `${n * 8}px` })
|
|
31
|
+
}));
|
|
32
|
+
vi.mock('api', () => ({
|
|
33
|
+
default: {
|
|
34
|
+
analytic: {
|
|
35
|
+
put: (id, payload) => ({ id, payload, op: 'put' })
|
|
36
|
+
},
|
|
37
|
+
search: {
|
|
38
|
+
count: {
|
|
39
|
+
hit: {
|
|
40
|
+
post: mockCountPost
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}));
|
|
46
|
+
vi.mock('chartjs-adapter-dayjs-4', () => ({}));
|
|
47
|
+
vi.mock('components/elements/display/Markdown', () => ({
|
|
48
|
+
default: ({ md }) => _jsx("div", { children: `markdown:${md}` })
|
|
49
|
+
}));
|
|
50
|
+
vi.mock('components/hooks/useMyApi', () => ({
|
|
51
|
+
default: () => ({ dispatchApi: mockDispatchApi })
|
|
52
|
+
}));
|
|
53
|
+
vi.mock('components/hooks/useMySnackbar', () => ({
|
|
54
|
+
default: () => ({ showSuccessMessage: mockShowSuccessMessage })
|
|
55
|
+
}));
|
|
56
|
+
vi.mock('react-i18next', () => ({
|
|
57
|
+
useTranslation: () => ({ t: (key) => key })
|
|
58
|
+
}));
|
|
59
|
+
vi.mock('./widgets/Assessment', () => ({ default: () => _jsx("div", { children: "assessment" }) }));
|
|
60
|
+
vi.mock('./widgets/Created', () => ({ default: () => _jsx("div", { children: "created" }) }));
|
|
61
|
+
vi.mock('./widgets/Detection', () => ({ default: () => _jsx("div", { children: "detection" }) }));
|
|
62
|
+
vi.mock('./widgets/Escalation', () => ({ default: () => _jsx("div", { children: "escalation" }) }));
|
|
63
|
+
vi.mock('./widgets/Status', () => ({ default: () => _jsx("div", { children: "status" }) }));
|
|
64
|
+
import AnalyticOverview from './AnalyticOverview';
|
|
65
|
+
describe('AnalyticOverview', () => {
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
mockDispatchApi.mockReset();
|
|
68
|
+
mockShowSuccessMessage.mockReset();
|
|
69
|
+
mockCountPost.mockReset();
|
|
70
|
+
});
|
|
71
|
+
it('shows an empty-state warning when no hits match the analytic', async () => {
|
|
72
|
+
mockCountPost.mockResolvedValueOnce({ count: 0 });
|
|
73
|
+
render(_jsx(AnalyticOverview, { analytic: { analytic_id: 'an-1', name: 'Alpha', description: 'desc' }, setAnalytic: vi.fn() }));
|
|
74
|
+
await waitFor(() => expect(mockCountPost).toHaveBeenCalledWith({ query: 'howler.analytic:"Alpha"' }));
|
|
75
|
+
await waitFor(() => {
|
|
76
|
+
expect(screen.getByText('route.analytics.overview.empty.title')).toBeInTheDocument();
|
|
77
|
+
expect(screen.getByText('route.analytics.overview.empty.description')).toBeInTheDocument();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
it('renders statistics and saves edited markdown descriptions', async () => {
|
|
81
|
+
const setAnalytic = vi.fn();
|
|
82
|
+
mockCountPost.mockResolvedValueOnce({ count: 2 });
|
|
83
|
+
mockDispatchApi.mockResolvedValueOnce({ analytic_id: 'an-1', description: 'updated' });
|
|
84
|
+
render(_jsx(AnalyticOverview, { analytic: { analytic_id: 'an-1', name: 'Alpha', description: 'original' }, setAnalytic: setAnalytic }));
|
|
85
|
+
await waitFor(() => expect(screen.getByText('created')).toBeInTheDocument());
|
|
86
|
+
expect(screen.getByText('assessment')).toBeInTheDocument();
|
|
87
|
+
expect(screen.getByText('status')).toBeInTheDocument();
|
|
88
|
+
expect(screen.getByText('detection')).toBeInTheDocument();
|
|
89
|
+
expect(screen.getByText('markdown:original')).toBeInTheDocument();
|
|
90
|
+
fireEvent.click(screen.getByText('edit-icon'));
|
|
91
|
+
fireEvent.change(screen.getByLabelText('edit-description'), { target: { value: 'updated' } });
|
|
92
|
+
fireEvent.click(screen.getByText('check-icon'));
|
|
93
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({ id: 'an-1', op: 'put', payload: { description: 'updated' } }, { showError: true, throwError: true }));
|
|
94
|
+
expect(setAnalytic).toHaveBeenCalledWith({ analytic_id: 'an-1', description: 'updated' });
|
|
95
|
+
expect(mockShowSuccessMessage).toHaveBeenCalledWith('route.analytics.updated');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
const mockGetOverviews = vi.hoisted(() => vi.fn(async () => undefined));
|
|
6
|
+
const overviewContextToken = vi.hoisted(() => ({ name: 'overview-context' }));
|
|
7
|
+
let overviewsValue = [];
|
|
8
|
+
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
9
|
+
const actual = await importOriginal();
|
|
10
|
+
return { ...actual, Article: () => _jsx("div", { children: "article-icon" }) };
|
|
11
|
+
});
|
|
12
|
+
vi.mock('@mui/material', () => ({
|
|
13
|
+
Box: ({ children }) => _jsx("div", { children: children }),
|
|
14
|
+
Fab: ({ children }) => _jsx("div", { children: children }),
|
|
15
|
+
Skeleton: () => _jsx("div", { children: "loading" }),
|
|
16
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
17
|
+
Typography: ({ children }) => _jsx("div", { children: children }),
|
|
18
|
+
useMediaQuery: () => false
|
|
19
|
+
}));
|
|
20
|
+
vi.mock('@tui/core', () => ({
|
|
21
|
+
AppListEmpty: () => _jsx("div", { children: "empty" })
|
|
22
|
+
}));
|
|
23
|
+
vi.mock('chartjs-adapter-dayjs-4', () => ({}));
|
|
24
|
+
vi.mock('components/app/providers/OverviewProvider', () => ({
|
|
25
|
+
OverviewContext: overviewContextToken
|
|
26
|
+
}));
|
|
27
|
+
vi.mock('react-i18next', () => ({
|
|
28
|
+
useTranslation: () => ({ t: (key) => key })
|
|
29
|
+
}));
|
|
30
|
+
vi.mock('react-router', () => ({
|
|
31
|
+
Link: ({ children }) => _jsx("div", { children: children })
|
|
32
|
+
}));
|
|
33
|
+
vi.mock('../overviews/OverviewCard', () => ({
|
|
34
|
+
default: ({ overview }) => _jsx("div", { children: `overview:${overview.overview_id}:${overview.detection ?? ''}` })
|
|
35
|
+
}));
|
|
36
|
+
vi.mock('react', async (importOriginal) => {
|
|
37
|
+
const actual = await importOriginal();
|
|
38
|
+
return {
|
|
39
|
+
...actual,
|
|
40
|
+
useContext: (context) => {
|
|
41
|
+
if (context === overviewContextToken) {
|
|
42
|
+
return { getOverviews: mockGetOverviews, overviews: overviewsValue };
|
|
43
|
+
}
|
|
44
|
+
return actual.useContext(context);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
import AnalyticOverviews from './AnalyticOverviews';
|
|
49
|
+
describe('AnalyticOverviews', () => {
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
overviewsValue = [];
|
|
52
|
+
mockGetOverviews.mockClear();
|
|
53
|
+
});
|
|
54
|
+
it('shows a skeleton when the analytic is missing', () => {
|
|
55
|
+
render(_jsx(AnalyticOverviews, { analytic: undefined }));
|
|
56
|
+
expect(screen.getByText('loading')).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
it('loads matching overviews and falls back to the empty state', async () => {
|
|
59
|
+
overviewsValue = [
|
|
60
|
+
{ overview_id: 'o1', analytic: 'Alpha', detection: 'Det1' },
|
|
61
|
+
{ overview_id: 'o2', analytic: 'Beta' }
|
|
62
|
+
];
|
|
63
|
+
const { rerender } = render(_jsx(AnalyticOverviews, { analytic: { name: 'Alpha' } }));
|
|
64
|
+
await waitFor(() => expect(mockGetOverviews).toHaveBeenCalled());
|
|
65
|
+
expect(screen.getByText('overview:o1:Det1')).toBeInTheDocument();
|
|
66
|
+
expect(screen.getByText('route.overviews.create')).toBeInTheDocument();
|
|
67
|
+
rerender(_jsx(AnalyticOverviews, { analytic: { name: 'Gamma' } }));
|
|
68
|
+
await waitFor(() => expect(screen.getByText('empty')).toBeInTheDocument());
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
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 listMethodContextToken = vi.hoisted(() => ({ name: 'list-method-context' }));
|
|
6
|
+
const mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
7
|
+
const mockNavigate = vi.hoisted(() => vi.fn());
|
|
8
|
+
const mockSetSearchParams = vi.hoisted(() => vi.fn());
|
|
9
|
+
const mockLoad = vi.hoisted(() => vi.fn());
|
|
10
|
+
const mockRequest = vi.hoisted(() => vi.fn());
|
|
11
|
+
const mockSetUser = vi.hoisted(() => vi.fn());
|
|
12
|
+
let searchParamsValue = new URLSearchParams();
|
|
13
|
+
let responseValue = {
|
|
14
|
+
total: 1,
|
|
15
|
+
items: [
|
|
16
|
+
{ analytic_id: 'an-1', name: 'Alpha', owner: 'owner-1', contributors: ['owner-1', 'user-2'], detections: ['d1'] }
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
let appUserValue = {
|
|
20
|
+
user: { username: 'demo', favourite_analytics: [] },
|
|
21
|
+
setUser: mockSetUser
|
|
22
|
+
};
|
|
23
|
+
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
24
|
+
const actual = await importOriginal();
|
|
25
|
+
return {
|
|
26
|
+
...actual,
|
|
27
|
+
Star: () => _jsx("div", { children: "star" }),
|
|
28
|
+
StarBorder: () => _jsx("div", { children: "star-border" })
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
vi.mock('@mui/material', () => ({
|
|
32
|
+
AvatarGroup: ({ children }) => _jsx("div", { children: children }),
|
|
33
|
+
Card: ({ children, onClick }) => _jsx("div", { onClick: onClick, children: children }),
|
|
34
|
+
CardContent: ({ children }) => _jsx("div", { children: children }),
|
|
35
|
+
CardHeader: ({ title }) => _jsx("div", { children: title }),
|
|
36
|
+
Chip: ({ label }) => _jsx("div", { children: label }),
|
|
37
|
+
Divider: () => _jsx("div", { children: "divider" }),
|
|
38
|
+
Grid: ({ children }) => _jsx("div", { children: children }),
|
|
39
|
+
IconButton: ({ children, onClick }) => _jsx("button", { onClick: onClick, children: children }),
|
|
40
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
41
|
+
Tooltip: ({ children }) => _jsx("div", { children: children }),
|
|
42
|
+
Typography: ({ children }) => _jsx("div", { children: children }),
|
|
43
|
+
useTheme: () => ({ palette: { text: { disabled: '#999' } }, spacing: (v) => `${v * 8}px` })
|
|
44
|
+
}));
|
|
45
|
+
vi.mock('@tui/core', () => ({
|
|
46
|
+
useAppUser: () => appUserValue
|
|
47
|
+
}));
|
|
48
|
+
vi.mock('api', () => ({
|
|
49
|
+
default: {
|
|
50
|
+
analytic: {
|
|
51
|
+
favourite: {
|
|
52
|
+
post: (id) => ({ id, op: 'add' }),
|
|
53
|
+
del: (id) => ({ id, op: 'remove' })
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
search: {
|
|
57
|
+
analytic: {
|
|
58
|
+
post: 'analytic-search'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
vi.mock('components/app/providers/SearchResponseProvider', () => ({
|
|
64
|
+
__esModule: true,
|
|
65
|
+
default: ({ children }) => _jsx("div", { children: children }),
|
|
66
|
+
createSearchResponseContext: () => ({}),
|
|
67
|
+
useSearchResponseContext: () => ({
|
|
68
|
+
response: responseValue,
|
|
69
|
+
request: mockRequest
|
|
70
|
+
})
|
|
71
|
+
}));
|
|
72
|
+
vi.mock('components/elements/addons/layout/FlexOne', () => ({
|
|
73
|
+
default: () => _jsx("div", { children: "flex" })
|
|
74
|
+
}));
|
|
75
|
+
vi.mock('components/elements/addons/lists', () => ({
|
|
76
|
+
TuiListProvider: ({ children }) => _jsx("div", { children: children })
|
|
77
|
+
}));
|
|
78
|
+
vi.mock('components/elements/addons/lists/TuiListProvider', () => ({
|
|
79
|
+
TuiListMethodContext: listMethodContextToken
|
|
80
|
+
}));
|
|
81
|
+
vi.mock('components/elements/display/HowlerAvatar', () => ({
|
|
82
|
+
default: ({ userId }) => _jsx("div", { children: `avatar:${userId}` })
|
|
83
|
+
}));
|
|
84
|
+
vi.mock('components/elements/display/ItemManager', () => ({
|
|
85
|
+
default: (props) => (_jsxs("div", { children: [_jsx("button", { onClick: () => props.onSearch(), children: "search" }), _jsx("button", { onClick: () => props.onPageChange(50), children: "page" }), _jsx("div", { children: props.aboveSearch }), props.response?.items?.map((item) => (_jsx("div", { children: props.renderer({ item: { item } }, () => 'card') }, item.analytic_id)))] }))
|
|
86
|
+
}));
|
|
87
|
+
vi.mock('components/hooks/useMyApi', () => ({
|
|
88
|
+
default: () => ({ dispatchApi: mockDispatchApi })
|
|
89
|
+
}));
|
|
90
|
+
vi.mock('components/hooks/useMyLocalStorage', () => ({
|
|
91
|
+
useMyLocalStorageItem: () => [25]
|
|
92
|
+
}));
|
|
93
|
+
vi.mock('react-i18next', () => ({
|
|
94
|
+
useTranslation: () => ({ t: (key) => key })
|
|
95
|
+
}));
|
|
96
|
+
vi.mock('react-router', () => ({
|
|
97
|
+
useNavigate: () => mockNavigate,
|
|
98
|
+
useSearchParams: () => [searchParamsValue, mockSetSearchParams]
|
|
99
|
+
}));
|
|
100
|
+
vi.mock('react', async (importOriginal) => {
|
|
101
|
+
const actual = await importOriginal();
|
|
102
|
+
return {
|
|
103
|
+
...actual,
|
|
104
|
+
useContext: (context) => {
|
|
105
|
+
if (context === listMethodContextToken) {
|
|
106
|
+
return { load: mockLoad };
|
|
107
|
+
}
|
|
108
|
+
return actual.useContext(context);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
import AnalyticSearch from './AnalyticSearch';
|
|
113
|
+
describe('AnalyticSearch', () => {
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
searchParamsValue = new URLSearchParams();
|
|
116
|
+
responseValue = {
|
|
117
|
+
total: 1,
|
|
118
|
+
items: [
|
|
119
|
+
{
|
|
120
|
+
analytic_id: 'an-1',
|
|
121
|
+
name: 'Alpha',
|
|
122
|
+
owner: 'owner-1',
|
|
123
|
+
contributors: ['owner-1', 'user-2'],
|
|
124
|
+
detections: ['d1', 'd2', 'd3', 'd4', 'd5', 'd6']
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
appUserValue = {
|
|
129
|
+
user: { username: 'demo', favourite_analytics: [] },
|
|
130
|
+
setUser: mockSetUser
|
|
131
|
+
};
|
|
132
|
+
mockDispatchApi.mockReset().mockImplementation(async (value) => value);
|
|
133
|
+
mockNavigate.mockReset();
|
|
134
|
+
mockSetSearchParams.mockReset();
|
|
135
|
+
mockLoad.mockReset();
|
|
136
|
+
mockRequest.mockReset().mockResolvedValue(responseValue);
|
|
137
|
+
mockSetUser.mockReset();
|
|
138
|
+
});
|
|
139
|
+
it('searches analytics, paginates, navigates, and toggles favourites', async () => {
|
|
140
|
+
render(_jsx(AnalyticSearch, {}));
|
|
141
|
+
await waitFor(() => expect(mockRequest).toHaveBeenCalledWith('analytic-search', {
|
|
142
|
+
query: 'name:** OR detections:**',
|
|
143
|
+
rows: 25,
|
|
144
|
+
offset: 0
|
|
145
|
+
}));
|
|
146
|
+
expect(mockLoad).toHaveBeenCalledWith([expect.objectContaining({ id: 'an-1' })]);
|
|
147
|
+
expect(screen.getByText('Alpha')).toBeInTheDocument();
|
|
148
|
+
expect(screen.getByText('avatar:owner-1')).toBeInTheDocument();
|
|
149
|
+
expect(screen.getByText('avatar:user-2')).toBeInTheDocument();
|
|
150
|
+
expect(screen.getByText('+ 1')).toBeInTheDocument();
|
|
151
|
+
fireEvent.click(screen.getByText('page'));
|
|
152
|
+
expect(mockSetSearchParams).toHaveBeenCalled();
|
|
153
|
+
fireEvent.click(screen.getByText('star-border'));
|
|
154
|
+
await waitFor(() => expect(mockSetUser).toHaveBeenCalledWith(expect.objectContaining({ favourite_analytics: ['an-1'] })));
|
|
155
|
+
fireEvent.click(screen.getByText('Alpha'));
|
|
156
|
+
expect(mockNavigate).toHaveBeenCalledWith('/analytics/an-1');
|
|
157
|
+
});
|
|
158
|
+
it('removes favourites when the analytic is already pinned', async () => {
|
|
159
|
+
appUserValue = {
|
|
160
|
+
user: { username: 'demo', favourite_analytics: ['an-1'] },
|
|
161
|
+
setUser: mockSetUser
|
|
162
|
+
};
|
|
163
|
+
render(_jsx(AnalyticSearch, {}));
|
|
164
|
+
fireEvent.click(screen.getByText('star'));
|
|
165
|
+
await waitFor(() => expect(mockSetUser).toHaveBeenCalledWith(expect.objectContaining({ favourite_analytics: [] })));
|
|
166
|
+
});
|
|
167
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
const mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
6
|
+
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
7
|
+
const actual = await importOriginal();
|
|
8
|
+
return { ...actual, Article: () => _jsx("div", { children: "article-icon" }) };
|
|
9
|
+
});
|
|
10
|
+
vi.mock('@mui/material', () => ({
|
|
11
|
+
Box: ({ children }) => _jsx("div", { children: children }),
|
|
12
|
+
Fab: ({ children }) => _jsx("div", { children: children }),
|
|
13
|
+
Skeleton: () => _jsx("div", { children: "loading" }),
|
|
14
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
15
|
+
Typography: ({ children }) => _jsx("div", { children: children }),
|
|
16
|
+
useMediaQuery: () => false
|
|
17
|
+
}));
|
|
18
|
+
vi.mock('@tui/core', () => ({
|
|
19
|
+
AppListEmpty: () => _jsx("div", { children: "empty" })
|
|
20
|
+
}));
|
|
21
|
+
vi.mock('api', () => ({
|
|
22
|
+
default: {
|
|
23
|
+
template: {
|
|
24
|
+
get: () => ({})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
vi.mock('chartjs-adapter-dayjs-4', () => ({}));
|
|
29
|
+
vi.mock('components/hooks/useMyApi', () => ({
|
|
30
|
+
default: () => ({ dispatchApi: mockDispatchApi })
|
|
31
|
+
}));
|
|
32
|
+
vi.mock('react-i18next', () => ({
|
|
33
|
+
useTranslation: () => ({ t: (key) => key })
|
|
34
|
+
}));
|
|
35
|
+
vi.mock('react-router', () => ({
|
|
36
|
+
Link: ({ children }) => _jsx("div", { children: children })
|
|
37
|
+
}));
|
|
38
|
+
vi.mock('../templates/TemplateCard', () => ({
|
|
39
|
+
default: ({ template }) => (_jsx("div", { children: `template:${template.template_id}:${template.detection ?? ''}:${template.type}` }))
|
|
40
|
+
}));
|
|
41
|
+
import AnalyticTemplates from './AnalyticTemplates';
|
|
42
|
+
describe('AnalyticTemplates', () => {
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
mockDispatchApi.mockReset();
|
|
45
|
+
});
|
|
46
|
+
it('shows a skeleton when the analytic is missing', () => {
|
|
47
|
+
mockDispatchApi.mockResolvedValue([]);
|
|
48
|
+
render(_jsx(AnalyticTemplates, { analytic: undefined }));
|
|
49
|
+
expect(screen.getByText('loading')).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
it('loads matching templates and shows empty state when none match', async () => {
|
|
52
|
+
mockDispatchApi.mockResolvedValueOnce([
|
|
53
|
+
{ template_id: 't1', analytic: 'Alpha', detection: 'Det1', type: 'global' },
|
|
54
|
+
{ template_id: 't2', analytic: 'Beta', type: 'personal' }
|
|
55
|
+
]);
|
|
56
|
+
const { rerender } = render(_jsx(AnalyticTemplates, { analytic: { name: 'Alpha' } }));
|
|
57
|
+
await waitFor(() => expect(screen.getByText('template:t1:Det1:global')).toBeInTheDocument());
|
|
58
|
+
expect(screen.getByText('route.templates.create')).toBeInTheDocument();
|
|
59
|
+
mockDispatchApi.mockResolvedValueOnce([{ template_id: 't2', analytic: 'Beta', type: 'personal' }]);
|
|
60
|
+
rerender(_jsx(AnalyticTemplates, { analytic: { name: 'Gamma' } }));
|
|
61
|
+
await waitFor(() => expect(screen.getByText('empty')).toBeInTheDocument());
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
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 mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
6
|
+
const apiConfigContextToken = vi.hoisted(() => ({ name: 'api-config-context' }));
|
|
7
|
+
let configValue = { lookups: { 'howler.assessment': ['malicious', 'suspicious'] } };
|
|
8
|
+
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
9
|
+
const actual = await importOriginal();
|
|
10
|
+
return {
|
|
11
|
+
...actual,
|
|
12
|
+
Check: () => _jsx("div", { children: "check-icon" }),
|
|
13
|
+
Delete: () => _jsx("div", { children: "delete-icon" }),
|
|
14
|
+
Remove: () => _jsx("div", { children: "remove-icon" })
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
vi.mock('@mui/material', () => ({
|
|
18
|
+
Card: ({ children }) => _jsx("div", { children: children }),
|
|
19
|
+
Chip: ({ label, onClick }) => _jsx("button", { onClick: onClick, children: label }),
|
|
20
|
+
Divider: () => _jsx("div", { children: "divider" }),
|
|
21
|
+
Grid: ({ children }) => _jsx("div", { children: children }),
|
|
22
|
+
IconButton: ({ children, onClick, disabled }) => (_jsx("button", { disabled: disabled, onClick: onClick, children: children })),
|
|
23
|
+
InputAdornment: ({ children }) => _jsx("div", { children: children }),
|
|
24
|
+
LinearProgress: () => _jsx("div", { children: "progress" }),
|
|
25
|
+
Paper: ({ children }) => _jsx("div", { children: children }),
|
|
26
|
+
Stack: ({ children }) => _jsx("div", { children: children }),
|
|
27
|
+
Table: ({ children }) => _jsx("div", { children: children }),
|
|
28
|
+
TableBody: ({ children }) => _jsx("div", { children: children }),
|
|
29
|
+
TableCell: ({ children }) => _jsx("div", { children: children }),
|
|
30
|
+
TableContainer: ({ children }) => _jsx("div", { children: children }),
|
|
31
|
+
TableHead: ({ children }) => _jsx("div", { children: children }),
|
|
32
|
+
TableRow: ({ children }) => _jsx("div", { children: children }),
|
|
33
|
+
TextField: ({ label, value, onChange, onKeyDown }) => (_jsxs("label", { children: [label, _jsx("input", { "aria-label": label, value: value, onChange: onChange, onKeyDown: onKeyDown })] })),
|
|
34
|
+
Tooltip: ({ children }) => _jsx("div", { children: children }),
|
|
35
|
+
Typography: ({ children }) => _jsx("div", { children: children })
|
|
36
|
+
}));
|
|
37
|
+
vi.mock('api', () => ({
|
|
38
|
+
default: {
|
|
39
|
+
analytic: {
|
|
40
|
+
put: (id, payload) => ({ id, payload, op: 'put' })
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
vi.mock('chartjs-adapter-dayjs-4', () => ({}));
|
|
45
|
+
vi.mock('components/app/providers/ApiConfigProvider', () => ({
|
|
46
|
+
ApiConfigContext: apiConfigContextToken
|
|
47
|
+
}));
|
|
48
|
+
vi.mock('components/elements/EditRow', () => ({
|
|
49
|
+
default: ({ onEdit }) => _jsx("button", { onClick: () => onEdit('true'), children: "toggle-skip" })
|
|
50
|
+
}));
|
|
51
|
+
vi.mock('components/hooks/useMyApi', () => ({
|
|
52
|
+
default: () => ({ dispatchApi: mockDispatchApi })
|
|
53
|
+
}));
|
|
54
|
+
vi.mock('react-i18next', () => ({
|
|
55
|
+
useTranslation: () => ({ t: (key) => key })
|
|
56
|
+
}));
|
|
57
|
+
vi.mock('react', async (importOriginal) => {
|
|
58
|
+
const actual = await importOriginal();
|
|
59
|
+
return {
|
|
60
|
+
...actual,
|
|
61
|
+
useContext: (context) => {
|
|
62
|
+
if (context === apiConfigContextToken) {
|
|
63
|
+
return { config: configValue };
|
|
64
|
+
}
|
|
65
|
+
return actual.useContext(context);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
import TriageSettings from './TriageSettings';
|
|
70
|
+
describe('TriageSettings', () => {
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
configValue = { lookups: { 'howler.assessment': ['malicious', 'suspicious'] } };
|
|
73
|
+
mockDispatchApi.mockReset().mockImplementation(async (_request) => ({ analytic_id: 'an-1' }));
|
|
74
|
+
});
|
|
75
|
+
it('updates skip rationale, assessments, and rationales', async () => {
|
|
76
|
+
const setAnalytic = vi.fn();
|
|
77
|
+
render(_jsx(TriageSettings, { analytic: { analytic_id: 'an-1', triage_settings: { valid_assessments: ['malicious'], rationales: ['because'] } }, setAnalytic: setAnalytic }));
|
|
78
|
+
fireEvent.click(screen.getByText('toggle-skip'));
|
|
79
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({ id: 'an-1', op: 'put', payload: { triage_settings: { skip_rationale: true } } }, { throwError: true, showError: true }));
|
|
80
|
+
fireEvent.click(screen.getByText('Malicious'));
|
|
81
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({ id: 'an-1', op: 'put', payload: { triage_settings: { valid_assessments: [] } } }, { throwError: true, showError: true }));
|
|
82
|
+
fireEvent.click(screen.getByText('delete-icon'));
|
|
83
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({ id: 'an-1', op: 'put', payload: { triage_settings: { rationales: [] } } }, { throwError: true, showError: true }));
|
|
84
|
+
fireEvent.change(screen.getByLabelText('route.analytics.rationales.new'), { target: { value: 'new reason' } });
|
|
85
|
+
fireEvent.keyDown(screen.getByLabelText('route.analytics.rationales.new'), { key: 'Enter' });
|
|
86
|
+
await waitFor(() => expect(mockDispatchApi).toHaveBeenCalledWith({ id: 'an-1', op: 'put', payload: { triage_settings: { rationales: ['because', 'new reason'] } } }, { throwError: true, showError: true }));
|
|
87
|
+
expect(setAnalytic).toHaveBeenCalled();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|