@@ -4,7 +4,10 @@ import { selectTab } from '../modules/collection-tab';
44import * as collectionTabModule from '../modules/collection-tab' ;
55import { waitFor } from '@mongodb-js/testing-library-compass' ;
66import Sinon from 'sinon' ;
7- import AppRegistry from '@mongodb-js/compass-app-registry' ;
7+ import type { ActivateHelpers } from '@mongodb-js/compass-app-registry' ;
8+ import AppRegistry , {
9+ createActivateHelpers ,
10+ } from '@mongodb-js/compass-app-registry' ;
811import { expect } from 'chai' ;
912import type { workspacesServiceLocator } from '@mongodb-js/compass-workspaces/provider' ;
1013import type { ExperimentationServices } from '@mongodb-js/compass-telemetry/provider' ;
@@ -94,36 +97,10 @@ describe('Collection Tab Content store', function () {
9497 . stub ( collectionTabModule , 'analyzeCollectionSchema' )
9598 . returns ( async ( ) => { } ) ;
9699
97- // Track event listeners for proper cleanup
98- const eventListeners : Array < {
99- registry : AppRegistry ;
100- eventName : string ;
101- listener : ( ...args : unknown [ ] ) => void ;
102- } > = [ ] ;
103-
104- const mockActivateHelpers = {
105- on : sandbox . spy (
106- (
107- registry : AppRegistry ,
108- eventName : string ,
109- listener : ( ...args : unknown [ ] ) => void
110- ) => {
111- registry . on ( eventName , listener ) ;
112- eventListeners . push ( { registry, eventName, listener } ) ;
113- }
114- ) ,
115- cleanup : sandbox . spy ( ( ) => {
116- // Remove all tracked event listeners
117- eventListeners . forEach ( ( { registry, eventName, listener } ) => {
118- registry . removeListener ( eventName , listener ) ;
119- } ) ;
120- eventListeners . length = 0 ;
121- } ) ,
122- addCleanup : sandbox . spy ( ) ,
123- } ;
100+ let mockActivateHelpers : ActivateHelpers ;
124101
125- const dataService = { } as never ;
126- const atlasAiService = { } as never ;
102+ const dataService = { } as any ;
103+ const atlasAiService = { } as any ;
127104 let store : ReturnType < typeof activatePlugin > [ 'store' ] ;
128105 let deactivate : ReturnType < typeof activatePlugin > [ 'deactivate' ] ;
129106
@@ -161,14 +138,14 @@ describe('Collection Tab Content store', function () {
161138 atlasAiService,
162139 localAppRegistry,
163140 globalAppRegistry,
164- collection : mockCollection as never ,
165- workspaces : workspaces as never ,
166- experimentationServices : experimentationServices as never ,
167- connectionInfoRef : connectionInfoRef as never ,
141+ collection : mockCollection as any ,
142+ workspaces : workspaces as any ,
143+ experimentationServices : experimentationServices as any ,
144+ connectionInfoRef : connectionInfoRef as any ,
168145 logger,
169146 preferences,
170147 } ,
171- mockActivateHelpers as never
148+ mockActivateHelpers
172149 ) ) ;
173150 await waitFor ( ( ) => {
174151 expect ( store . getState ( ) )
@@ -178,6 +155,10 @@ describe('Collection Tab Content store', function () {
178155 return store ;
179156 } ;
180157
158+ beforeEach ( function ( ) {
159+ mockActivateHelpers = createActivateHelpers ( ) ;
160+ } ) ;
161+
181162 afterEach ( function ( ) {
182163 mockActivateHelpers . cleanup ( ) ;
183164 sandbox . resetHistory ( ) ;
@@ -194,7 +175,7 @@ describe('Collection Tab Content store', function () {
194175 { openCollectionWorkspaceSubtab } ,
195176 { assignExperiment }
196177 ) ;
197- store . dispatch ( selectTab ( 'Documents' ) as never ) ;
178+ store . dispatch ( selectTab ( 'Documents' ) as any ) ;
198179 expect ( openCollectionWorkspaceSubtab ) . to . have . been . calledWith (
199180 'workspace-tab-id' ,
200181 'Documents'
@@ -508,7 +489,7 @@ describe('Collection Tab Content store', function () {
508489 } ) ;
509490
510491 // Dispatch cancel action
511- store . dispatch ( collectionTabModule . cancelSchemaAnalysis ( ) as never ) ;
492+ store . dispatch ( collectionTabModule . cancelSchemaAnalysis ( ) as any ) ;
512493
513494 // Verify the state is reset to initial
514495 expect (
@@ -549,7 +530,7 @@ describe('Collection Tab Content store', function () {
549530 store . dispatch ( {
550531 type : 'compass-collection/SchemaAnalysisFailed' ,
551532 error : new Error ( 'No documents found' ) ,
552- } as never ) ;
533+ } as any ) ;
553534
554535 // Trigger the document-inserted event
555536 globalAppRegistry . emit (
0 commit comments