@@ -468,6 +468,50 @@ describe("createAdapterStoreModule", () => {
468468 expect ( result . testMethod ( ) ) . toBe ( "adapted-1" ) ;
469469 } ) ;
470470
471+ it ( "should return reactive adapted item that reflects store updates" , async ( ) => {
472+ // Arrange
473+ const httpService : Pick < HttpService , "getRequest" > = { getRequest : vi . fn ( ) } ;
474+ const storageService : TestStorageService = { put : vi . fn ( ) , get : vi . fn ( ) . mockReturnValue ( { } ) } ;
475+ const loadingService : TestLoadingService = {
476+ ensureLoadingFinished : vi . fn ( ) . mockResolvedValue ( undefined ) ,
477+ } ;
478+ const { adapter, getCapturedStoreModule } = createCapturingAdapter ( ) ;
479+ const config : AdapterStoreConfig < TestItem , TestAdapted , TestNewAdapted > = {
480+ domainName : "test-items" ,
481+ adapter,
482+ httpService,
483+ storageService,
484+ loadingService,
485+ } ;
486+ const items : TestItem [ ] = [
487+ {
488+ id : 1 ,
489+ name : "Original" ,
490+ createdAt : "2024-01-01T00:00:00Z" ,
491+ updatedAt : "2024-01-01T00:00:00Z" ,
492+ } ,
493+ ] ;
494+ vi . mocked ( httpService . getRequest ) . mockResolvedValue ( { data : items } as AxiosResponse <
495+ TestItem [ ]
496+ > ) ;
497+ const store = createAdapterStoreModule ( config ) ;
498+ await store . retrieveAll ( ) ;
499+ const result = await store . getOrFailById ( 1 ) ;
500+ expect ( result . name ) . toBe ( "Original" ) ;
501+
502+ // Act — simulate a store update (e.g. from a patch/update response)
503+ const storeModule = getCapturedStoreModule ( ) as unknown as AdapterStoreModule < TestItem > ;
504+ storeModule . setById ( {
505+ id : 1 ,
506+ name : "Updated" ,
507+ createdAt : "2024-01-01T00:00:00Z" ,
508+ updatedAt : "2024-01-02T00:00:00Z" ,
509+ } ) ;
510+
511+ // Assert — the same adapted object should reflect the updated data via getters
512+ expect ( result . name ) . toBe ( "Updated" ) ;
513+ } ) ;
514+
471515 it ( "should throw EntryNotFoundError when item not found" , async ( ) => {
472516 // Arrange
473517 const httpService : Pick < HttpService , "getRequest" > = { getRequest : vi . fn ( ) } ;
0 commit comments