@@ -71,25 +71,28 @@ function createStore({
7171 hasShardingError = ( ) => false ,
7272 hasShardKey = ( ) => false ,
7373 failsOnShardingRequest = ( ) => false ,
74+ failsOnShardZoneRequest = ( ) => false ,
7475 authenticatedFetchStub,
7576} :
7677 | {
7778 isNamespaceManaged ?: ( ) => boolean ;
7879 hasShardingError ?: ( ) => boolean ;
7980 hasShardKey ?: ( ) => boolean | AtlasShardKey ;
8081 failsOnShardingRequest ?: ( ) => boolean ;
82+ failsOnShardZoneRequest ?: ( ) => boolean ;
8183 authenticatedFetchStub ?: never ;
8284 }
8385 | {
8486 isNamespaceManaged ?: never ;
8587 hasShardingError ?: never ;
8688 hasShardKey ?: ( ) => boolean | ShardKey ;
8789 failsOnShardingRequest ?: never ;
90+ failsOnShardZoneRequest ?: ( ) => never ;
8891 authenticatedFetchStub ?: ( ) => void ;
8992 } = { } ) : GlobalWritesStore {
9093 const atlasService = {
9194 authenticatedFetch : ( uri : string ) => {
92- if ( uri . includes ( ` /geoSharding` ) && failsOnShardingRequest ( ) ) {
95+ if ( uri . endsWith ( ' /geoSharding' ) && failsOnShardingRequest ( ) ) {
9396 return Promise . reject ( new Error ( 'Failed to shard' ) ) ;
9497 }
9598
@@ -111,6 +114,13 @@ function createStore({
111114 } ) ;
112115 }
113116
117+ if (
118+ / g e o S h a r d i n g .* n e w F o r m L o c a t i o n M a p p i n g / . test ( uri ) &&
119+ failsOnShardZoneRequest ( )
120+ ) {
121+ return Promise . reject ( new Error ( 'Failed to fetch shard zones' ) ) ;
122+ }
123+
114124 return createAuthFetchResponse ( { } ) ;
115125 } ,
116126 automationAgentRequest : ( _meta : unknown , type : string ) => ( {
@@ -262,6 +272,7 @@ describe('GlobalWritesStore Store', function () {
262272 const store = createStore ( {
263273 isNamespaceManaged : ( ) => true ,
264274 hasShardKey : Sinon . fake ( ( ) => mockShardKey ) ,
275+ failsOnShardZoneRequest : ( ) => true ,
265276 } ) ;
266277 await waitFor ( ( ) => {
267278 expect ( store . getState ( ) . status ) . to . equal ( 'SHARDING' ) ;
0 commit comments