@@ -536,6 +536,182 @@ describe('Entry API Tests', () => {
536536 } )
537537 } )
538538
539+ // ==========================================================================
540+ // DAM 2.0 - ASSET FIELDS QUERY PARAMETER
541+ // Note: These tests are for AM 2.0 feature which is still in development.
542+ // Set DAM_2_0_ENABLED=true in .env to enable these tests once the feature is available.
543+ // ==========================================================================
544+
545+ describe ( 'DAM 2.0 - Asset Fields Query Parameter' , ( ) => {
546+ let assetFieldsEntryUid
547+ let dam20Enabled = false
548+
549+ before ( async function ( ) {
550+ this . timeout ( 30000 )
551+
552+ // Check if DAM 2.0 feature is enabled via env variable
553+ if ( process . env . DAM_2_0_ENABLED !== 'true' ) {
554+ console . log ( ' DAM 2.0 tests skipped: Set DAM_2_0_ENABLED=true in .env to enable' )
555+ this . skip ( )
556+ return
557+ }
558+
559+ dam20Enabled = true
560+
561+ if ( ! mediumCtReady ) {
562+ console . log ( ' Skipping: Medium content type not available' )
563+ this . skip ( )
564+ return
565+ }
566+
567+ // Create an entry for asset_fields testing
568+ try {
569+ const entryData = {
570+ entry : {
571+ title : `Asset Fields Test ${ Date . now ( ) } ` ,
572+ summary : 'Entry for testing asset_fields parameter'
573+ }
574+ }
575+ const entry = await stack . contentType ( mediumCtUid ) . entry ( ) . create ( entryData )
576+ assetFieldsEntryUid = entry . uid
577+ console . log ( ` ✓ Created entry for asset_fields tests: ${ assetFieldsEntryUid } ` )
578+ await wait ( 2000 )
579+ } catch ( e ) {
580+ console . log ( ` ✗ Failed to create entry for asset_fields tests: ${ e . message } ` )
581+ }
582+ } )
583+
584+ // ----- FETCH with asset_fields -----
585+
586+ it ( 'should fetch entry with asset_fields parameter - single value' , async function ( ) {
587+ this . timeout ( 15000 )
588+ if ( ! assetFieldsEntryUid ) this . skip ( )
589+
590+ const entry = await stack . contentType ( mediumCtUid ) . entry ( assetFieldsEntryUid )
591+ . fetch ( { asset_fields : [ 'user_defined_fields' ] } )
592+
593+ expect ( entry ) . to . be . an ( 'object' )
594+ expect ( entry . uid ) . to . equal ( assetFieldsEntryUid )
595+ } )
596+
597+ it ( 'should fetch entry with asset_fields parameter - multiple values' , async function ( ) {
598+ this . timeout ( 15000 )
599+ if ( ! assetFieldsEntryUid ) this . skip ( )
600+
601+ const entry = await stack . contentType ( mediumCtUid ) . entry ( assetFieldsEntryUid )
602+ . fetch ( {
603+ asset_fields : [ 'user_defined_fields' , 'embedded' , 'ai_suggested' , 'visual_markups' ]
604+ } )
605+
606+ expect ( entry ) . to . be . an ( 'object' )
607+ expect ( entry . uid ) . to . equal ( assetFieldsEntryUid )
608+ } )
609+
610+ it ( 'should fetch entry with asset_fields combined with other params' , async function ( ) {
611+ this . timeout ( 15000 )
612+ if ( ! assetFieldsEntryUid ) this . skip ( )
613+
614+ const entry = await stack . contentType ( mediumCtUid ) . entry ( assetFieldsEntryUid )
615+ . fetch ( {
616+ locale : 'en-us' ,
617+ include_workflow : true ,
618+ include_publish_details : true ,
619+ asset_fields : [ 'user_defined_fields' , 'embedded' ]
620+ } )
621+
622+ expect ( entry ) . to . be . an ( 'object' )
623+ expect ( entry . uid ) . to . equal ( assetFieldsEntryUid )
624+ } )
625+
626+ // ----- QUERY with asset_fields -----
627+
628+ it ( 'should query entries with asset_fields parameter - single value' , async function ( ) {
629+ this . timeout ( 15000 )
630+ if ( ! mediumCtReady ) this . skip ( )
631+
632+ const response = await stack . contentType ( mediumCtUid ) . entry ( )
633+ . query ( {
634+ include_count : true ,
635+ asset_fields : [ 'user_defined_fields' ]
636+ } )
637+ . find ( )
638+
639+ expect ( response ) . to . be . an ( 'object' )
640+ const entries = response . items || response . entries || [ ]
641+ expect ( entries ) . to . be . an ( 'array' )
642+ if ( response . count !== undefined ) {
643+ expect ( response . count ) . to . be . a ( 'number' )
644+ }
645+ } )
646+
647+ it ( 'should query entries with asset_fields parameter - multiple values' , async function ( ) {
648+ this . timeout ( 15000 )
649+ if ( ! mediumCtReady ) this . skip ( )
650+
651+ const response = await stack . contentType ( mediumCtUid ) . entry ( )
652+ . query ( {
653+ include_count : true ,
654+ asset_fields : [ 'user_defined_fields' , 'embedded' , 'ai_suggested' , 'visual_markups' ]
655+ } )
656+ . find ( )
657+
658+ expect ( response ) . to . be . an ( 'object' )
659+ const entries = response . items || response . entries || [ ]
660+ expect ( entries ) . to . be . an ( 'array' )
661+ } )
662+
663+ it ( 'should query entries with asset_fields combined with other query params' , async function ( ) {
664+ this . timeout ( 15000 )
665+ if ( ! mediumCtReady ) this . skip ( )
666+
667+ const response = await stack . contentType ( mediumCtUid ) . entry ( )
668+ . query ( {
669+ include_count : true ,
670+ include_content_type : true ,
671+ locale : 'en-us' ,
672+ asset_fields : [ 'user_defined_fields' , 'embedded' ]
673+ } )
674+ . find ( )
675+
676+ expect ( response ) . to . be . an ( 'object' )
677+ const entries = response . items || response . entries || [ ]
678+ expect ( entries ) . to . be . an ( 'array' )
679+ } )
680+
681+ // ----- Edge cases -----
682+
683+ it ( 'should handle empty asset_fields array gracefully' , async function ( ) {
684+ this . timeout ( 15000 )
685+ if ( ! assetFieldsEntryUid ) this . skip ( )
686+
687+ try {
688+ const entry = await stack . contentType ( mediumCtUid ) . entry ( assetFieldsEntryUid )
689+ . fetch ( { asset_fields : [ ] } )
690+
691+ expect ( entry ) . to . be . an ( 'object' )
692+ expect ( entry . uid ) . to . equal ( assetFieldsEntryUid )
693+ } catch ( error ) {
694+ // Some APIs may reject empty array - that's also acceptable
695+ expect ( error ) . to . exist
696+ }
697+ } )
698+
699+ it ( 'should fetch entry with all supported asset_fields values' , async function ( ) {
700+ this . timeout ( 15000 )
701+ if ( ! assetFieldsEntryUid ) this . skip ( )
702+
703+ // Test all four supported values from DAM 2.0
704+ const allAssetFields = [ 'user_defined_fields' , 'embedded' , 'ai_suggested' , 'visual_markups' ]
705+
706+ const entry = await stack . contentType ( mediumCtUid ) . entry ( assetFieldsEntryUid )
707+ . fetch ( { asset_fields : allAssetFields } )
708+
709+ expect ( entry ) . to . be . an ( 'object' )
710+ expect ( entry . uid ) . to . equal ( assetFieldsEntryUid )
711+ expect ( entry . title ) . to . include ( 'Asset Fields Test' )
712+ } )
713+ } )
714+
539715 // ==========================================================================
540716 // ERROR HANDLING
541717 // ==========================================================================
0 commit comments