@@ -921,10 +921,9 @@ describe('OnyxUtils', () => {
921921 } ) ;
922922
923923 describe ( 'mergeCollection pre-warm' , ( ) => {
924- // The retryOperation describe block above mutates StorageMock.setItem (and never restores it),
925- // so by the time we run, setItem may be a rejecting mock from a prior test. Capture pristine
926- // references at file-load time and restore them in beforeEach so our seeding via Onyx.set
927- // actually reaches the in-memory storage provider.
924+ // retryOperation tests above replace StorageMock methods without restoring them, leaving
925+ // rejecting mocks behind. Capture pristine refs at file-load time and restore in beforeEach
926+ // so our Onyx.set seeding actually reaches the in-memory storage provider.
928927 const pristineSetItem = StorageMock . setItem ;
929928 const pristineMultiSet = StorageMock . multiSet ;
930929 const pristineMultiGet = StorageMock . multiGet ;
@@ -939,11 +938,9 @@ describe('OnyxUtils', () => {
939938 StorageMock . multiMerge = pristineMultiMerge ;
940939 } ) ;
941940
942- // Make a key "cold" — value evicted from cache but the key is still tracked as persisted.
943- // OnyxCache.drop also removes the key from `storageKeys`, which would cause getAllKeys() to
944- // miss it (unless the entire storageKeys set is empty, in which case the function falls back
945- // to Storage.getAllKeys). To reliably hit the cold-but-persisted state regardless of how many
946- // other keys remain in cache, we re-register the key as known after dropping its value.
941+ // Make a key "cold" — value evicted from cache but still tracked as persisted. OnyxCache.drop
942+ // also removes the key from `storageKeys`, so we re-register it afterwards to reliably hit
943+ // the cold-but-persisted state regardless of getAllKeys()'s fallback path.
947944 const evictFromCache = ( ...keys : string [ ] ) => {
948945 for ( const key of keys ) {
949946 OnyxCache . drop ( key ) ;
@@ -1103,10 +1100,9 @@ describe('OnyxUtils', () => {
11031100 await Onyx . set ( coldMemberKey , { value : 'persisted' } ) ;
11041101 evictFromCache ( coldMemberKey ) ;
11051102
1106- // Connect the subscriber and flush its initial data load FIRST, before installing
1107- // the rejecting mock. Otherwise the connect's getCollectionDataAndSendAsObject path
1108- // (whose multiGet call has no .catch) would consume the mockRejectedValueOnce and
1109- // leak an unhandled rejection — not the merge pre-warm we're actually exercising.
1103+ // Connect and flush the subscriber's initial load BEFORE installing the rejecting mock —
1104+ // otherwise the connect's own multiGet (no .catch) consumes the mockRejectedValueOnce and
1105+ // leaks an unhandled rejection instead of exercising the merge pre-warm path.
11101106 const collectionCallback = jest . fn ( ) ;
11111107 Onyx . connect ( {
11121108 key : collectionKey ,
@@ -1134,10 +1130,9 @@ describe('OnyxUtils', () => {
11341130 expect ( outerRejected ) . toBeNull ( ) ;
11351131 expect ( result ) . toBeUndefined ( ) ;
11361132
1137- // cache.merge() + keysChanged() must still have fired so subscribers see the merge.
1138- // Use toMatchObject for the cold key because a successful concurrent read may have
1139- // re-populated the persisted value into cache; what we care about is that the new
1140- // {merged: true} delta is applied.
1133+ // cache.merge() + keysChanged() must still fire so subscribers see the merge. Use
1134+ // toMatchObject because a concurrent read may have re-populated the persisted value;
1135+ // what matters is that the new {merged: true} delta is applied on top.
11411136 expect ( collectionCallback ) . toHaveBeenCalled ( ) ;
11421137 const lastBroadcast = collectionCallback . mock . calls . at ( - 1 ) ?. [ 0 ] as Record < string , unknown > | undefined ;
11431138 expect ( lastBroadcast ?. [ coldMemberKey ] ) . toMatchObject ( { merged : true } ) ;
@@ -1146,10 +1141,8 @@ describe('OnyxUtils', () => {
11461141 } ) ;
11471142
11481143 describe ( 'multiGet cache hit consistency' , ( ) => {
1149- // Same suite-pollution guard as the pre-warm block above: capture pristine StorageMock
1150- // references at file-load time and restore them in beforeEach. The retryOperation
1151- // describe block above mutates StorageMock.setItem (and never restores it), so by the
1152- // time we run, setItem may be a rejecting mock from a prior test.
1144+ // Same suite-pollution guard as the pre-warm block above — capture pristine StorageMock
1145+ // refs at file-load time and restore them in beforeEach, since retryOperation tests leak.
11531146 const pristineSetItem = StorageMock . setItem ;
11541147 const pristineMultiGet = StorageMock . multiGet ;
11551148 const pristineGetItem = StorageMock . getItem ;
0 commit comments