@@ -781,3 +781,46 @@ test.describe('custom actions with startAction/stopAction', () => {
781781 expect ( relatedFetch ) . toBeDefined ( )
782782 } )
783783} )
784+
785+ test . describe ( 'action collection with composed path selector' , ( ) => {
786+ createTest ( 'should not return a composed_path_selector if flag is disabled' )
787+ . withRum ( { trackUserInteractions : true } )
788+ . withBody ( html `
789+ < div id ="container ">
790+ < button > Click</ button >
791+ < button id ="my-button " data-test-allowed ="test-btn " data-random ="secret " class ="foo bar baz "> Click me</ button >
792+ </ div >
793+ ` )
794+ . run ( async ( { intakeRegistry, flushEvents, page } ) => {
795+ const button = page . locator ( '#my-button' )
796+ await button . click ( )
797+ await flushEvents ( )
798+
799+ const actionEvents = intakeRegistry . rumActionEvents
800+ expect ( actionEvents ) . toHaveLength ( 1 )
801+ expect ( actionEvents [ 0 ] . _dd . action ?. target ?. composed_path_selector ) . toBeUndefined ( )
802+ } )
803+ createTest ( 'should return a composed_path_selector if flag is enabled' )
804+ . withRum ( {
805+ trackUserInteractions : true ,
806+ enableExperimentalFeatures : [ 'composed_path_selector' ] ,
807+ allowedHtmlAttributes : [ 'data-test-allowed' ] ,
808+ } )
809+ . withBody ( html `
810+ < div id ="container ">
811+ < button > Click</ button >
812+ < button id ="my-button " data-test-allowed ="test-btn " data-random ="secret " class ="foo bar baz "> Click me</ button >
813+ </ div >
814+ ` )
815+ . run ( async ( { intakeRegistry, flushEvents, page } ) => {
816+ const button = page . locator ( '#my-button' )
817+ await button . click ( )
818+ await flushEvents ( )
819+
820+ const actionEvents = intakeRegistry . rumActionEvents
821+ expect ( actionEvents ) . toHaveLength ( 1 )
822+ expect ( actionEvents [ 0 ] . _dd . action ?. target ?. composed_path_selector ) . toBe (
823+ 'BUTTON#my-button[data-test-allowed="test-btn"].bar.baz.foo:nth-child(2):nth-of-type(2);DIV#container;'
824+ )
825+ } )
826+ } )
0 commit comments