@@ -212,6 +212,79 @@ describe("other methods", () => {
212212 expect ( resp . scripts [ 1 ] as ScriptOrFolder ) . toHaveProperty ( "isFolder" ) ;
213213 } ) ;
214214
215+ it ( "should retrieve layout metadata with only the layout parameter" , async ( ) => {
216+ const client = DataApi ( {
217+ adapter : new OttoAdapter ( {
218+ auth : config . auth ,
219+ db : config . db ,
220+ server : config . server ,
221+ } ) ,
222+ } ) ;
223+ const layoutName = "layout" ; // Assuming "layout" is a valid layout in the test DB
224+
225+ // Call the method with only the required layout parameter
226+ const response = await client . layoutMetadata ( { layout : layoutName } ) ;
227+
228+ // Assertion 1: Ensure the call succeeded and returned a response object
229+ expect ( response ) . toBeDefined ( ) ;
230+ expect ( response ) . toBeTypeOf ( "object" ) ;
231+
232+ // Assertion 2: Check for the presence of core metadata properties
233+ expect ( response ) . toHaveProperty ( "fieldMetaData" ) ;
234+ expect ( response ) . toHaveProperty ( "portalMetaData" ) ;
235+ // valueLists is optional, check type if present
236+ if ( response . valueLists ) {
237+ expect ( Array . isArray ( response . valueLists ) ) . toBe ( true ) ;
238+ }
239+
240+ // Assertion 3: Verify the types of the core properties
241+ expect ( Array . isArray ( response . fieldMetaData ) ) . toBe ( true ) ;
242+ expect ( typeof response . portalMetaData ) . toBe ( "object" ) ;
243+
244+ // Assertion 4 (Optional but recommended): Check structure of metadata
245+ if ( response . fieldMetaData . length > 0 ) {
246+ expect ( response . fieldMetaData [ 0 ] ) . toHaveProperty ( "name" ) ;
247+ expect ( response . fieldMetaData [ 0 ] ) . toHaveProperty ( "type" ) ;
248+ }
249+ } ) ;
250+
251+ it ( "should retrieve layout metadata when layout is configured on the client" , async ( ) => {
252+ const client = DataApi ( {
253+ adapter : new OttoAdapter ( {
254+ auth : config . auth ,
255+ db : config . db ,
256+ server : config . server ,
257+ } ) ,
258+ layout : "layout" , // Configure layout on the client
259+ } ) ;
260+
261+ // Call the method without the layout parameter (expecting it to use the client's layout)
262+ // No arguments should be needed when layout is configured on the client.
263+ const response = await client . layoutMetadata ( ) ;
264+
265+ // Assertion 1: Ensure the call succeeded and returned a response object
266+ expect ( response ) . toBeDefined ( ) ;
267+ expect ( response ) . toBeTypeOf ( "object" ) ;
268+
269+ // Assertion 2: Check for the presence of core metadata properties
270+ expect ( response ) . toHaveProperty ( "fieldMetaData" ) ;
271+ expect ( response ) . toHaveProperty ( "portalMetaData" ) ;
272+ // valueLists is optional, check type if present
273+ if ( response . valueLists ) {
274+ expect ( Array . isArray ( response . valueLists ) ) . toBe ( true ) ;
275+ }
276+
277+ // Assertion 3: Verify the types of the core properties
278+ expect ( Array . isArray ( response . fieldMetaData ) ) . toBe ( true ) ;
279+ expect ( typeof response . portalMetaData ) . toBe ( "object" ) ;
280+
281+ // Assertion 4 (Optional but recommended): Check structure of metadata
282+ if ( response . fieldMetaData . length > 0 ) {
283+ expect ( response . fieldMetaData [ 0 ] ) . toHaveProperty ( "name" ) ;
284+ expect ( response . fieldMetaData [ 0 ] ) . toHaveProperty ( "type" ) ;
285+ }
286+ } ) ;
287+
215288 it ( "should paginate through all records" , async ( ) => {
216289 const client = DataApi ( {
217290 adapter : new OttoAdapter ( {
0 commit comments