@@ -604,6 +604,50 @@ const SLOW_NAVIGATIONS = [
604604] ;
605605
606606test . describe ( "interaction frustration signals" , ( ) => {
607+ async function rageClickUnresponsiveButton ( page : Page ) {
608+ await page . click ( "button" , { clickCount : 3 } ) ;
609+ return page . evaluate (
610+ ( ) => ( window . __tracker as BaseTracker ) . rageClickCount
611+ ) ;
612+ }
613+
614+ test ( "interaction tracking is on without any configuration" , async ( {
615+ page,
616+ } ) => {
617+ await page . goto ( "/test" ) ;
618+ await page . evaluate ( ( ) => {
619+ document . body . innerHTML = `<button type="button" aria-label="pay">Pay</button>` ;
620+ window . databuddyConfig = {
621+ clientId : "test-interactions-default" ,
622+ ignoreBotDetection : true ,
623+ } ;
624+ } ) ;
625+ await page . addScriptTag ( { url : "/dist/databuddy-debug.js" } ) ;
626+ await expect
627+ . poll ( ( ) => page . evaluate ( ( ) => Boolean ( window . __tracker ) ) )
628+ . toBeTruthy ( ) ;
629+ expect ( await rageClickUnresponsiveButton ( page ) ) . toBe ( 1 ) ;
630+ } ) ;
631+
632+ test ( 'data-track-interactions="false" turns interaction tracking off' , async ( {
633+ page,
634+ } ) => {
635+ await page . goto ( "/test" ) ;
636+ await page . evaluate ( ( ) => {
637+ document . body . innerHTML = `<button type="button" aria-label="pay">Pay</button>` ;
638+ const script = document . createElement ( "script" ) ;
639+ script . src = "/dist/databuddy-debug.js" ;
640+ script . dataset . clientId = "test-interactions-opt-out" ;
641+ script . dataset . ignoreBotDetection = "true" ;
642+ script . dataset . trackInteractions = "false" ;
643+ document . head . append ( script ) ;
644+ } ) ;
645+ await expect
646+ . poll ( ( ) => page . evaluate ( ( ) => Boolean ( window . __tracker ) ) )
647+ . toBeTruthy ( ) ;
648+ expect ( await rageClickUnresponsiveButton ( page ) ) . toBe ( 0 ) ;
649+ } ) ;
650+
607651 for ( const { name, markup, act } of ORDINARY_CLICKS ) {
608652 test ( `${ name } is neither a rage nor a dead click` , async ( { page } ) => {
609653 await loadFixture ( page , markup ) ;
0 commit comments