@@ -781,3 +781,42 @@ 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+ < button > Click</ button >
790+ < button id ="my-button " data-test-allowed ="test-btn " data-random ="secret " class ="foo bar baz "> Click me</ button >
791+ ` )
792+ . run ( async ( { intakeRegistry, flushEvents, page } ) => {
793+ const button = page . locator ( '#my-button' )
794+ await button . click ( )
795+ await flushEvents ( )
796+
797+ const actionEvents = intakeRegistry . rumActionEvents
798+ expect ( actionEvents ) . toHaveLength ( 1 )
799+ expect ( actionEvents [ 0 ] . _dd . action ?. target ?. composed_path_selector ) . toBeUndefined ( )
800+ } )
801+ createTest ( 'should return a composed_path_selector if flag is enabled' )
802+ . withRum ( {
803+ trackUserInteractions : true ,
804+ enableExperimentalFeatures : [ 'composed_path_selector' ] ,
805+ allowedHtmlAttributes : [ 'data-test-allowed' ] ,
806+ } )
807+ . withBody ( html `
808+ < button > Click</ button >
809+ < button id ="my-button " data-test-allowed ="test-btn " data-random ="secret " class ="foo bar baz "> Click me</ button >
810+ ` )
811+ . run ( async ( { intakeRegistry, flushEvents, page } ) => {
812+ const button = page . locator ( '#my-button' )
813+ await button . click ( )
814+ await flushEvents ( )
815+
816+ const actionEvents = intakeRegistry . rumActionEvents
817+ expect ( actionEvents ) . toHaveLength ( 1 )
818+ expect ( actionEvents [ 0 ] . _dd . action ?. target ?. composed_path_selector ) . toBe (
819+ 'BUTTON#my-button[data-test-allowed="test-btn"].bar.baz.foo:nth-child(2):nth-of-type(2);'
820+ )
821+ } )
822+ } )
0 commit comments