@@ -17,7 +17,7 @@ import type { WorkspacesService } from '@mongodb-js/compass-workspaces/provider'
1717import { WorkspacesServiceProvider } from '@mongodb-js/compass-workspaces/provider' ;
1818import { TestMongoDBInstanceManager } from '@mongodb-js/compass-app-stores/provider' ;
1919import { ConnectionImportExportProvider } from '@mongodb-js/compass-connection-import-export' ;
20- import { CompassSidebarPlugin } from '../../index' ;
20+ import { AtlasClusterConnectionsOnly , CompassSidebarPlugin } from '../../index' ;
2121import type { ConnectionInfo } from '@mongodb-js/compass-connections/provider' ;
2222import type AppRegistry from '../../../../hadron-app-registry/dist' ;
2323
@@ -91,14 +91,16 @@ describe('Multiple Connections Sidebar Component', function () {
9191
9292 function doRender (
9393 activeWorkspace : WorkspaceTab | null = null ,
94- connections : ConnectionInfo [ ] = [ savedFavoriteConnection ]
94+ connections : ConnectionInfo [ ] = [ savedFavoriteConnection ] ,
95+ atlasClusterConnectionsOnly : boolean | undefined = undefined
9596 ) {
9697 workspace = sinon . spy ( {
9798 openMyQueriesWorkspace : ( ) => undefined ,
9899 openShellWorkspace : ( ) => undefined ,
99100 openPerformanceWorkspace : ( ) => undefined ,
100101 } ) as any ;
101- const result = renderWithConnections (
102+
103+ let component = (
102104 < ConnectionImportExportProvider >
103105 < WorkspacesProvider
104106 value = { [
@@ -112,25 +114,36 @@ describe('Multiple Connections Sidebar Component', function () {
112114 > </ MultipleConnectionSidebar >
113115 </ WorkspacesServiceProvider >
114116 </ WorkspacesProvider >
115- </ ConnectionImportExportProvider > ,
116- {
117- preferences : { enableMultipleConnectionSystem : true } ,
118- connections,
119- connectFn ( ) {
120- return {
121- currentOp ( ) {
122- return { } ;
123- } ,
124- top ( ) {
125- return { } ;
126- } ,
127- getConnectionOptions ( ) {
128- return { } ;
129- } ,
130- } as any ;
131- } ,
132- }
117+ </ ConnectionImportExportProvider >
133118 ) ;
119+
120+ if ( atlasClusterConnectionsOnly !== undefined ) {
121+ component = (
122+ < AtlasClusterConnectionsOnly . Provider
123+ value = { atlasClusterConnectionsOnly }
124+ >
125+ { component }
126+ </ AtlasClusterConnectionsOnly . Provider >
127+ ) ;
128+ }
129+
130+ const result = renderWithConnections ( component , {
131+ preferences : { enableMultipleConnectionSystem : true } ,
132+ connections,
133+ connectFn ( ) {
134+ return {
135+ currentOp ( ) {
136+ return { } ;
137+ } ,
138+ top ( ) {
139+ return { } ;
140+ } ,
141+ getConnectionOptions ( ) {
142+ return { } ;
143+ } ,
144+ } as any ;
145+ } ,
146+ } ) ;
134147 track = result . track ;
135148 appRegistry = sinon . spy ( result . globalAppRegistry ) ;
136149 connectionsStoreActions = sinon . spy ( result . connectionsStore . actions ) ;
@@ -188,6 +201,37 @@ describe('Multiple Connections Sidebar Component', function () {
188201 } ) ;
189202 } ) ;
190203
204+ describe ( "'Connections ' header" , function ( ) {
205+ context ( 'by default' , ( ) => {
206+ it ( "shows 'Connections' in header and search bar" , ( ) => {
207+ doRender ( undefined , [ savedFavoriteConnection , savedRecentConnection ] ) ;
208+ expect ( screen . getByTestId ( 'connections-header' ) . textContent ) . to . equal (
209+ 'Connections(2)'
210+ ) ;
211+ expect (
212+ screen . getByTestId < HTMLInputElement > ( 'sidebar-filter-input' )
213+ . placeholder
214+ ) . to . equal ( 'Search connections' ) ;
215+ } ) ;
216+ } ) ;
217+ context ( 'when is atlas clusters only' , ( ) => {
218+ it ( "shows 'Clusters' in header and search bar" , ( ) => {
219+ doRender (
220+ undefined ,
221+ [ savedFavoriteConnection , savedRecentConnection ] ,
222+ true
223+ ) ;
224+ expect ( screen . getByTestId ( 'connections-header' ) . textContent ) . to . equal (
225+ 'Clusters(2)'
226+ ) ;
227+ expect (
228+ screen . getByTestId < HTMLInputElement > ( 'sidebar-filter-input' )
229+ . placeholder
230+ ) . to . equal ( 'Search clusters' ) ;
231+ } ) ;
232+ } ) ;
233+ } ) ;
234+
191235 describe ( 'connections list' , function ( ) {
192236 context ( 'when there are no connections' , function ( ) {
193237 it ( 'should display an empty state with a CTA to add new connection' , function ( ) {
0 commit comments