@@ -7,16 +7,25 @@ import { activateGlobalWritesPlugin } from '../src/store';
77import { createActivateHelpers } from 'hadron-app-registry' ;
88import { createNoopLogger } from '@mongodb-js/compass-logging/provider' ;
99import { createNoopTrack } from '@mongodb-js/compass-telemetry/provider' ;
10- import type {
11- ConnectionInfo ,
12- ConnectionInfoRef ,
13- } from '@mongodb-js/compass-connections/provider' ;
10+ import type { ConnectionInfo } from '@mongodb-js/compass-connections/provider' ;
1411import type { AtlasService } from '@mongodb-js/atlas-service/provider' ;
1512import { Provider } from 'react-redux' ;
1613import { renderWithActiveConnection } from '@mongodb-js/testing-library-compass' ;
1714
1815import clusterApiResponse from './cluster-api-response.json' ;
1916
17+ const TEST_CONNECTION_INFO = {
18+ id : 'TEST' ,
19+ connectionOptions : {
20+ connectionString : 'mongodb://localhost' ,
21+ } ,
22+ atlasMetadata : {
23+ clusterName : 'Cluster0' ,
24+ clusterType : 'UNSHARDED' ,
25+ projectId : 'Project0' ,
26+ } as unknown as ConnectionInfo [ 'atlasMetadata' ] ,
27+ } ;
28+
2029const atlasService = {
2130 cloudEndpoint : ( p : string ) => {
2231 return `https://example.com/${ p } ` ;
@@ -39,19 +48,9 @@ const atlasService = {
3948
4049export const setupStore = (
4150 options : Partial < GlobalWritesPluginOptions > = { } ,
42- services : Partial < GlobalWritesPluginServices > = { }
51+ services : Partial < GlobalWritesPluginServices > = { } ,
52+ connectionInfo : ConnectionInfo = TEST_CONNECTION_INFO
4353) => {
44- const connectionInfoRef = {
45- current : {
46- id : 'TEST' ,
47- atlasMetadata : {
48- clusterName : 'Cluster0' ,
49- clusterType : 'GEOSHARDED' ,
50- projectId : 'Project0' ,
51- } ,
52- } ,
53- } as ConnectionInfoRef ;
54-
5554 return activateGlobalWritesPlugin (
5655 {
5756 namespace : 'airbnb.listings' ,
@@ -60,7 +59,12 @@ export const setupStore = (
6059 {
6160 logger : createNoopLogger ( 'TEST' ) ,
6261 track : createNoopTrack ( ) ,
63- connectionInfoRef,
62+ connectionInfoRef : {
63+ current : {
64+ ...connectionInfo ,
65+ title : 'My connection' ,
66+ } ,
67+ } ,
6468 ...services ,
6569 atlasService : {
6670 ...atlasService ,
@@ -76,19 +80,14 @@ export const renderWithStore = (
7680 {
7781 services = { } ,
7882 options = { } ,
79- connectionInfo = {
80- id : 'testConnection' ,
81- connectionOptions : {
82- connectionString : 'mongodb://localhost' ,
83- } ,
84- } ,
83+ connectionInfo = TEST_CONNECTION_INFO ,
8584 } : {
8685 services ?: Partial < GlobalWritesPluginServices > ;
8786 options ?: Partial < GlobalWritesPluginOptions > ;
8887 connectionInfo ?: ConnectionInfo ;
8988 } = { }
9089) => {
91- const store = setupStore ( options , services ) ;
90+ const store = setupStore ( options , services , connectionInfo ) ;
9291 return renderWithActiveConnection (
9392 < Provider store = { store } > { component } </ Provider > ,
9493 connectionInfo
0 commit comments