@@ -83,6 +83,13 @@ const MockAdapterInstance = {
8383 connect : vi . fn ( ) . mockResolvedValue ( true ) ,
8484 onConnectionStateChange : vi . fn ( ) . mockReturnValue ( ( ) => { } ) ,
8585 getConnectionState : vi . fn ( ) . mockReturnValue ( 'connected' ) ,
86+ getClient : vi . fn ( ) . mockReturnValue ( {
87+ meta : {
88+ saveItem : vi . fn ( ) . mockResolvedValue ( { ok : true } ) ,
89+ getItems : vi . fn ( ) . mockResolvedValue ( { items : [ ] } ) ,
90+ getItem : vi . fn ( ) . mockResolvedValue ( null ) ,
91+ } ,
92+ } ) ,
8693 discovery : { } ,
8794} ;
8895
@@ -349,6 +356,25 @@ describe('Console App Creation Integration', () => {
349356 expect ( localStorage . getItem ( 'objectui-app-wizard-draft' ) ) . toBeNull ( ) ;
350357 } ) ;
351358 } ) ;
359+
360+ it ( 'calls client.meta.saveItem on wizard completion' , async ( ) => {
361+ renderApp ( '/apps/sales/create-app' ) ;
362+
363+ await waitFor ( ( ) => {
364+ expect ( screen . getByTestId ( 'wizard-complete' ) ) . toBeInTheDocument ( ) ;
365+ } , { timeout : 10000 } ) ;
366+
367+ fireEvent . click ( screen . getByTestId ( 'wizard-complete' ) ) ;
368+
369+ await waitFor ( ( ) => {
370+ const client = MockAdapterInstance . getClient ( ) ;
371+ expect ( client . meta . saveItem ) . toHaveBeenCalledWith (
372+ 'app' ,
373+ 'my_app' ,
374+ expect . objectContaining ( { name : 'my_app' } ) ,
375+ ) ;
376+ } ) ;
377+ } ) ;
352378 } ) ;
353379
354380 // --- Route: Edit App ---
@@ -379,6 +405,25 @@ describe('Console App Creation Integration', () => {
379405 expect ( screen . getByTestId ( 'edit-app-not-found' ) ) . toBeInTheDocument ( ) ;
380406 } , { timeout : 10000 } ) ;
381407 } ) ;
408+
409+ it ( 'calls client.meta.saveItem on wizard completion (edit)' , async ( ) => {
410+ renderApp ( '/apps/sales/edit-app/sales' ) ;
411+
412+ await waitFor ( ( ) => {
413+ expect ( screen . getByTestId ( 'wizard-complete' ) ) . toBeInTheDocument ( ) ;
414+ } , { timeout : 10000 } ) ;
415+
416+ fireEvent . click ( screen . getByTestId ( 'wizard-complete' ) ) ;
417+
418+ await waitFor ( ( ) => {
419+ const client = MockAdapterInstance . getClient ( ) ;
420+ expect ( client . meta . saveItem ) . toHaveBeenCalledWith (
421+ 'app' ,
422+ 'my_app' ,
423+ expect . objectContaining ( { name : 'my_app' } ) ,
424+ ) ;
425+ } ) ;
426+ } ) ;
382427 } ) ;
383428
384429 // --- CommandPalette: Create App Command ---
0 commit comments