@@ -15,7 +15,6 @@ import { CASE_VIEW_PAGE_TABS } from '../../../common/types';
1515import { caseData , caseViewProps } from './mocks' ;
1616import type { CaseViewPageProps } from './types' ;
1717import { useCasesTitleBreadcrumbs } from '../use_breadcrumbs' ;
18- import { toUnifiedAttachmentType } from '../../../common/utils/attachments/migration_utils' ;
1918import { UnifiedAttachmentTypeRegistry } from '../../client/attachment_framework/unified_attachment_registry' ;
2019
2120jest . mock ( '../../common/navigation/hooks' ) ;
@@ -31,14 +30,6 @@ jest.mock(
3130 } ) ,
3231 { virtual : true }
3332) ;
34- jest . mock ( '../../../common/utils/attachments/migration_utils' , ( ) => {
35- const actual = jest . requireActual ( '../../../common/utils/attachments/migration_utils' ) ;
36-
37- return {
38- ...actual ,
39- toUnifiedAttachmentType : jest . fn ( actual . toUnifiedAttachmentType ) ,
40- } ;
41- } ) ;
4233
4334jest . mock ( '../header_page' , ( ) => ( {
4435 HeaderPage : jest . fn ( ( ) => < div data-test-subj = "test-case-view-header" > { 'Case view header' } </ div > ) ,
@@ -56,9 +47,9 @@ jest.mock('./components/case_view_activity', () => ({
5647 ) ) ,
5748} ) ) ;
5849
59- jest . mock ( './components/case_view_observables ' , ( ) => ( {
60- CaseViewObservables : jest . fn ( ( ) => (
61- < div data-test-subj = "test-case-view-observables " > { 'Case view observables ' } </ div >
50+ jest . mock ( './components/case_view_attachments ' , ( ) => ( {
51+ CaseViewAttachments : jest . fn ( ( ) => (
52+ < div data-test-subj = "test-case-view-attachments " > { 'Case view attachments ' } </ div >
6253 ) ) ,
6354} ) ) ;
6455
@@ -70,9 +61,6 @@ jest.mock('./components/case_view_similar_cases', () => ({
7061
7162const useUrlParamsMock = useUrlParams as jest . Mock ;
7263const useCasesTitleBreadcrumbsMock = useCasesTitleBreadcrumbs as jest . Mock ;
73- const toUnifiedAttachmentTypeMock = toUnifiedAttachmentType as jest . MockedFunction <
74- typeof toUnifiedAttachmentType
75- > ;
7664
7765const caseProps : CaseViewPageProps = {
7866 ...caseViewProps ,
@@ -87,40 +75,6 @@ describe('CaseViewPage', () => {
8775 jest . clearAllMocks ( ) ;
8876 useUrlParamsMock . mockReturnValue ( { } ) ;
8977 unifiedAttachmentTypeRegistry = new UnifiedAttachmentTypeRegistry ( ) ;
90- unifiedAttachmentTypeRegistry . register ( {
91- id : 'security.event' ,
92- displayName : 'Event' ,
93- icon : 'bell' ,
94- getAttachmentViewObject : ( ) => ( { event : 'added an event' } ) ,
95- getAttachmentTabViewObject : ( ) => ( {
96- children : ( ) => (
97- < div data-test-subj = "test-case-view-events-content" > { 'Events content' } </ div >
98- ) ,
99- } ) ,
100- schemaValidator : ( ) => { } ,
101- } ) ;
102- unifiedAttachmentTypeRegistry . register ( {
103- id : 'security.alert' ,
104- displayName : 'Alert' ,
105- icon : 'bell' ,
106- getAttachmentViewObject : ( ) => ( { event : 'added an alert' } ) ,
107- getAttachmentTabViewObject : ( ) => ( {
108- children : ( ) => (
109- < div data-test-subj = "test-case-view-alerts-content" > { 'Alerts content' } </ div >
110- ) ,
111- } ) ,
112- schemaValidator : ( ) => { } ,
113- } ) ;
114- unifiedAttachmentTypeRegistry . register ( {
115- id : 'file' ,
116- displayName : 'File' ,
117- icon : 'document' ,
118- getAttachmentViewObject : ( ) => ( { event : 'added a file' } ) ,
119- getAttachmentTabViewObject : ( ) => ( {
120- children : ( ) => < div data-test-subj = "test-case-view-files" > { 'Case view files' } </ div > ,
121- } ) ,
122- schemaValidator : ( ) => { } ,
123- } ) ;
12478 } ) ;
12579
12680 it ( 'shows the header section' , async ( ) => {
@@ -153,79 +107,19 @@ describe('CaseViewPage', () => {
153107 } ) ;
154108 } ) ;
155109
156- it ( 'resolves event type using the full case owner' , ( ) => {
157- const caseDataWithStringOwner = { ...caseProps . caseData , owner : 'securitySolution' } ;
158-
159- renderWithTestingProviders ( < CaseViewPage { ...caseProps } caseData = { caseDataWithStringOwner } /> ) ;
160-
161- expect ( toUnifiedAttachmentTypeMock ) . toHaveBeenCalledWith ( 'event' , 'securitySolution' ) ;
162- } ) ;
163-
164- it ( 'does not render the events tab content when events feature is disabled' , ( ) => {
165- useUrlParamsMock . mockReturnValue ( {
166- urlParams : { tabId : CASE_VIEW_PAGE_TABS . EVENTS } ,
167- } ) ;
168-
169- renderWithTestingProviders ( < CaseViewPage { ...caseProps } /> , {
170- wrapperProps : {
171- features : { events : { enabled : false } } ,
172- unifiedAttachmentTypeRegistry,
173- } ,
174- } ) ;
175-
176- expect ( screen . queryByTestId ( 'test-case-view-events-content' ) ) . not . toBeInTheDocument ( ) ;
177- } ) ;
178-
179- it ( 'renders the events tab content when events feature is enabled and type is registered' , async ( ) => {
180- useUrlParamsMock . mockReturnValue ( {
181- urlParams : { tabId : CASE_VIEW_PAGE_TABS . EVENTS } ,
182- } ) ;
183-
184- renderWithTestingProviders ( < CaseViewPage { ...caseProps } /> , {
185- wrapperProps : {
186- features : { events : { enabled : true } } ,
187- unifiedAttachmentTypeRegistry,
188- } ,
189- } ) ;
190-
191- expect ( await screen . findByTestId ( 'test-case-view-events-content' ) ) . toBeInTheDocument ( ) ;
192- } ) ;
193-
194- it ( 'resolves alert type using the full case owner' , ( ) => {
195- const caseDataWithStringOwner = { ...caseProps . caseData , owner : 'securitySolution' } ;
196-
197- renderWithTestingProviders ( < CaseViewPage { ...caseProps } caseData = { caseDataWithStringOwner } /> ) ;
198-
199- expect ( toUnifiedAttachmentTypeMock ) . toHaveBeenCalledWith ( 'alert' , 'securitySolution' ) ;
200- } ) ;
201-
202- it ( 'does not render the alerts tab content when alerts feature is disabled' , ( ) => {
203- useUrlParamsMock . mockReturnValue ( {
204- urlParams : { tabId : CASE_VIEW_PAGE_TABS . ALERTS } ,
205- } ) ;
206-
207- renderWithTestingProviders ( < CaseViewPage { ...caseProps } /> , {
208- wrapperProps : {
209- features : { alerts : { enabled : false } } ,
210- unifiedAttachmentTypeRegistry,
211- } ,
212- } ) ;
213-
214- expect ( screen . queryByTestId ( 'test-case-view-alerts-content' ) ) . not . toBeInTheDocument ( ) ;
215- } ) ;
216-
217- it ( 'renders the alerts tab content when alerts feature is enabled and type is registered' , async ( ) => {
218- useUrlParamsMock . mockReturnValue ( {
219- urlParams : { tabId : CASE_VIEW_PAGE_TABS . ALERTS } ,
220- } ) ;
110+ it . each ( [
111+ CASE_VIEW_PAGE_TABS . ATTACHMENTS ,
112+ CASE_VIEW_PAGE_TABS . ALERTS ,
113+ CASE_VIEW_PAGE_TABS . EVENTS ,
114+ CASE_VIEW_PAGE_TABS . FILES ,
115+ CASE_VIEW_PAGE_TABS . OBSERVABLES ,
116+ ] ) ( 'renders the consolidated attachments view for tabId=%s' , async ( tabId ) => {
117+ useUrlParamsMock . mockReturnValue ( { urlParams : { tabId } } ) ;
221118
222119 renderWithTestingProviders ( < CaseViewPage { ...caseProps } /> , {
223- wrapperProps : {
224- features : { alerts : { enabled : true } } ,
225- unifiedAttachmentTypeRegistry,
226- } ,
120+ wrapperProps : { unifiedAttachmentTypeRegistry } ,
227121 } ) ;
228122
229- expect ( await screen . findByTestId ( 'test-case-view-alerts-content ' ) ) . toBeInTheDocument ( ) ;
123+ expect ( await screen . findByTestId ( 'test-case-view-attachments ' ) ) . toBeInTheDocument ( ) ;
230124 } ) ;
231125} ) ;
0 commit comments