1515 *
1616 * Pinned:
1717 * - an object with a default internal form view: the field groups are the
18- * canvas, the chip says so, Add group saves the object 's `fieldGroups` and
19- * writes no view; Preview shows the field groups, not the view's sections;
18+ * canvas, the chip says so, Add group then the top bar 's Save
19+ * (objectstack#36511) saves the object's `fieldGroups` and writes no view; Preview shows the field groups, not the view's sections;
2020 * - CONTROL: no form view: the same canvas and the same save.
2121 */
2222
@@ -109,6 +109,7 @@ const mockClient = {
109109 return pending ? { item : pending . served , version : 'v7' } : null ;
110110 } ) ,
111111 get : vi . fn ( async ( ) => null ) ,
112+ publish : vi . fn ( async ( ) => ( { } ) ) , reset : vi . fn ( async ( ) => ( { } ) ) ,
112113 save : vi . fn ( async ( ) => ( { ok : true , version : 'v2' , state : 'draft' } ) ) ,
113114} ;
114115
@@ -140,6 +141,7 @@ vi.mock('@object-ui/plugin-view', async (importOriginal) => {
140141// warmed here so its first load is paid at import, not inside a test's clock.
141142import '@objectstack/lint' ;
142143import { DataPillar , type StudioBaseCustomization } from './StudioDesignSurface' ;
144+ import { StudioSaveHarness , pressStudioSave } from './__tests__/studioSaveHarness' ;
143145import { t } from '../metadata-admin/i18n' ;
144146
145147const FORM = t ( 'engine.studio.data.tab.form' , 'en' ) ;
@@ -160,9 +162,9 @@ afterEach(() => {
160162
161163async function openForm ( props : { readOnly ?: boolean ; customization ?: StudioBaseCustomization } = { } ) {
162164 render (
163- < MemoryRouter initialEntries = { [ `/studio/${ PKG } /data` ] } >
165+ < StudioSaveHarness > < MemoryRouter initialEntries = { [ `/studio/${ PKG } /data` ] } >
164166 < DataPillar packageId = { PKG } { ...props } />
165- </ MemoryRouter > ,
167+ </ MemoryRouter > </ StudioSaveHarness > ,
166168 ) ;
167169 await waitFor ( ( ) => expect ( screen . getByTestId ( 'records-panel' ) ) . toBeInTheDocument ( ) , { timeout : 8000 } ) ;
168170 await userEvent . click ( screen . getAllByRole ( 'button' , { name : FORM } ) [ 0 ] ) ;
@@ -186,6 +188,7 @@ describe('the Form tab lays out by field groups, internal form or not (objectsta
186188 expect ( screen . queryByTestId ( 'form-layout-flow' ) ) . toBeNull ( ) ;
187189
188190 await userEvent . click ( screen . getByTestId ( 'form-designer-add-section-footer' ) ) ;
191+ await pressStudioSave ( ) ;
189192 await waitFor ( ( ) => expect ( saves ( ) . length ) . toBe ( 1 ) , { timeout : 4000 } ) ;
190193 const [ type , name , body ] = saves ( ) [ 0 ] ;
191194 expect ( [ type , name ] ) . toEqual ( [ 'object' , OBJECT ] ) ;
@@ -219,6 +222,7 @@ describe('the Form tab lays out by field groups, internal form or not (objectsta
219222 expect ( screen . getByText ( UNGROUPED ) ) . toBeInTheDocument ( ) ;
220223
221224 await userEvent . click ( screen . getByTestId ( 'form-designer-add-section-footer' ) ) ;
225+ await pressStudioSave ( ) ;
222226 await waitFor ( ( ) => expect ( saves ( ) . length ) . toBe ( 1 ) , { timeout : 4000 } ) ;
223227 const [ type , name , body ] = saves ( ) [ 0 ] ;
224228 expect ( [ type , name ] ) . toEqual ( [ 'object' , OBJECT ] ) ;
0 commit comments