@@ -361,6 +361,116 @@ describe('Entry API Tests', () => {
361361 } )
362362 } )
363363
364+ // ==========================================================================
365+ // MASTER COVERAGE: asset_fields, localize, publish (cases added with feature/fix)
366+ // ==========================================================================
367+
368+ describe ( 'Entry asset_fields, localize and publish (master coverage)' , ( ) => {
369+ before ( function ( ) {
370+ if ( ! mediumCtReady ) {
371+ console . log ( ' Skipping: Medium content type not available' )
372+ this . skip ( )
373+ }
374+ } )
375+
376+ it ( 'should entry fetch with asset_fields parameter - single value' , async function ( ) {
377+ this . timeout ( 15000 )
378+ const uid = testData . entries ?. medium ?. uid
379+ if ( ! uid ) this . skip ( )
380+ const entry = await stack . contentType ( mediumCtUid ) . entry ( uid ) . fetch ( { asset_fields : [ 'user_defined_fields' ] } )
381+ trackedExpect ( entry . uid , 'Entry UID' ) . toEqual ( uid )
382+ } )
383+
384+ it ( 'should entry fetch with asset_fields parameter - multiple values' , async function ( ) {
385+ this . timeout ( 15000 )
386+ const uid = testData . entries ?. medium ?. uid
387+ if ( ! uid ) this . skip ( )
388+ const entry = await stack . contentType ( mediumCtUid ) . entry ( uid ) . fetch ( { asset_fields : [ 'user_defined_fields' , 'embedded' , 'ai_suggested' , 'visual_markups' ] } )
389+ trackedExpect ( entry . uid , 'Entry UID' ) . toEqual ( uid )
390+ } )
391+
392+ it ( 'should localize entry with title update' , async function ( ) {
393+ this . timeout ( 15000 )
394+ const uid = testData . entries ?. medium ?. uid
395+ if ( ! uid ) this . skip ( )
396+ // Use a locale that exists on the dynamic stack (create if missing)
397+ const locales = await stack . locale ( ) . query ( ) . find ( )
398+ const items = locales . items || locales . locales || [ ]
399+ const enAt = items . find ( l => l . code === 'en-at' )
400+ if ( ! enAt ) {
401+ try {
402+ await stack . locale ( ) . create ( {
403+ locale : { code : 'en-at' , name : 'English (Austria)' , fallback_locale : 'en-us' }
404+ } )
405+ } catch ( e ) {
406+ this . skip ( ) // locale may already exist or stack doesn't support it
407+ return
408+ }
409+ }
410+ const entry = await stack . contentType ( mediumCtUid ) . entry ( uid ) . fetch ( )
411+ entry . title = 'Sample Entry in en-at'
412+ const response = await entry . update ( { locale : 'en-at' } )
413+ expect ( response . title ) . to . equal ( 'Sample Entry in en-at' )
414+ expect ( response . uid ) . to . be . a ( 'string' )
415+ expect ( response . locale ) . to . equal ( 'en-at' )
416+ } )
417+
418+ it ( 'should get all Entry with asset_fields parameter - single value' , async function ( ) {
419+ this . timeout ( 15000 )
420+ const collection = await stack . contentType ( mediumCtUid ) . entry ( ) . query ( { include_count : true , asset_fields : [ 'user_defined_fields' ] } ) . find ( )
421+ expect ( collection ) . to . be . an ( 'object' )
422+ if ( collection . count !== undefined ) {
423+ expect ( collection . count ) . to . be . a ( 'number' )
424+ }
425+ expect ( collection . items ) . to . be . an ( 'array' )
426+ collection . items . forEach ( ( entry ) => {
427+ expect ( entry . uid ) . to . be . a ( 'string' )
428+ expect ( entry . content_type_uid ) . to . equal ( mediumCtUid )
429+ } )
430+ } )
431+
432+ it ( 'should get all Entry with asset_fields parameter - multiple values' , async function ( ) {
433+ this . timeout ( 15000 )
434+ const collection = await stack . contentType ( mediumCtUid ) . entry ( ) . query ( { include_count : true , asset_fields : [ 'user_defined_fields' , 'embedded' , 'ai_suggested' , 'visual_markups' ] } ) . find ( )
435+ expect ( collection . items ) . to . be . an ( 'array' )
436+ collection . items . forEach ( ( entry ) => {
437+ expect ( entry . uid ) . to . be . a ( 'string' )
438+ expect ( entry . content_type_uid ) . to . equal ( mediumCtUid )
439+ } )
440+ } )
441+
442+ it ( 'should get all Entry with asset_fields parameter combined with other query params' , async function ( ) {
443+ this . timeout ( 15000 )
444+ const collection = await stack . contentType ( mediumCtUid ) . entry ( ) . query ( {
445+ include_count : true ,
446+ include_content_type : true ,
447+ asset_fields : [ 'user_defined_fields' , 'embedded' ]
448+ } ) . find ( )
449+ expect ( collection . items ) . to . be . an ( 'array' )
450+ collection . items . forEach ( ( entry ) => {
451+ expect ( entry . uid ) . to . be . a ( 'string' )
452+ expect ( entry . content_type_uid ) . to . equal ( mediumCtUid )
453+ } )
454+ } )
455+
456+ it ( 'should publish Entry' , async function ( ) {
457+ this . timeout ( 15000 )
458+ const uid = testData . entries ?. medium ?. uid
459+ if ( ! uid ) this . skip ( )
460+ // Use environment that exists on dynamic stack
461+ const envName = testData . environments ?. development ?. name || 'development'
462+ const entry = await stack . contentType ( mediumCtUid ) . entry ( uid )
463+ const response = await entry . publish ( {
464+ publishDetails : {
465+ locales : [ 'en-us' ] ,
466+ environments : [ envName ]
467+ }
468+ } )
469+ expect ( response ) . to . be . an ( 'object' )
470+ trackedExpect ( response . uid ?? response . entry_uid , 'Published entry' ) . toBeA ( 'string' )
471+ } )
472+ } )
473+
364474 // ==========================================================================
365475 // ENTRY CRUD OPERATIONS
366476 // ==========================================================================
0 commit comments