Skip to content

Commit

Permalink
πŸš©πŸ› enable fix #1979
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Feb 6, 2023
1 parent 58db7ee commit f848091
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,34 +430,24 @@ describe('trackClickActions', () => {
expect(events[0].frustrationTypes).toEqual([FrustrationType.DEAD_CLICK])
})

describe('dead_click_fixes experimental feature', () => {
beforeEach(() => {
updateExperimentalFeatures(['dead_click_fixes'])
})

afterEach(() => {
resetExperimentalFeatures()
})

it('does not consider a click with activity happening on pointerdown as a dead click', () => {
const { clock } = setupBuilder.build()
it('does not consider a click with activity happening on pointerdown as a dead click', () => {
const { clock } = setupBuilder.build()

emulateClick({ activity: { on: 'pointerdown' } })
emulateClick({ activity: { on: 'pointerdown' } })

clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].frustrationTypes).toEqual([])
})
clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].frustrationTypes).toEqual([])
})

it('activity happening on pointerdown is not taken into account for the action duration', () => {
const { clock } = setupBuilder.build()
it('activity happening on pointerdown is not taken into account for the action duration', () => {
const { clock } = setupBuilder.build()

emulateClick({ activity: { on: 'pointerdown' } })
emulateClick({ activity: { on: 'pointerdown' } })

clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].duration).toBe(0 as Duration)
})
clock.tick(EXPIRE_DELAY)
expect(events.length).toBe(1)
expect(events[0].duration).toBe(0 as Duration)
})

it('does not consider a click with activity happening on pointerup as a dead click', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,17 @@ function processPointerDown(

let hadActivityOnPointerDown = false

if (isExperimentalFeatureEnabled('dead_click_fixes')) {
waitPageActivityEnd(
lifeCycle,
domMutationObservable,
configuration,
(pageActivityEndEvent) => {
hadActivityOnPointerDown = pageActivityEndEvent.hadActivity
},
// We don't care about the activity duration, we just want to know whether an activity did happen
// within the "validation delay" or not. Limit the duration so the callback is called sooner.
PAGE_ACTIVITY_VALIDATION_DELAY
)
}
waitPageActivityEnd(
lifeCycle,
domMutationObservable,
configuration,
(pageActivityEndEvent) => {
hadActivityOnPointerDown = pageActivityEndEvent.hadActivity
},
// We don't care about the activity duration, we just want to know whether an activity did happen
// within the "validation delay" or not. Limit the duration so the callback is called sooner.
PAGE_ACTIVITY_VALIDATION_DELAY
)

return { clickActionBase, hadActivityOnPointerDown: () => hadActivityOnPointerDown }
}
Expand Down

0 comments on commit f848091

Please sign in to comment.