@cccsaurora/howler-ui 2.14.0-dev.264 → 2.14.0-dev.265
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.ts +3 -3
- package/api/action/index.ts +5 -5
- package/api/action/operations.ts +3 -3
- package/api/analytic/comments/index.ts +4 -4
- package/api/analytic/comments/react.ts +2 -2
- package/api/analytic/favourite.ts +2 -2
- package/api/analytic/index.ts +7 -7
- package/api/analytic/notebooks/index.ts +3 -3
- package/api/analytic/owner.ts +3 -3
- package/api/analytic/rules.ts +3 -3
- package/api/auth/apikey.ts +2 -2
- package/api/auth/index.ts +3 -3
- package/api/auth/login.ts +3 -3
- package/api/configs/index.ts +2 -2
- package/api/dossier/hit.ts +2 -2
- package/api/dossier/index.ts +2 -2
- package/api/help.ts +1 -1
- package/api/hit/assign.ts +3 -3
- package/api/hit/comments/index.ts +4 -4
- package/api/hit/comments/react.ts +2 -2
- package/api/hit/index.ts +7 -7
- package/api/hit/labels.ts +4 -4
- package/api/hit/overwrite.ts +3 -3
- package/api/hit/transition.ts +4 -4
- package/api/index.ts +18 -18
- package/api/notebook/environments.ts +2 -2
- package/api/notebook/index.ts +4 -4
- package/api/overview/index.ts +2 -2
- package/api/search/action.ts +4 -4
- package/api/search/analytic.ts +4 -4
- package/api/search/count/hit.ts +3 -3
- package/api/search/count/index.ts +3 -3
- package/api/search/dossier.ts +4 -4
- package/api/search/eql/hit.ts +4 -4
- package/api/search/facet/hit.ts +3 -3
- package/api/search/facet/index.ts +3 -3
- package/api/search/fields/hit.ts +3 -3
- package/api/search/fields/index.ts +4 -4
- package/api/search/fields/user.ts +4 -4
- package/api/search/grouped/hit.ts +4 -4
- package/api/search/grouped/index.ts +4 -4
- package/api/search/grouped/user.ts +4 -4
- package/api/search/histogram/hit.ts +3 -3
- package/api/search/histogram/index.ts +3 -3
- package/api/search/hit.ts +6 -6
- package/api/search/index.ts +14 -14
- package/api/search/overview.ts +4 -4
- package/api/search/sigma/hit.ts +4 -4
- package/api/search/template.ts +4 -4
- package/api/search/user.ts +4 -4
- package/api/search/view.ts +4 -4
- package/api/template/index.ts +2 -2
- package/api/user/avatar/index.ts +2 -2
- package/api/user/groups.ts +2 -2
- package/api/user/index.ts +5 -5
- package/api/user/whoami.ts +3 -3
- package/api/view/favourite.ts +2 -2
- package/api/view/index.ts +3 -3
- package/commons/components/app/AppConfigs.ts +2 -2
- package/commons/components/app/AppContexts.ts +5 -5
- package/commons/components/app/AppDefaults.ts +1 -1
- package/commons/components/app/AppNotificationService.ts +1 -1
- package/commons/components/app/AppProvider.tsx +14 -14
- package/commons/components/app/AppSearchService.ts +1 -1
- package/commons/components/app/AppSkeleton.tsx +3 -3
- package/commons/components/app/hooks/useApp.tsx +1 -1
- package/commons/components/app/hooks/useAppBanner.tsx +1 -1
- package/commons/components/app/hooks/useAppBar.tsx +1 -1
- package/commons/components/app/hooks/useAppBreadcrumbs.tsx +1 -1
- package/commons/components/app/hooks/useAppConfigs.tsx +2 -2
- package/commons/components/app/hooks/useAppLanguage.tsx +2 -2
- package/commons/components/app/hooks/useAppLayout.tsx +1 -1
- package/commons/components/app/hooks/useAppLeftNav.tsx +1 -1
- package/commons/components/app/hooks/useAppLogo.tsx +2 -2
- package/commons/components/app/hooks/useAppNotification.tsx +1 -1
- package/commons/components/app/hooks/useAppQuickSearch.tsx +1 -1
- package/commons/components/app/hooks/useAppSearchService.tsx +2 -2
- package/commons/components/app/hooks/useAppSitemap.tsx +3 -3
- package/commons/components/app/hooks/useAppSwitcher.tsx +1 -1
- package/commons/components/app/hooks/useAppTheme.tsx +1 -1
- package/commons/components/app/hooks/useAppUser.tsx +2 -2
- package/commons/components/app/providers/AppBarProvider.tsx +9 -9
- package/commons/components/app/providers/AppBreadcrumbsProvider.tsx +5 -5
- package/commons/components/app/providers/AppLayoutProvider.tsx +7 -7
- package/commons/components/app/providers/AppLeftNavProvider.tsx +5 -5
- package/commons/components/app/providers/AppNotificationProvider.tsx +1 -1
- package/commons/components/app/providers/AppQuickSearchProvider.tsx +6 -6
- package/commons/components/app/providers/AppSearchServiceProvider.tsx +3 -3
- package/commons/components/app/providers/AppSwitcherProvider.tsx +3 -3
- package/commons/components/app/providers/AppUserProvider.tsx +2 -2
- package/commons/components/breadcrumbs/BreadcrumbIcon.tsx +1 -1
- package/commons/components/breadcrumbs/BreadcrumbLastItem.tsx +2 -2
- package/commons/components/breadcrumbs/BreadcrumbLinkItem.tsx +2 -2
- package/commons/components/breadcrumbs/BreadcrumbList.tsx +3 -3
- package/commons/components/breadcrumbs/Breadcrumbs.tsx +2 -2
- package/commons/components/display/AppAvatar.tsx +1 -1
- package/commons/components/display/AppListEmpty.tsx +1 -1
- package/commons/components/display/AppToc.tsx +3 -3
- package/commons/components/display/hooks/useAppColor.tsx +1 -1
- package/commons/components/leftnav/LeftNavDrawer.tsx +4 -4
- package/commons/components/leftnav/LeftNavGroup.tsx +3 -3
- package/commons/components/leftnav/LeftNavItem.tsx +2 -2
- package/commons/components/notification/Notification.tsx +4 -4
- package/commons/components/notification/elements/NotificationCloseButton.tsx +1 -1
- package/commons/components/notification/elements/NotificationContainer.tsx +5 -5
- package/commons/components/notification/elements/NotificationEndOfPage.tsx +1 -1
- package/commons/components/notification/elements/NotificationItems.tsx +2 -2
- package/commons/components/notification/elements/item/NotificationItem.tsx +7 -7
- package/commons/components/notification/elements/item/NotificationItemAuthor.tsx +1 -1
- package/commons/components/notification/elements/item/NotificationItemContent.tsx +1 -1
- package/commons/components/notification/elements/item/NotificationItemDate.tsx +1 -1
- package/commons/components/notification/elements/item/NotificationItemTitle.tsx +1 -1
- package/commons/components/pages/PageContent.tsx +1 -1
- package/commons/components/pages/PageFullScreen.tsx +3 -3
- package/commons/components/pages/PageHeader.tsx +1 -1
- package/commons/components/search/AppSearch.tsx +4 -4
- package/commons/components/search/AppSearchResult.tsx +4 -4
- package/commons/components/topnav/AppBar.tsx +9 -9
- package/commons/components/topnav/AppName.tsx +1 -1
- package/commons/components/topnav/AppSwitcher.tsx +1 -1
- package/commons/components/topnav/Notifications.tsx +2 -2
- package/commons/components/topnav/ThemeSelection.tsx +2 -2
- package/commons/components/topnav/ThemeSelectionIcon.tsx +2 -2
- package/commons/components/topnav/UserProfile.tsx +3 -3
- package/commons/components/utils/hooks/useLocalStorageItem.tsx +1 -1
- package/commons/components/utils/hooks/useThemeBuilder.tsx +2 -2
- package/components/app/App.tsx +57 -57
- package/components/app/AppContainer.tsx +1 -1
- package/components/app/drawers/ApiKeyDrawer.tsx +5 -5
- package/components/app/drawers/AssignUserDrawer.tsx +6 -6
- package/components/app/drawers/ViewGroupsDrawer.tsx +1 -1
- package/components/app/hooks/useMatchers.tsx +2 -2
- package/components/app/hooks/useTitle.tsx +1 -1
- package/components/app/providers/AnalyticProvider.tsx +5 -5
- package/components/app/providers/ApiConfigProvider.tsx +1 -1
- package/components/app/providers/AppDrawerProvider.tsx +1 -1
- package/components/app/providers/AvatarProvider.tsx +2 -2
- package/components/app/providers/CustomPluginProvider.tsx +1 -1
- package/components/app/providers/FavouritesProvider.tsx +3 -3
- package/components/app/providers/FieldProvider.tsx +3 -3
- package/components/app/providers/HitProvider.tsx +5 -5
- package/components/app/providers/HitSearchProvider.tsx +12 -12
- package/components/app/providers/LocalStorageProvider.tsx +2 -2
- package/components/app/providers/OverviewProvider.tsx +3 -3
- package/components/app/providers/ParameterProvider.tsx +1 -1
- package/components/app/providers/SocketProvider.tsx +5 -5
- package/components/app/providers/UserListProvider.tsx +3 -3
- package/components/app/providers/ViewProvider.tsx +7 -7
- package/components/elements/Comment.tsx +7 -7
- package/components/elements/EditRow.tsx +1 -1
- package/components/elements/PluginChip.tsx +1 -1
- package/components/elements/PluginTypography.tsx +1 -1
- package/components/elements/ThemedEditor.tsx +3 -3
- package/components/elements/UserList.tsx +1 -1
- package/components/elements/addons/layout/FlexPort.tsx +1 -1
- package/components/elements/addons/layout/FlexVertical.tsx +2 -2
- package/components/elements/addons/layout/vsbox/VSBox.tsx +1 -1
- package/components/elements/addons/lists/TuiList.tsx +1 -1
- package/components/elements/addons/lists/TuiListBase.tsx +2 -2
- package/components/elements/addons/lists/hooks/useTuiListKeyboard.tsx +2 -2
- package/components/elements/addons/lists/table/TuiTable.tsx +1 -1
- package/components/elements/addons/lists/table/TuiTableBody.tsx +1 -1
- package/components/elements/addons/lists/table/TuiTableHead.tsx +1 -1
- package/components/elements/addons/search/phrase/Phrase.tsx +1 -1
- package/components/elements/display/ActionButton.tsx +4 -4
- package/components/elements/display/Classification.tsx +1 -1
- package/components/elements/display/HandlebarsMarkdown.tsx +2 -2
- package/components/elements/display/HowlerAvatar.tsx +3 -3
- package/components/elements/display/HowlerAvatarHeader.tsx +1 -1
- package/components/elements/display/ItemManager.tsx +7 -7
- package/components/elements/display/Markdown.tsx +1 -1
- package/components/elements/display/Modal.tsx +1 -1
- package/components/elements/display/UserPageWrapper.tsx +2 -2
- package/components/elements/display/features/DevelopmentBanner.tsx +2 -2
- package/components/elements/display/features/DevelopmentIcon.tsx +2 -2
- package/components/elements/display/handlebars/helpers.tsx +4 -4
- package/components/elements/display/icons/BundleButton.tsx +1 -1
- package/components/elements/display/icons/SocketBadge.tsx +2 -2
- package/components/elements/display/json/JSONViewer.tsx +7 -7
- package/components/elements/display/modals/ConfirmDeleteModal.tsx +1 -1
- package/components/elements/display/modals/ConfirmNotebookModal.tsx +1 -1
- package/components/elements/display/modals/CreateActionModal.tsx +3 -3
- package/components/elements/display/modals/RationaleModal.tsx +2 -2
- package/components/elements/hit/HitActions.tsx +13 -13
- package/components/elements/hit/HitBanner.tsx +6 -6
- package/components/elements/hit/HitBannerTooltip.tsx +1 -1
- package/components/elements/hit/HitCard.tsx +1 -1
- package/components/elements/hit/HitComments.tsx +11 -11
- package/components/elements/hit/HitDetails.tsx +2 -2
- package/components/elements/hit/HitLabels.tsx +6 -6
- package/components/elements/hit/HitNotebooks.tsx +8 -8
- package/components/elements/hit/HitOutline.tsx +4 -4
- package/components/elements/hit/HitOverview.tsx +4 -4
- package/components/elements/hit/HitQuickSearch.tsx +4 -4
- package/components/elements/hit/HitRelated.tsx +1 -1
- package/components/elements/hit/HitSummary.tsx +13 -13
- package/components/elements/hit/HitWorklog.tsx +7 -7
- package/components/elements/hit/actions/DropdownActions.tsx +1 -1
- package/components/elements/hit/aggregate/HitGraph.tsx +8 -8
- package/components/elements/hit/elements/Assigned.tsx +4 -4
- package/components/elements/hit/elements/EscalationChip.tsx +2 -2
- package/components/elements/hit/elements/HitTimestamp.tsx +3 -3
- package/components/elements/hit/outlines/DefaultOutline.tsx +4 -4
- package/components/elements/hit/outlines/al/AssemblyLineRules.tsx +2 -2
- package/components/elements/hit/related/PivotLink.tsx +3 -3
- package/components/elements/hit/related/RelatedIcon.tsx +2 -2
- package/components/elements/hit/related/RelatedLink.tsx +1 -1
- package/components/elements/view/ViewTitle.tsx +1 -1
- package/components/hooks/useHitActions.tsx +12 -12
- package/components/hooks/useHitSelection.tsx +7 -7
- package/components/hooks/useMyApi.tsx +2 -2
- package/components/hooks/useMyLocalStorage.ts +5 -5
- package/components/hooks/useMyPreferences.tsx +6 -6
- package/components/hooks/useMySearch.tsx +7 -7
- package/components/hooks/useMySitemap.tsx +2 -2
- package/components/hooks/useMyTheme.tsx +1 -1
- package/components/hooks/useMyUser.tsx +2 -2
- package/components/hooks/useMyUserFunctions.tsx +8 -8
- package/components/hooks/useMyUserList.tsx +1 -1
- package/components/hooks/useMyUtils.tsx +1 -1
- package/components/logins/Login.tsx +4 -4
- package/components/logins/auth/OAuthLogin.tsx +3 -3
- package/components/logins/hooks/useLogin.tsx +11 -11
- package/components/routes/404.tsx +1 -1
- package/components/routes/ErrorOccured.tsx +2 -2
- package/components/routes/Logout.tsx +3 -3
- package/components/routes/action/edit/ActionEditor.tsx +13 -13
- package/components/routes/action/shared/ActionReportDisplay.tsx +2 -2
- package/components/routes/action/shared/OperationEntry.tsx +4 -4
- package/components/routes/action/shared/OperationStep.tsx +8 -8
- package/components/routes/action/useMyActionFunctions.tsx +9 -9
- package/components/routes/action/view/ActionDetails.tsx +12 -12
- package/components/routes/action/view/ActionSearch.tsx +14 -14
- package/components/routes/action/view/Integrations.tsx +2 -2
- package/components/routes/admin/users/UserEditor.tsx +8 -8
- package/components/routes/admin/users/UserSearch.tsx +19 -19
- package/components/routes/advanced/QueryBuilder.tsx +14 -14
- package/components/routes/advanced/QueryEditor.tsx +3 -3
- package/components/routes/advanced/RuleModal.tsx +10 -10
- package/components/routes/advanced/eqlCompletionProvider.ts +1 -1
- package/components/routes/advanced/historyCompletionProvider.ts +2 -2
- package/components/routes/advanced/luceneCompletionProvider.ts +3 -3
- package/components/routes/advanced/yamlCompletionProvider.ts +1 -1
- package/components/routes/analytics/AnalyticComments.tsx +9 -9
- package/components/routes/analytics/AnalyticDetails.tsx +12 -12
- package/components/routes/analytics/AnalyticHitComments.tsx +8 -8
- package/components/routes/analytics/AnalyticNotebooks.tsx +9 -9
- package/components/routes/analytics/AnalyticOverview.tsx +6 -6
- package/components/routes/analytics/AnalyticOverviews.tsx +3 -3
- package/components/routes/analytics/AnalyticSearch.tsx +15 -15
- package/components/routes/analytics/AnalyticTemplates.tsx +5 -5
- package/components/routes/analytics/RuleView.tsx +4 -4
- package/components/routes/analytics/TriageSettings.tsx +6 -6
- package/components/routes/analytics/widgets/Assessment.tsx +5 -5
- package/components/routes/analytics/widgets/Created.tsx +4 -4
- package/components/routes/analytics/widgets/Detection.tsx +2 -2
- package/components/routes/analytics/widgets/Escalation.tsx +5 -5
- package/components/routes/analytics/widgets/Stacked.tsx +3 -3
- package/components/routes/analytics/widgets/Status.tsx +2 -2
- package/components/routes/dossiers/DossierCard.tsx +3 -3
- package/components/routes/dossiers/DossierEditor.tsx +5 -5
- package/components/routes/dossiers/Dossiers.tsx +10 -10
- package/components/routes/dossiers/LeadEditor.tsx +3 -3
- package/components/routes/dossiers/LeadForm.tsx +1 -1
- package/components/routes/dossiers/PivotForm.tsx +4 -4
- package/components/routes/help/ActionDocumentation.tsx +3 -3
- package/components/routes/help/ActionIntroductionDocumentation.tsx +7 -7
- package/components/routes/help/ApiDocumentation.tsx +8 -8
- package/components/routes/help/AuthDocumentation.tsx +3 -3
- package/components/routes/help/BundleDocumentation.tsx +1 -1
- package/components/routes/help/ClientDocumentation.tsx +3 -3
- package/components/routes/help/Help.tsx +5 -5
- package/components/routes/help/HitBannerDocumentation.tsx +5 -5
- package/components/routes/help/HitDocumentation.tsx +2 -2
- package/components/routes/help/HitLabelsDocumentation.tsx +1 -1
- package/components/routes/help/HitLinksDocumentation.tsx +2 -2
- package/components/routes/help/HitSchemaDocumentation.tsx +3 -3
- package/components/routes/help/NotebookDocumentation.tsx +3 -3
- package/components/routes/help/OverviewDocumentation.tsx +3 -3
- package/components/routes/help/RetentionDocumentation.tsx +7 -7
- package/components/routes/help/SearchDocumentation.tsx +6 -6
- package/components/routes/help/TemplateDocumentation.tsx +5 -5
- package/components/routes/help/ViewDocumentation.tsx +3 -3
- package/components/routes/hits/search/BundleParentMenu.tsx +5 -5
- package/components/routes/hits/search/BundleScroller.tsx +1 -1
- package/components/routes/hits/search/CustomSort.tsx +2 -2
- package/components/routes/hits/search/HitBrowser.tsx +10 -10
- package/components/routes/hits/search/HitContextMenu.tsx +11 -11
- package/components/routes/hits/search/HitQuery.tsx +5 -5
- package/components/routes/hits/search/InformationPane.tsx +35 -35
- package/components/routes/hits/search/SearchPane.tsx +21 -21
- package/components/routes/hits/search/ViewLink.tsx +3 -3
- package/components/routes/hits/search/grid/AddColumnModal.tsx +3 -3
- package/components/routes/hits/search/grid/ColumnHeader.tsx +2 -2
- package/components/routes/hits/search/grid/EnhancedCell.tsx +1 -1
- package/components/routes/hits/search/grid/HitGrid.tsx +12 -12
- package/components/routes/hits/search/grid/HitRow.tsx +7 -7
- package/components/routes/hits/search/shared/CustomSpan.tsx +1 -1
- package/components/routes/hits/search/shared/HitFilter.tsx +4 -4
- package/components/routes/hits/search/shared/HitSort.tsx +2 -2
- package/components/routes/hits/search/shared/QuerySettings.tsx +2 -2
- package/components/routes/hits/search/shared/SearchSpan.tsx +3 -3
- package/components/routes/hits/view/HitViewer.tsx +28 -28
- package/components/routes/hits/view/LeadRenderer.tsx +3 -3
- package/components/routes/home/AddNewCard.tsx +5 -5
- package/components/routes/home/AnalyticCard.tsx +3 -3
- package/components/routes/home/ViewCard.tsx +7 -7
- package/components/routes/home/index.tsx +9 -9
- package/components/routes/overviews/OverviewCard.tsx +3 -3
- package/components/routes/overviews/OverviewEditor.tsx +2 -2
- package/components/routes/overviews/OverviewViewer.tsx +13 -13
- package/components/routes/overviews/Overviews.tsx +10 -10
- package/components/routes/overviews/startingTemplate.ts +1 -1
- package/components/routes/settings/AdminSection.tsx +1 -1
- package/components/routes/settings/LocalSection.tsx +4 -4
- package/components/routes/settings/ProfileSection.tsx +4 -4
- package/components/routes/settings/SecuritySection.tsx +5 -5
- package/components/routes/settings/Settings.tsx +6 -6
- package/components/routes/templates/TemplateCard.tsx +1 -1
- package/components/routes/templates/TemplateEditor.tsx +4 -4
- package/components/routes/templates/TemplateViewer.tsx +10 -10
- package/components/routes/templates/Templates.tsx +11 -11
- package/components/routes/views/ViewComposer.tsx +21 -21
- package/components/routes/views/Views.tsx +16 -16
- package/index.tsx +3 -3
- package/models/entities/HowlerUser.d.ts +1 -1
- package/models/socket/HitUpdate.d.ts +1 -1
- package/package.json +4 -32
- package/plugins/HowlerPlugin.ts +12 -12
- package/plugins/store.ts +1 -1
- package/rest/AxiosClient.ts +3 -3
- package/rest/FetchClient.ts +2 -2
- package/rest/index.ts +1 -1
- package/utils/actionUtils.ts +2 -2
- package/utils/hitFunctions.ts +1 -1
- package/utils/localStorage.ts +1 -1
- package/utils/sessionStorage.ts +1 -1
- package/utils/socketUtils.ts +2 -2
- package/components/app/hooks/useMatchers.test.ts +0 -328
- package/components/app/providers/ViewProvider.test.tsx +0 -244
- package/tests/MockLocalStorage.ts +0 -46
- package/tests/server-handlers.ts +0 -114
- package/tests/server.ts +0 -6
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import type { RenderHookResult } from '@testing-library/react';
|
|
2
|
-
import { act, renderHook, waitFor } from '@testing-library/react';
|
|
3
|
-
import { hget, hpost, hput } from 'api';
|
|
4
|
-
import MockLocalStorage from 'tests/MockLocalStorage';
|
|
5
|
-
import { MOCK_RESPONSES } from 'tests/server-handlers';
|
|
6
|
-
import { useContextSelector } from 'use-context-selector';
|
|
7
|
-
import { MY_LOCAL_STORAGE_PREFIX, StorageKey } from 'utils/constants';
|
|
8
|
-
import ViewProvider, { ViewContext, type ViewContextType } from './ViewProvider';
|
|
9
|
-
|
|
10
|
-
let mockUser = {
|
|
11
|
-
favourite_views: ['favourited_view_id']
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
vi.mock('api', { spy: true });
|
|
15
|
-
vi.mock('react-router-dom', () => ({
|
|
16
|
-
useLocation: vi.fn(() => ({ pathname: '/views/searched_view_id' })),
|
|
17
|
-
useParams: vi.fn(() => ({ id: 'searched_view_id' }))
|
|
18
|
-
}));
|
|
19
|
-
vi.mock('commons/components/app/hooks', () => ({
|
|
20
|
-
useAppUser: () => ({
|
|
21
|
-
user: mockUser,
|
|
22
|
-
setUser: _user => (mockUser = _user)
|
|
23
|
-
})
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
const mockLocalStorage: Storage = new MockLocalStorage() as any;
|
|
27
|
-
|
|
28
|
-
// Replace localStorage in global scope
|
|
29
|
-
Object.defineProperty(window, 'localStorage', {
|
|
30
|
-
value: mockLocalStorage,
|
|
31
|
-
writable: true
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const Wrapper = ({ children }) => {
|
|
35
|
-
return <ViewProvider>{children}</ViewProvider>;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
beforeEach(() => {
|
|
39
|
-
mockLocalStorage.clear();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('ViewContext', () => {
|
|
43
|
-
it('should fetch the defaultView on initialization', async () => {
|
|
44
|
-
mockLocalStorage.setItem(
|
|
45
|
-
`${MY_LOCAL_STORAGE_PREFIX}.${StorageKey.DEFAULT_VIEW}`,
|
|
46
|
-
JSON.stringify('searched_view_id')
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
let hook = await act(async () =>
|
|
50
|
-
renderHook(() => useContextSelector(ViewContext, ctx => ctx.views), { wrapper: Wrapper })
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
await waitFor(() => expect(hook.result.current.searched_view_id).not.toBeFalsy());
|
|
54
|
-
|
|
55
|
-
expect(hook.result.current.searched_view_id).toEqual(MOCK_RESPONSES['/api/v1/search/view'].items[0]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('should allow the user to add and remove a favourite view', async () => {
|
|
59
|
-
interface HookResult {
|
|
60
|
-
addFavourite: ViewContextType['addFavourite'];
|
|
61
|
-
removeFavourite: ViewContextType['removeFavourite'];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const hook: RenderHookResult<HookResult, any> = await act(async () => {
|
|
65
|
-
return renderHook(
|
|
66
|
-
() =>
|
|
67
|
-
useContextSelector(ViewContext, ctx => ({
|
|
68
|
-
addFavourite: ctx.addFavourite,
|
|
69
|
-
removeFavourite: ctx.removeFavourite
|
|
70
|
-
})),
|
|
71
|
-
{ wrapper: Wrapper }
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
await hook.result.current.addFavourite('example_view_id');
|
|
76
|
-
|
|
77
|
-
expect(mockUser.favourite_views).toEqual(['favourited_view_id', 'example_view_id']);
|
|
78
|
-
|
|
79
|
-
await hook.result.current.removeFavourite('example_view_id');
|
|
80
|
-
|
|
81
|
-
expect(mockUser.favourite_views).toEqual(['favourited_view_id']);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('should allow the user to add and remove views', async () => {
|
|
85
|
-
interface HookResult {
|
|
86
|
-
addView: ViewContextType['addView'];
|
|
87
|
-
removeView: ViewContextType['removeView'];
|
|
88
|
-
views: ViewContextType['views'];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const hook: RenderHookResult<HookResult, any> = await act(async () => {
|
|
92
|
-
return renderHook(
|
|
93
|
-
() =>
|
|
94
|
-
useContextSelector(ViewContext, ctx => ({
|
|
95
|
-
addView: ctx.addView,
|
|
96
|
-
removeView: ctx.removeView,
|
|
97
|
-
views: ctx.views
|
|
98
|
-
})),
|
|
99
|
-
{ wrapper: Wrapper }
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const result = await act(async () =>
|
|
104
|
-
hook.result.current.addView({
|
|
105
|
-
owner: 'user',
|
|
106
|
-
settings: {
|
|
107
|
-
advance_on_triage: false
|
|
108
|
-
},
|
|
109
|
-
view_id: 'example_created_view',
|
|
110
|
-
query: 'howler.id:*',
|
|
111
|
-
sort: 'event.created desc',
|
|
112
|
-
title: 'Example View',
|
|
113
|
-
type: 'personal',
|
|
114
|
-
span: 'date.range.1.month'
|
|
115
|
-
})
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
hook.rerender();
|
|
119
|
-
|
|
120
|
-
expect(hook.result.current.views[result.view_id]).toEqual(result);
|
|
121
|
-
|
|
122
|
-
await act(async () => hook.result.current.removeView(result.view_id));
|
|
123
|
-
|
|
124
|
-
hook.rerender();
|
|
125
|
-
|
|
126
|
-
expect(hook.result.current.views[result.view_id]).toBeFalsy();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe('fetchViews', () => {
|
|
130
|
-
let hook: RenderHookResult<ViewContextType['fetchViews'], any>;
|
|
131
|
-
beforeEach(async () => {
|
|
132
|
-
hook = await act(async () => {
|
|
133
|
-
return renderHook(() => useContextSelector(ViewContext, ctx => ctx.fetchViews), { wrapper: Wrapper });
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
vi.mocked(hpost).mockClear();
|
|
137
|
-
vi.mocked(hget).mockClear();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('Should fetch all views when no ids are provided', async () => {
|
|
141
|
-
const result = await act(async () => hook.result.current());
|
|
142
|
-
|
|
143
|
-
expect(result.length).toBe(2);
|
|
144
|
-
expect(result[0].view_id).toBe('example_view_id');
|
|
145
|
-
expect(result[1].view_id).toBe('another_view_id');
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('Should search for specified views when ids are provided', async () => {
|
|
149
|
-
const result = await act(async () => hook.result.current(['searched_view_id']));
|
|
150
|
-
|
|
151
|
-
expect(hpost).toHaveBeenCalledOnce();
|
|
152
|
-
expect(hpost).toBeCalledWith('/api/v1/search/view', {
|
|
153
|
-
query: 'view_id:(searched_view_id)',
|
|
154
|
-
rows: 1,
|
|
155
|
-
sort: 'title asc'
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
expect(result).toEqual(MOCK_RESPONSES['/api/v1/search/view'].items);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('Should search only for new views when ids are provided', async () => {
|
|
162
|
-
await act(async () => hook.result.current(['searched_view_id']));
|
|
163
|
-
|
|
164
|
-
expect(hpost).toHaveBeenCalledOnce();
|
|
165
|
-
expect(hpost).toBeCalledWith('/api/v1/search/view', {
|
|
166
|
-
query: 'view_id:(searched_view_id)',
|
|
167
|
-
rows: 1,
|
|
168
|
-
sort: 'title asc'
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
vi.mocked(hpost).mockClear();
|
|
172
|
-
await act(async () => hook.result.current(['searched_view_id', 'searched_view_id_2']));
|
|
173
|
-
|
|
174
|
-
expect(hpost).toHaveBeenCalledOnce();
|
|
175
|
-
expect(hpost).toBeCalledWith('/api/v1/search/view', {
|
|
176
|
-
query: 'view_id:(searched_view_id_2)',
|
|
177
|
-
rows: 1,
|
|
178
|
-
sort: 'title asc'
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('Should provide cached instances as a response when the same views are requested', async () => {
|
|
183
|
-
let result = await act(async () => hook.result.current(['searched_view_id']));
|
|
184
|
-
|
|
185
|
-
expect(result).toEqual(MOCK_RESPONSES['/api/v1/search/view'].items);
|
|
186
|
-
|
|
187
|
-
result = await act(async () => hook.result.current(['searched_view_id']));
|
|
188
|
-
|
|
189
|
-
expect(result).toEqual(MOCK_RESPONSES['/api/v1/search/view'].items);
|
|
190
|
-
|
|
191
|
-
expect(hpost).toHaveBeenCalledOnce();
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe('getCurrentView', () => {
|
|
196
|
-
let hook: RenderHookResult<ViewContextType['getCurrentView'], any>;
|
|
197
|
-
beforeEach(async () => {
|
|
198
|
-
hook = await act(async () => {
|
|
199
|
-
return renderHook(() => useContextSelector(ViewContext, ctx => ctx.getCurrentView), { wrapper: Wrapper });
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('should allow the user to fetch their current view based on the location', async () => {
|
|
204
|
-
// lazy load should return nothing
|
|
205
|
-
await expect(hook.result.current({ lazy: true })).resolves.toBeFalsy();
|
|
206
|
-
|
|
207
|
-
const result = await act(async () => hook.result.current());
|
|
208
|
-
|
|
209
|
-
expect(result).toEqual(MOCK_RESPONSES['/api/v1/search/view'].items[0]);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('should allow the user to fetch their current view based on the view ID', async () => {
|
|
213
|
-
// lazy load should return nothing
|
|
214
|
-
await expect(hook.result.current({ lazy: true })).resolves.toBeFalsy();
|
|
215
|
-
|
|
216
|
-
const result = await act(async () => hook.result.current({ viewId: 'searched_view_id' }));
|
|
217
|
-
|
|
218
|
-
expect(result).toEqual(MOCK_RESPONSES['/api/v1/search/view'].items[0]);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
describe('editView', () => {
|
|
223
|
-
let hook: RenderHookResult<ViewContextType['editView'], any>;
|
|
224
|
-
beforeAll(async () => {
|
|
225
|
-
hook = await act(async () => {
|
|
226
|
-
return renderHook(() => useContextSelector(ViewContext, ctx => ctx.editView), { wrapper: Wrapper });
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
beforeEach(() => {
|
|
231
|
-
vi.mocked(hput).mockClear();
|
|
232
|
-
vi.mocked(hpost).mockClear();
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('should allow users to edit views', async () => {
|
|
236
|
-
const result = await act(async () => hook.result.current('example_view_id', { query: 'howler.id:*' }));
|
|
237
|
-
|
|
238
|
-
expect(hput).toHaveBeenCalledOnce();
|
|
239
|
-
expect(hput).toBeCalledWith('/api/v1/view/example_view_id', { query: 'howler.id:*' });
|
|
240
|
-
|
|
241
|
-
expect(result).toEqual(MOCK_RESPONSES['/api/v1/view/example_view_id']);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export default class MockLocalStorage {
|
|
2
|
-
constructor() {
|
|
3
|
-
Object.defineProperty(this, 'getItem', {
|
|
4
|
-
enumerable: false,
|
|
5
|
-
value: vi.fn(key => (this[key] !== undefined ? this[key] : null))
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(this, 'setItem', {
|
|
8
|
-
enumerable: false,
|
|
9
|
-
// not mentioned in the spec, but we must always coerce to a string
|
|
10
|
-
value: vi.fn((key, val) => {
|
|
11
|
-
this[key] = `${val}`;
|
|
12
|
-
})
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, 'removeItem', {
|
|
15
|
-
enumerable: false,
|
|
16
|
-
value: vi.fn(key => {
|
|
17
|
-
delete this[key];
|
|
18
|
-
})
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, 'clear', {
|
|
21
|
-
enumerable: false,
|
|
22
|
-
value: vi.fn(() => {
|
|
23
|
-
Object.keys(this).map(key => delete this[key]);
|
|
24
|
-
})
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(this, 'toString', {
|
|
27
|
-
enumerable: false,
|
|
28
|
-
value: vi.fn(() => {
|
|
29
|
-
return '[object Storage]';
|
|
30
|
-
})
|
|
31
|
-
});
|
|
32
|
-
Object.defineProperty(this, 'key', {
|
|
33
|
-
enumerable: false,
|
|
34
|
-
value: vi.fn(idx => Object.keys(this)[idx] || null)
|
|
35
|
-
});
|
|
36
|
-
} // end constructor
|
|
37
|
-
|
|
38
|
-
get length() {
|
|
39
|
-
return Object.keys(this).length;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// for backwards compatibility
|
|
43
|
-
get __STORE__() {
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
}
|
package/tests/server-handlers.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { http, HttpResponse } from 'msw';
|
|
2
|
-
|
|
3
|
-
export const MOCK_RESPONSES: { [path: string]: any } = {
|
|
4
|
-
'/api/v1/view/example_view_id': {
|
|
5
|
-
owner: 'user',
|
|
6
|
-
settings: {
|
|
7
|
-
advance_on_triage: false
|
|
8
|
-
},
|
|
9
|
-
view_id: 'example_view_id',
|
|
10
|
-
query: 'howler.id:*',
|
|
11
|
-
sort: 'event.created desc',
|
|
12
|
-
title: 'Example View',
|
|
13
|
-
type: 'personal',
|
|
14
|
-
span: 'date.range.1.month'
|
|
15
|
-
},
|
|
16
|
-
'/api/v1/search/view': {
|
|
17
|
-
items: [
|
|
18
|
-
{
|
|
19
|
-
owner: 'user',
|
|
20
|
-
settings: {
|
|
21
|
-
advance_on_triage: false
|
|
22
|
-
},
|
|
23
|
-
view_id: 'searched_view_id',
|
|
24
|
-
query: 'howler.id:searched',
|
|
25
|
-
sort: 'event.created desc',
|
|
26
|
-
title: 'Searched View',
|
|
27
|
-
type: 'personal',
|
|
28
|
-
span: 'date.range.1.month'
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
total: 1,
|
|
32
|
-
rows: 1
|
|
33
|
-
},
|
|
34
|
-
'/api/v1/view/new_view_id': {
|
|
35
|
-
owner: 'user',
|
|
36
|
-
settings: {
|
|
37
|
-
advance_on_triage: false
|
|
38
|
-
},
|
|
39
|
-
view_id: 'new_view_id',
|
|
40
|
-
query: 'howler.id:new',
|
|
41
|
-
sort: 'event.created desc',
|
|
42
|
-
title: 'New View',
|
|
43
|
-
type: 'personal',
|
|
44
|
-
span: 'date.range.1.month'
|
|
45
|
-
},
|
|
46
|
-
'/api/v1/view/:view_id/favourite': { success: true }
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const handlers = [
|
|
50
|
-
...Object.entries(MOCK_RESPONSES).map(([path, data]) =>
|
|
51
|
-
http.all(path, async () => HttpResponse.json({ api_response: data }))
|
|
52
|
-
),
|
|
53
|
-
http.post('/api/v1/view', async () =>
|
|
54
|
-
HttpResponse.json(
|
|
55
|
-
{
|
|
56
|
-
api_response: {
|
|
57
|
-
owner: 'user',
|
|
58
|
-
settings: {
|
|
59
|
-
advance_on_triage: false
|
|
60
|
-
},
|
|
61
|
-
view_id: 'example_created_view',
|
|
62
|
-
query: 'howler.id:*',
|
|
63
|
-
sort: 'event.created desc',
|
|
64
|
-
title: 'Example View',
|
|
65
|
-
type: 'personal',
|
|
66
|
-
span: 'date.range.1.month'
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
{ status: 201 }
|
|
70
|
-
)
|
|
71
|
-
),
|
|
72
|
-
http.delete('/api/v1/view/:view_id', async () =>
|
|
73
|
-
HttpResponse.json(
|
|
74
|
-
{
|
|
75
|
-
api_response: {
|
|
76
|
-
success: true
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
{ status: 204 }
|
|
80
|
-
)
|
|
81
|
-
),
|
|
82
|
-
http.get('/api/v1/view', async () =>
|
|
83
|
-
HttpResponse.json({
|
|
84
|
-
api_response: [
|
|
85
|
-
{
|
|
86
|
-
owner: 'user',
|
|
87
|
-
settings: {
|
|
88
|
-
advance_on_triage: false
|
|
89
|
-
},
|
|
90
|
-
view_id: 'example_view_id',
|
|
91
|
-
query: 'howler.id:*',
|
|
92
|
-
sort: 'event.created desc',
|
|
93
|
-
title: 'Example View',
|
|
94
|
-
type: 'personal',
|
|
95
|
-
span: 'date.range.1.month'
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
owner: 'user',
|
|
99
|
-
settings: {
|
|
100
|
-
advance_on_triage: true
|
|
101
|
-
},
|
|
102
|
-
view_id: 'another_view_id',
|
|
103
|
-
query: 'howler.status:open',
|
|
104
|
-
sort: 'event.created asc',
|
|
105
|
-
title: 'Another View',
|
|
106
|
-
type: 'global',
|
|
107
|
-
span: 'date.range.1.week'
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
})
|
|
111
|
-
)
|
|
112
|
-
];
|
|
113
|
-
|
|
114
|
-
export { handlers };
|