@@ -2363,6 +2363,71 @@ describe("KnockGuideClient", () => {
23632363 expect ( result2 ! . type ) . toBe ( "banner" ) ;
23642364 } ) ;
23652365
2366+ test ( "returns a guide inside a throttle window when ignoreDisplayInterval is true" , ( ) => {
2367+ const stateWithGuides = {
2368+ guideGroups : [
2369+ {
2370+ ...mockDefaultGroup ,
2371+ display_interval : 5 * 60 , // 5 minutes
2372+ } ,
2373+ ] ,
2374+ guideGroupDisplayLogs : {
2375+ default : new Date ( ) . toISOString ( ) ,
2376+ } ,
2377+ guides : mockGuides ,
2378+ ineligibleGuides : { } ,
2379+ previewGuides : { } ,
2380+ queries : { } ,
2381+ location : undefined ,
2382+ counter : 0 ,
2383+ debug : {
2384+ debugging : true ,
2385+ ignoreDisplayInterval : true ,
2386+ forcedGuideKey : null ,
2387+ previewSessionId : null ,
2388+ } ,
2389+ } ;
2390+
2391+ const client = new KnockGuideClient ( mockKnock , channelId ) ;
2392+ const result = client [ "_selectGuide" ] ( stateWithGuides ) ;
2393+
2394+ // Even though we are inside the configured throttle window,
2395+ // ignoreDisplayInterval bypasses it.
2396+ expect ( result ) . toBeDefined ( ) ;
2397+ expect ( result ! . key ) . toBe ( "feature_tour" ) ;
2398+ } ) ;
2399+
2400+ test ( "does not return a guide inside a throttle window when ignoreDisplayInterval is false" , ( ) => {
2401+ const stateWithGuides = {
2402+ guideGroups : [
2403+ {
2404+ ...mockDefaultGroup ,
2405+ display_interval : 5 * 60 , // 5 minutes
2406+ } ,
2407+ ] ,
2408+ guideGroupDisplayLogs : {
2409+ default : new Date ( ) . toISOString ( ) ,
2410+ } ,
2411+ guides : mockGuides ,
2412+ ineligibleGuides : { } ,
2413+ previewGuides : { } ,
2414+ queries : { } ,
2415+ location : undefined ,
2416+ counter : 0 ,
2417+ debug : {
2418+ debugging : true ,
2419+ ignoreDisplayInterval : false ,
2420+ forcedGuideKey : null ,
2421+ previewSessionId : null ,
2422+ } ,
2423+ } ;
2424+
2425+ const client = new KnockGuideClient ( mockKnock , channelId ) ;
2426+ const result = client [ "_selectGuide" ] ( stateWithGuides ) ;
2427+
2428+ expect ( result ) . toBeUndefined ( ) ;
2429+ } ) ;
2430+
23662431 test ( "skips ineligible guides during selection" , ( ) => {
23672432 const stateWithGuides = {
23682433 guideGroups : [ mockDefaultGroup ] ,
@@ -4234,6 +4299,34 @@ describe("KnockGuideClient", () => {
42344299
42354300 expect ( client . store . state . debug ! . skipEngagementTracking ) . toBe ( false ) ;
42364301 } ) ;
4302+
4303+ test ( "defaults ignoreDisplayInterval to true" , ( ) => {
4304+ const client = new KnockGuideClient ( mockKnock , channelId ) ;
4305+ client . store . state . debug = undefined ;
4306+
4307+ vi . spyOn ( client , "fetch" ) . mockImplementation ( ( ) =>
4308+ Promise . resolve ( { status : "ok" } ) ,
4309+ ) ;
4310+ vi . spyOn ( client , "subscribe" ) . mockImplementation ( ( ) => { } ) ;
4311+
4312+ client . setDebug ( ) ;
4313+
4314+ expect ( client . store . state . debug ! . ignoreDisplayInterval ) . toBe ( true ) ;
4315+ } ) ;
4316+
4317+ test ( "allows overriding ignoreDisplayInterval to false" , ( ) => {
4318+ const client = new KnockGuideClient ( mockKnock , channelId ) ;
4319+ client . store . state . debug = undefined ;
4320+
4321+ vi . spyOn ( client , "fetch" ) . mockImplementation ( ( ) =>
4322+ Promise . resolve ( { status : "ok" } ) ,
4323+ ) ;
4324+ vi . spyOn ( client , "subscribe" ) . mockImplementation ( ( ) => { } ) ;
4325+
4326+ client . setDebug ( { ignoreDisplayInterval : false } ) ;
4327+
4328+ expect ( client . store . state . debug ! . ignoreDisplayInterval ) . toBe ( false ) ;
4329+ } ) ;
42374330 } ) ;
42384331
42394332 describe ( "unsetDebug" , ( ) => {
0 commit comments