File tree Expand file tree Collapse file tree 12 files changed +63
-23
lines changed
configs/testing-library-compass/src
compass-aggregations/test
compass-connections/src/stores
compass-data-modeling/test
compass-field-store/src/stores
compass-indexes/src/components/search-indexes-modals
compass-preferences-model/src
compass-schema/src/modules
compass-settings/src/stores Expand file tree Collapse file tree 12 files changed +63
-23
lines changed Original file line number Diff line number Diff line change @@ -283,7 +283,9 @@ function createWrapper(
283283 const wrapperState = {
284284 globalAppRegistry : new AppRegistry ( ) ,
285285 localAppRegistry : new AppRegistry ( ) ,
286- preferences : new InMemoryPreferencesAccess ( options . preferences ) ,
286+ preferences : new InMemoryPreferencesAccess (
287+ options . preferences
288+ ) as PreferencesAccess ,
287289 track : Sinon . stub ( ) ,
288290 logger : createNoopLogger ( ) ,
289291 connectionStorage :
@@ -585,6 +587,12 @@ function createPluginWrapper<
585587 return { ref, Wrapper : ComponentWithProvider } ;
586588}
587589
590+ export type RenderPluginWithConnectionsResult <
591+ T extends CompassPluginComponent < any , any , any >
592+ > = RenderWithConnectionsResult & {
593+ plugin : ReturnType < T [ 'useActivate' ] > ;
594+ } ;
595+
588596function createPluginTestHelpers <
589597 Props ,
590598 ServiceLocators extends Record < string , ( ) => unknown > ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import type {
33 ConfigureStoreOptions ,
44} from '../src/stores/store' ;
55import { mockDataService } from './mocks/data-service' ;
6+ import type { RenderPluginWithConnectionsResult } from '@mongodb-js/testing-library-compass' ;
67import { createPluginTestHelpers } from '@mongodb-js/testing-library-compass' ;
78import { CompassAggregationsPlugin } from '../src/index' ;
89import type { DataService } from '@mongodb-js/compass-connections/provider' ;
@@ -86,7 +87,9 @@ export default function configureStore(
8687export function renderWithStore (
8788 ui : React . ReactElement ,
8889 ...args : Parameters < typeof configureStore >
89- ) {
90+ ) : Promise <
91+ RenderPluginWithConnectionsResult < typeof CompassAggregationsPlugin . provider >
92+ > {
9093 ui = args [ 2 ] ?. pipelineStorage
9194 ? React . createElement ( PipelineStorageProvider , {
9295 value : args [ 2 ] . pipelineStorage ,
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import {
3838 getLatestEndOfLifeServerVersion ,
3939 isEndOfLifeVersion ,
4040} from '../utils/end-of-life-server' ;
41+ import type { ImportConnectionOptions } from '@mongodb-js/connection-storage/provider' ;
4142
4243export type ConnectionsEventMap = {
4344 connected : (
@@ -2183,11 +2184,11 @@ export const showEndOfLifeMongoDBWarningModal = (
21832184 } ;
21842185} ;
21852186
2186- type ImportConnectionsFn = Required < ConnectionStorage > [ 'importConnections' ] ;
2187-
2188- export const importConnections = (
2189- ... args : Parameters < ImportConnectionsFn >
2190- ) : ConnectionsThunkAction <
2187+ export const importConnections = ( options : {
2188+ content : string ;
2189+ options ?: ImportConnectionOptions ;
2190+ signal ?: AbortSignal ;
2191+ } ) : ConnectionsThunkAction <
21912192 Promise < void > ,
21922193 ConnectionsImportStartAction | ConnectionsImportFinishAction
21932194> => {
@@ -2197,7 +2198,7 @@ export const importConnections = (
21972198 let error ;
21982199 try {
21992200 if ( connectionStorage . importConnections ) {
2200- await connectionStorage . importConnections ( ... args ) ;
2201+ await connectionStorage . importConnections ( options ) ;
22012202 connections = await connectionStorage . loadAll ( ) ;
22022203 }
22032204 } catch ( err ) {
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import {
4141} from '@mongodb-js/connection-info' ;
4242import { createServiceLocator } from '@mongodb-js/compass-app-registry' ;
4343import { isEqual } from 'lodash' ;
44+ import type { ImportConnectionOptions } from '@mongodb-js/connection-storage/provider' ;
4445
4546type ConnectionsStore = ReturnType < typeof configureStore > extends Store <
4647 infer S ,
@@ -130,8 +131,12 @@ function getConnectionsActions(dispatch: ConnectionsStore['dispatch']) {
130131 showNonGenuineMongoDBWarningModal : ( connectionId : ConnectionId ) => {
131132 return dispatch ( showNonGenuineMongoDBWarningModal ( connectionId ) ) ;
132133 } ,
133- importConnections : ( ...args : Parameters < typeof importConnections > ) => {
134- return dispatch ( importConnections ( ...args ) ) ;
134+ importConnections : ( options : {
135+ content : string ;
136+ options ?: ImportConnectionOptions ;
137+ signal ?: AbortSignal ;
138+ } ) => {
139+ return dispatch ( importConnections ( options ) ) ;
135140 } ,
136141 refreshConnections : ( ) => {
137142 return dispatch ( refreshConnections ( ) ) ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import type { RenderWithConnectionsResult } from '@mongodb-js/testing-library-compass' ;
23import { renderWithConnections } from '@mongodb-js/testing-library-compass' ;
34import { createActivateHelpers } from '@mongodb-js/compass-app-registry' ;
45import { createNoopTrack } from '@mongodb-js/compass-telemetry/provider' ;
@@ -180,6 +181,7 @@ export const setupStore = (
180181 createActivateHelpers ( )
181182 ) . store ;
182183} ;
184+
183185export const renderWithStore = (
184186 component : JSX . Element ,
185187 {
@@ -189,7 +191,8 @@ export const renderWithStore = (
189191 services ?: Partial < DataModelingStoreServices > ;
190192 connections ?: ConnectionInfoWithMockData [ ] ;
191193 } = { }
192- ) => {
194+ ) : RenderWithConnectionsResult & { store : DataModelingStore } => {
195+ // TODO: use createPluginTestHelpers instead of most of the code in this file
193196 const store = setupStore ( services , connections ) ;
194197 const renderResult = renderWithConnections (
195198 < Provider store = { store } > { component } </ Provider > ,
Original file line number Diff line number Diff line change @@ -37,13 +37,11 @@ function createFieldStoreService(
3737/**
3838 * @internal exported for test purposes only
3939 */
40- export function useFieldStoreService ( ) {
40+ export function useFieldStoreService ( ) : FieldStoreService {
4141 const dispatch = useDispatch ( ) ;
4242 const connectionInfoRef = useConnectionInfoRef ( ) ;
4343 return createFieldStoreService ( dispatch , connectionInfoRef ) ;
4444}
4545
46- export const fieldStoreServiceLocator = createServiceLocator (
47- useFieldStoreService ,
48- 'fieldStoreServiceLocator'
49- ) ;
46+ export const fieldStoreServiceLocator : ( ) => FieldStoreService =
47+ createServiceLocator ( useFieldStoreService , 'fieldStoreServiceLocator' ) ;
Original file line number Diff line number Diff line change @@ -197,7 +197,16 @@ export const BaseSearchIndexModal: React.FunctionComponent<
197197 ( track : TrackFunction ) => {
198198 if ( isModalOpen ) {
199199 const connectionInfo = connectionInfoRef . current ;
200- track ( 'Screen' , { name : `${ mode } _search_index_modal` } , connectionInfo ) ;
200+ track (
201+ 'Screen' ,
202+ {
203+ name :
204+ mode === 'create'
205+ ? 'create_search_index_modal'
206+ : 'update_search_index_modal' ,
207+ } ,
208+ connectionInfo
209+ ) ;
201210 if ( mode === 'create' ) {
202211 track (
203212 'Index Create Opened' ,
Original file line number Diff line number Diff line change @@ -39,3 +39,5 @@ export function createSandboxFromDefaultPreferences(): Promise<PreferencesAccess
3939 return defaultPreferencesInstance . createSandbox ( ) ;
4040}
4141export type { DevtoolsProxyOptions } from '@mongodb-js/devtools-proxy-support' ;
42+ export type * from './feature-flags' ;
43+ export type * from './preferences-schema' ;
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ export {
1010} from './utils' ;
1111export { capMaxTimeMSAtPreferenceLimit } from './maxtimems' ;
1212export { featureFlags } from './feature-flags' ;
13+ export type * from './feature-flags' ;
1314export { getSettingDescription , SORT_ORDER_VALUES } from './preferences-schema' ;
14- export type { AllPreferences , SORT_ORDERS } from './preferences-schema' ;
15+ export type * from './preferences-schema' ;
1516export type { DevtoolsProxyOptions } from '@mongodb-js/devtools-proxy-support' ;
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ import type {
1010 PrimitiveSchemaType ,
1111 SchemaParseOptions ,
1212} from 'mongodb-schema' ;
13- import type { DataService } from '../stores/store ' ;
14- import type { Logger } from '@mongodb-js/compass-logging' ;
15- import type { PreferencesAccess } from 'compass-preferences-model' ;
13+ import type { DataService } from '@mongodb-js/compass-connections/provider ' ;
14+ import type { Logger } from '@mongodb-js/compass-logging/provider ' ;
15+ import type { PreferencesAccess } from 'compass-preferences-model/provider ' ;
1616
1717export const DISTINCT_FIELDS_ABORT_THRESHOLD = 1000 ;
1818
@@ -31,7 +31,7 @@ function promoteMongoErrorCode(err?: Error & { code?: unknown }) {
3131}
3232
3333export const analyzeSchema = async (
34- dataService : DataService ,
34+ dataService : Pick < DataService , 'sampleCursor' > ,
3535 abortSignal : AbortSignal ,
3636 ns : string ,
3737 query :
You can’t perform that action at this time.
0 commit comments