@cccsaurora/howler-ui 2.19.0-dev.839 → 2.19.0-dev.842
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/index.d.ts +4 -0
- package/api/index.js +10 -2
- package/api/search/case.d.ts +4 -0
- package/api/search/case.js +8 -0
- package/api/search/facet/hit.d.ts +1 -3
- package/api/search/facet/index.d.ts +3 -1
- package/api/search/index.d.ts +2 -1
- package/api/search/index.js +2 -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/v2/case/index.d.ts +9 -0
- package/api/v2/case/index.js +21 -0
- package/api/v2/case/items.d.ts +6 -0
- package/api/v2/case/items.js +18 -0
- package/api/v2/case/rules.d.ts +6 -0
- package/api/v2/case/rules.js +18 -0
- package/api/v2/index.d.ts +4 -0
- package/api/v2/index.js +6 -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 +5 -0
- package/api/v2/search/index.js +24 -0
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/components/app/App.js +41 -8
- package/components/app/hooks/useMatchers.d.ts +1 -1
- package/components/app/hooks/useMatchers.js +23 -11
- package/components/app/hooks/useMatchers.test.js +22 -22
- package/components/app/hooks/useTitle.js +5 -5
- package/components/app/providers/FavouritesProvider.js +2 -2
- package/components/app/providers/ModalProvider.d.ts +1 -0
- package/components/app/providers/ParameterProvider.d.ts +9 -2
- package/components/app/providers/ParameterProvider.js +165 -240
- package/components/app/providers/ParameterProvider.test.js +346 -94
- package/components/app/providers/RecordProvider.d.ts +23 -0
- package/components/app/providers/{HitProvider.js → RecordProvider.js} +41 -41
- package/components/app/providers/{HitSearchProvider.d.ts → RecordSearchProvider.d.ts} +6 -6
- package/components/app/providers/{HitSearchProvider.js → RecordSearchProvider.js} +12 -17
- package/components/app/providers/{HitSearchProvider.test.js → RecordSearchProvider.test.js} +52 -71
- package/components/app/providers/SocketProvider.d.ts +11 -2
- package/components/app/providers/SocketProvider.js +18 -5
- package/components/app/providers/UserListProvider.js +28 -8
- package/components/elements/ContextMenu.d.ts +56 -0
- package/components/elements/ContextMenu.js +109 -0
- package/components/elements/ContextMenu.test.d.ts +1 -0
- package/components/elements/ContextMenu.test.js +215 -0
- 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/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 +18 -8
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/case/CaseCard.d.ts +12 -0
- package/components/elements/case/CaseCard.js +42 -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/ChipPopper.d.ts +1 -1
- package/components/elements/display/ChipPopper.js +5 -5
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +2 -0
- package/components/elements/hit/HitActions.js +4 -4
- package/components/elements/hit/HitBanner.d.ts +1 -0
- package/components/elements/hit/HitBanner.js +29 -47
- package/components/elements/hit/HitCard.d.ts +2 -0
- package/components/elements/hit/HitCard.js +7 -7
- package/components/elements/hit/HitLabels.js +2 -2
- package/components/elements/hit/HitOutline.d.ts +1 -0
- package/components/elements/hit/HitOutline.js +3 -3
- package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
- package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
- package/components/elements/hit/HitSummary.d.ts +2 -1
- package/components/elements/hit/HitSummary.js +6 -5
- package/components/elements/hit/aggregate/HitGraph.js +8 -8
- package/components/elements/hit/elements/AnalyticLink.d.ts +9 -0
- package/components/elements/hit/elements/AnalyticLink.js +22 -0
- package/components/elements/hit/elements/Assigned.js +6 -3
- package/components/elements/hit/elements/Assigned.test.d.ts +1 -0
- package/components/elements/hit/elements/Assigned.test.js +65 -0
- package/components/elements/hit/outlines/DefaultOutline.js +1 -1
- package/components/elements/hit/related/RelatedRecords.js +63 -0
- package/components/elements/observable/ObservableCard.d.ts +6 -0
- package/components/elements/observable/ObservableCard.js +22 -0
- package/components/elements/observable/ObservablePreview.d.ts +6 -0
- package/components/elements/observable/ObservablePreview.js +12 -0
- package/components/elements/{hit/HitComments.d.ts → record/RecordComments.d.ts} +5 -4
- package/components/elements/{hit/HitComments.js → record/RecordComments.js} +29 -28
- 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} +98 -43
- 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} +15 -13
- package/components/elements/view/ViewTitle.d.ts +1 -0
- package/components/elements/view/ViewTitle.js +9 -2
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +4 -4
- package/components/hooks/useMyPreferences.js +10 -1
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +4 -1
- package/components/hooks/useMyTheme.js +9 -2
- 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/routes/action/edit/ActionEditor.js +2 -2
- package/components/routes/action/view/ActionSearch.js +1 -1
- package/components/routes/advanced/QueryBuilder.js +1 -1
- package/components/routes/advanced/QueryEditor.js +3 -3
- package/components/routes/advanced/historyCompletionProvider.js +3 -3
- package/components/routes/analytics/AnalyticDetails.js +2 -2
- package/components/routes/analytics/AnalyticSearch.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 +133 -0
- package/components/routes/cases/Cases.d.ts +2 -0
- package/components/routes/cases/Cases.js +148 -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 +33 -0
- package/components/routes/cases/detail/CaseAssets.d.ts +11 -0
- package/components/routes/cases/detail/CaseAssets.js +104 -0
- package/components/routes/cases/detail/CaseAssets.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseAssets.test.js +167 -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/CaseDetails.d.ts +6 -0
- package/components/routes/cases/detail/CaseDetails.js +70 -0
- package/components/routes/cases/detail/CaseOverview.d.ts +7 -0
- package/components/routes/cases/detail/CaseOverview.js +43 -0
- package/components/routes/cases/detail/CaseRules.d.ts +7 -0
- package/components/routes/cases/detail/CaseRules.js +57 -0
- package/components/routes/cases/detail/CaseRules.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseRules.test.js +221 -0
- package/components/routes/cases/detail/CaseSidebar.d.ts +8 -0
- package/components/routes/cases/detail/CaseSidebar.js +107 -0
- package/components/routes/cases/detail/CaseSidebar.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseSidebar.test.js +266 -0
- package/components/routes/cases/detail/CaseTask.d.ts +11 -0
- package/components/routes/cases/detail/CaseTask.js +66 -0
- package/components/routes/cases/detail/CaseTimeline.d.ts +12 -0
- package/components/routes/cases/detail/CaseTimeline.js +106 -0
- package/components/routes/cases/detail/CaseTimeline.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseTimeline.test.js +320 -0
- package/components/routes/cases/detail/CreateRuleDialog.d.ts +9 -0
- package/components/routes/cases/detail/CreateRuleDialog.js +163 -0
- package/components/routes/cases/detail/CreateRuleDialog.test.d.ts +1 -0
- package/components/routes/cases/detail/CreateRuleDialog.test.js +259 -0
- package/components/routes/cases/detail/ItemPage.d.ts +6 -0
- package/components/routes/cases/detail/ItemPage.js +95 -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/TaskPanel.d.ts +7 -0
- package/components/routes/cases/detail/TaskPanel.js +52 -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/assets/Asset.d.ts +14 -0
- package/components/routes/cases/detail/assets/Asset.js +12 -0
- package/components/routes/cases/detail/assets/Asset.test.d.ts +1 -0
- package/components/routes/cases/detail/assets/Asset.test.js +72 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +20 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.js +83 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.test.js +295 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.d.ts +34 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.js +103 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.js +363 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.d.ts +25 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.js +88 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.test.js +206 -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 +3 -0
- package/components/routes/cases/detail/sidebar/utils.js +29 -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/hooks/useCase.d.ts +13 -0
- package/components/routes/cases/hooks/useCase.js +69 -0
- package/components/routes/cases/hooks/useCase.test.d.ts +1 -0
- package/components/routes/cases/hooks/useCase.test.js +141 -0
- package/components/routes/cases/modals/AddToCaseModal.d.ts +7 -0
- package/components/routes/cases/modals/AddToCaseModal.js +59 -0
- package/components/routes/cases/modals/AddToCaseModal.test.d.ts +1 -0
- package/components/routes/cases/modals/AddToCaseModal.test.js +313 -0
- package/components/routes/cases/modals/CaseRecordRow.d.ts +9 -0
- package/components/routes/cases/modals/CaseRecordRow.js +15 -0
- package/components/routes/cases/modals/CreateCaseModal.d.ts +7 -0
- package/components/routes/cases/modals/CreateCaseModal.js +55 -0
- package/components/routes/cases/modals/CreateCaseModal.test.d.ts +1 -0
- package/components/routes/cases/modals/CreateCaseModal.test.js +358 -0
- package/components/routes/cases/modals/RenameItemModal.d.ts +9 -0
- package/components/routes/cases/modals/RenameItemModal.js +48 -0
- package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
- package/components/routes/cases/modals/ResolveModal.js +115 -0
- package/components/routes/cases/modals/ResolveModal.test.d.ts +1 -0
- package/components/routes/cases/modals/ResolveModal.test.js +394 -0
- package/components/routes/cases/modals/hooks.d.ts +7 -0
- package/components/routes/cases/modals/hooks.js +44 -0
- package/components/routes/cases/modals/types.d.ts +5 -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/dossiers/DossierEditor.js +2 -2
- package/components/routes/dossiers/DossierEditor.test.js +1 -1
- package/components/routes/help/ApiDocumentation.js +1 -1
- package/components/routes/help/HitBannerDocumentation.js +1 -0
- package/components/routes/help/HitDocumentation.js +1 -3
- package/components/routes/hits/search/InformationPane.d.ts +1 -0
- package/components/routes/hits/search/InformationPane.js +50 -63
- package/components/routes/hits/search/LayoutSettings.js +3 -3
- package/components/routes/hits/search/QuerySettings.js +2 -1
- package/components/routes/hits/search/QuerySettings.test.js +14 -9
- package/components/routes/hits/search/{HitBrowser.js → RecordBrowser.js} +9 -9
- 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 +26 -49
- package/components/routes/hits/search/ViewLink.js +3 -3
- package/components/routes/hits/search/ViewLink.test.js +8 -8
- package/components/routes/hits/search/grid/AddColumnModal.js +5 -4
- package/components/routes/hits/search/grid/EnhancedCell.d.ts +2 -1
- package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
- package/components/routes/hits/search/grid/HitGrid.js +20 -18
- package/components/routes/hits/search/grid/{HitRow.d.ts → RecordRow.d.ts} +3 -2
- package/components/routes/hits/search/grid/{HitRow.js → RecordRow.js} +10 -8
- package/components/routes/hits/search/shared/IndexPicker.d.ts +2 -0
- package/components/routes/hits/search/shared/IndexPicker.js +20 -0
- package/components/routes/hits/view/HitViewer.js +12 -13
- package/components/routes/home/ViewCard.js +47 -41
- package/components/routes/observables/ObservableViewer.d.ts +7 -0
- package/components/routes/observables/ObservableViewer.js +27 -0
- package/components/routes/overviews/OverviewViewer.js +2 -2
- package/components/routes/views/ViewComposer.js +46 -19
- package/locales/en/translation.json +122 -3
- package/locales/fr/translation.json +120 -3
- package/models/WithMetadata.d.ts +2 -1
- package/models/entities/generated/AttachmentsFile.d.ts +12 -0
- package/models/entities/generated/Case.d.ts +28 -0
- package/models/entities/generated/DestinationOriginal.d.ts +19 -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/Hit.d.ts +1 -0
- package/models/entities/generated/Howler.d.ts +0 -5
- package/models/entities/generated/HttpResponse.d.ts +11 -0
- package/models/entities/generated/Item.d.ts +9 -0
- package/models/entities/generated/Observable.d.ts +85 -0
- package/models/entities/generated/ObservableCloud.d.ts +20 -0
- package/models/entities/generated/ObservableDestination.d.ts +23 -0
- package/models/entities/generated/ObservableEmail.d.ts +30 -0
- package/models/entities/generated/ObservableFile.d.ts +36 -0
- package/models/entities/generated/ObservableHowler.d.ts +42 -0
- package/models/entities/generated/ObservableHttp.d.ts +11 -0
- package/models/entities/generated/ObservableObserver.d.ts +21 -0
- package/models/entities/generated/ObservableOrganization.d.ts +7 -0
- package/models/entities/generated/ObservableProcess.d.ts +34 -0
- package/models/entities/generated/ObservableSource.d.ts +23 -0
- package/models/entities/generated/ObservableThreat.d.ts +21 -0
- package/models/entities/generated/ObservableTls.d.ts +12 -0
- package/models/entities/generated/ObserverIngress.d.ts +9 -0
- package/models/entities/generated/Rule.d.ts +6 -9
- 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 +21 -1
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +2 -1
- package/tests/mocks.d.ts +11 -1
- package/tests/mocks.js +12 -7
- package/tests/server-handlers.js +6 -1
- package/tests/utils.d.ts +4 -0
- package/tests/utils.js +20 -0
- package/utils/constants.d.ts +4 -3
- package/utils/constants.js +6 -0
- package/utils/hitFunctions.d.ts +2 -1
- package/utils/hitFunctions.js +4 -4
- package/utils/socketUtils.d.ts +14 -0
- package/utils/socketUtils.js +17 -1
- package/utils/socketUtils.test.d.ts +1 -0
- package/utils/socketUtils.test.js +59 -0
- package/utils/typeUtils.d.ts +7 -0
- package/utils/typeUtils.js +27 -0
- package/utils/viewUtils.js +3 -0
- 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/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/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/RecordSearchProvider.test.d.ts} +0 -0
- /package/components/{routes/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react';
|
|
2
2
|
import { useContextSelector } from 'use-context-selector';
|
|
3
3
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
4
|
-
import {
|
|
4
|
+
import { RecordContext } from '../providers/RecordProvider';
|
|
5
5
|
import useMatchers from './useMatchers';
|
|
6
6
|
// Mock the useContextSelector hook
|
|
7
7
|
vi.mock('use-context-selector', () => ({
|
|
@@ -40,14 +40,14 @@ const mockHitWithMetadata = {
|
|
|
40
40
|
__overview: mockOverview,
|
|
41
41
|
__dossiers: mockDossiers
|
|
42
42
|
};
|
|
43
|
-
const
|
|
43
|
+
const mockGetRecord = vi.fn();
|
|
44
44
|
describe('useMatchers', () => {
|
|
45
45
|
beforeEach(() => {
|
|
46
46
|
vi.clearAllMocks();
|
|
47
47
|
// Mock useContextSelector to return our mock getHit function
|
|
48
48
|
useContextSelector.mockImplementation((context, selector) => {
|
|
49
|
-
if (context ===
|
|
50
|
-
return selector({
|
|
49
|
+
if (context === RecordContext) {
|
|
50
|
+
return selector({ getRecord: mockGetRecord });
|
|
51
51
|
}
|
|
52
52
|
return null;
|
|
53
53
|
});
|
|
@@ -69,25 +69,25 @@ describe('useMatchers', () => {
|
|
|
69
69
|
const { result } = renderHook(() => useMatchers());
|
|
70
70
|
const template = await result.current.getMatchingTemplate(mockHitWithMetadata);
|
|
71
71
|
expect(template).toBe(mockTemplate);
|
|
72
|
-
expect(
|
|
72
|
+
expect(mockGetRecord).not.toHaveBeenCalled();
|
|
73
73
|
});
|
|
74
74
|
it('should fetch hit with metadata when template is not present', async () => {
|
|
75
75
|
const { has } = await import('lodash-es');
|
|
76
76
|
has.mockReturnValue(false);
|
|
77
77
|
const hitWithFetchedMetadata = { ...mockHit, __template: mockTemplate };
|
|
78
|
-
|
|
78
|
+
mockGetRecord.mockResolvedValue(hitWithFetchedMetadata);
|
|
79
79
|
const { result } = renderHook(() => useMatchers());
|
|
80
80
|
const template = await result.current.getMatchingTemplate(mockHit);
|
|
81
81
|
expect(template).toBe(mockTemplate);
|
|
82
|
-
expect(
|
|
82
|
+
expect(mockGetRecord).toHaveBeenCalledWith('test-hit-id', true);
|
|
83
83
|
});
|
|
84
84
|
it('should handle getHit rejection gracefully', async () => {
|
|
85
85
|
const { has } = await import('lodash-es');
|
|
86
86
|
has.mockReturnValue(false);
|
|
87
|
-
|
|
87
|
+
mockGetRecord.mockRejectedValue(new Error('Failed to fetch hit'));
|
|
88
88
|
const { result } = renderHook(() => useMatchers());
|
|
89
89
|
await expect(result.current.getMatchingTemplate(mockHit)).resolves.toBeNull();
|
|
90
|
-
expect(
|
|
90
|
+
expect(mockGetRecord).toHaveBeenCalledWith('test-hit-id', true);
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
describe('getMatchingOverview', () => {
|
|
@@ -107,25 +107,25 @@ describe('useMatchers', () => {
|
|
|
107
107
|
const { result } = renderHook(() => useMatchers());
|
|
108
108
|
const overview = await result.current.getMatchingOverview(mockHitWithMetadata);
|
|
109
109
|
expect(overview).toBe(mockOverview);
|
|
110
|
-
expect(
|
|
110
|
+
expect(mockGetRecord).not.toHaveBeenCalled();
|
|
111
111
|
});
|
|
112
112
|
it('should fetch hit with metadata when overview is not present', async () => {
|
|
113
113
|
const { has } = await import('lodash-es');
|
|
114
114
|
has.mockReturnValue(false);
|
|
115
115
|
const hitWithFetchedMetadata = { ...mockHit, __overview: mockOverview };
|
|
116
|
-
|
|
116
|
+
mockGetRecord.mockResolvedValue(hitWithFetchedMetadata);
|
|
117
117
|
const { result } = renderHook(() => useMatchers());
|
|
118
118
|
const overview = await result.current.getMatchingOverview(mockHit);
|
|
119
119
|
expect(overview).toBe(mockOverview);
|
|
120
|
-
expect(
|
|
120
|
+
expect(mockGetRecord).toHaveBeenCalledWith('test-hit-id', true);
|
|
121
121
|
});
|
|
122
122
|
it('should handle getHit rejection gracefully', async () => {
|
|
123
123
|
const { has } = await import('lodash-es');
|
|
124
124
|
has.mockReturnValue(false);
|
|
125
|
-
|
|
125
|
+
mockGetRecord.mockRejectedValue(new Error('Failed to fetch hit'));
|
|
126
126
|
const { result } = renderHook(() => useMatchers());
|
|
127
127
|
await expect(result.current.getMatchingOverview(mockHit)).resolves.toBeNull();
|
|
128
|
-
expect(
|
|
128
|
+
expect(mockGetRecord).toHaveBeenCalledWith('test-hit-id', true);
|
|
129
129
|
});
|
|
130
130
|
});
|
|
131
131
|
describe('getMatchingDossiers', () => {
|
|
@@ -145,25 +145,25 @@ describe('useMatchers', () => {
|
|
|
145
145
|
const { result } = renderHook(() => useMatchers());
|
|
146
146
|
const dossiers = await result.current.getMatchingDossiers(mockHitWithMetadata);
|
|
147
147
|
expect(dossiers).toBe(mockDossiers);
|
|
148
|
-
expect(
|
|
148
|
+
expect(mockGetRecord).not.toHaveBeenCalled();
|
|
149
149
|
});
|
|
150
150
|
it('should fetch hit with metadata when dossiers are not present', async () => {
|
|
151
151
|
const { has } = await import('lodash-es');
|
|
152
152
|
has.mockReturnValue(false);
|
|
153
153
|
const hitWithFetchedMetadata = { ...mockHit, __dossiers: mockDossiers };
|
|
154
|
-
|
|
154
|
+
mockGetRecord.mockResolvedValue(hitWithFetchedMetadata);
|
|
155
155
|
const { result } = renderHook(() => useMatchers());
|
|
156
156
|
const dossiers = await result.current.getMatchingDossiers(mockHit);
|
|
157
157
|
expect(dossiers).toBe(mockDossiers);
|
|
158
|
-
expect(
|
|
158
|
+
expect(mockGetRecord).toHaveBeenCalledWith('test-hit-id', true);
|
|
159
159
|
});
|
|
160
160
|
it('should handle getHit rejection gracefully', async () => {
|
|
161
161
|
const { has } = await import('lodash-es');
|
|
162
162
|
has.mockReturnValue(false);
|
|
163
|
-
|
|
163
|
+
mockGetRecord.mockRejectedValue(new Error('Failed to fetch hit'));
|
|
164
164
|
const { result } = renderHook(() => useMatchers());
|
|
165
165
|
await expect(result.current.getMatchingDossiers(mockHit)).resolves.toEqual([]);
|
|
166
|
-
expect(
|
|
166
|
+
expect(mockGetRecord).toHaveBeenCalledWith('test-hit-id', true);
|
|
167
167
|
});
|
|
168
168
|
});
|
|
169
169
|
describe('integration tests', () => {
|
|
@@ -177,7 +177,7 @@ describe('useMatchers', () => {
|
|
|
177
177
|
...mockHit,
|
|
178
178
|
__template: mockTemplate
|
|
179
179
|
};
|
|
180
|
-
|
|
180
|
+
mockGetRecord.mockResolvedValue({
|
|
181
181
|
...mockHit,
|
|
182
182
|
__overview: mockOverview,
|
|
183
183
|
__dossiers: mockDossiers
|
|
@@ -200,7 +200,7 @@ describe('useMatchers', () => {
|
|
|
200
200
|
it('should handle empty or undefined metadata gracefully', async () => {
|
|
201
201
|
const { has } = await import('lodash-es');
|
|
202
202
|
has.mockReturnValue(false);
|
|
203
|
-
|
|
203
|
+
mockGetRecord.mockResolvedValue({
|
|
204
204
|
...mockHit,
|
|
205
205
|
__template: undefined,
|
|
206
206
|
__overview: null,
|
|
@@ -213,7 +213,7 @@ describe('useMatchers', () => {
|
|
|
213
213
|
expect(template).toBeUndefined();
|
|
214
214
|
expect(overview).toBeNull();
|
|
215
215
|
expect(dossiers).toEqual([]);
|
|
216
|
-
expect(
|
|
216
|
+
expect(mockGetRecord).toHaveBeenCalledTimes(3);
|
|
217
217
|
});
|
|
218
218
|
it('should maintain referential equality of returned functions', () => {
|
|
219
219
|
const { result, rerender } = renderHook(() => useMatchers());
|
|
@@ -5,23 +5,23 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { useLocation, useParams, useSearchParams } from 'react-router-dom';
|
|
6
6
|
import { useContextSelector } from 'use-context-selector';
|
|
7
7
|
import { AnalyticContext } from '../providers/AnalyticProvider';
|
|
8
|
-
import {
|
|
8
|
+
import { RecordContext } from '../providers/RecordProvider';
|
|
9
9
|
const useTitle = () => {
|
|
10
10
|
const { t } = useTranslation();
|
|
11
11
|
const location = useLocation();
|
|
12
12
|
const params = useParams();
|
|
13
13
|
const searchParams = useSearchParams()[0];
|
|
14
14
|
const sitemap = useMySitemap();
|
|
15
|
-
const { getAnalyticFromId } = useContext(AnalyticContext);
|
|
16
|
-
const hits = useContextSelector(
|
|
17
|
-
const getHit = useContextSelector(
|
|
15
|
+
const { getAnalyticFromId } = useContext(AnalyticContext) ?? {};
|
|
16
|
+
const hits = useContextSelector(RecordContext, ctx => ctx.records);
|
|
17
|
+
const getHit = useContextSelector(RecordContext, ctx => ctx.getRecord);
|
|
18
18
|
const setTitle = useCallback((title) => {
|
|
19
19
|
document.querySelector('title').innerHTML = title;
|
|
20
20
|
}, []);
|
|
21
21
|
const runChecks = useCallback(async () => {
|
|
22
22
|
const searchType = location.pathname.replace(/^\/(\w+)(\/.+)?$/, '$1').replace(/s$/, '');
|
|
23
23
|
if (searchType === 'analytic') {
|
|
24
|
-
if (params.id) {
|
|
24
|
+
if (params.id && getAnalyticFromId) {
|
|
25
25
|
const analytic = await getAnalyticFromId(params.id);
|
|
26
26
|
if (analytic) {
|
|
27
27
|
setTitle(`${t('route.analytics.view')} - ${analytic.name}`);
|
|
@@ -120,11 +120,11 @@ const FavouriteProvider = ({ children }) => {
|
|
|
120
120
|
(async () => {
|
|
121
121
|
const analyticElement = processAnalyticElement();
|
|
122
122
|
if (analyticElement) {
|
|
123
|
-
newElements.splice(
|
|
123
|
+
newElements.splice(2, 0, analyticElement);
|
|
124
124
|
}
|
|
125
125
|
const viewElement = await processViewElement();
|
|
126
126
|
if (viewElement) {
|
|
127
|
-
newElements.splice(
|
|
127
|
+
newElements.splice(2, 0, viewElement);
|
|
128
128
|
}
|
|
129
129
|
leftNav.setElements(newElements);
|
|
130
130
|
})();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FC, PropsWithChildren } from 'react';
|
|
2
|
+
export type SearchIndex = 'hit' | 'observable' | 'case';
|
|
2
3
|
export interface ParameterContextType {
|
|
3
4
|
selected?: string;
|
|
4
5
|
query?: string;
|
|
@@ -6,6 +7,7 @@ export interface ParameterContextType {
|
|
|
6
7
|
trackTotalHits: boolean;
|
|
7
8
|
sort?: string;
|
|
8
9
|
span?: string;
|
|
10
|
+
indexes?: SearchIndex[];
|
|
9
11
|
filters?: string[];
|
|
10
12
|
startDate?: string;
|
|
11
13
|
endDate?: string;
|
|
@@ -19,11 +21,16 @@ export interface ParameterContextType {
|
|
|
19
21
|
addFilter: (filter: string) => void;
|
|
20
22
|
removeFilter: (filter: string) => void;
|
|
21
23
|
setFilter: (index: number, filter: string) => void;
|
|
22
|
-
|
|
24
|
+
resetFilters: () => void;
|
|
25
|
+
addIndex: (index: SearchIndex) => void;
|
|
26
|
+
removeIndex: (index: SearchIndex) => void;
|
|
27
|
+
setIndex: (position: number, index: SearchIndex) => void;
|
|
28
|
+
setIndexes: (indexes: SearchIndex[]) => void;
|
|
29
|
+
resetIndexes: () => void;
|
|
23
30
|
addView: (view: string) => void;
|
|
24
31
|
removeView: (view: string) => void;
|
|
25
32
|
setView: (index: number, view: string) => void;
|
|
26
|
-
|
|
33
|
+
resetViews: () => void;
|
|
27
34
|
}
|
|
28
35
|
export declare const ParameterContext: import("use-context-selector").Context<ParameterContextType>;
|
|
29
36
|
/**
|