Skip to content

Commit

Permalink
✅ [RUMF-1258] add a E2E test for view action counters
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed May 11, 2022
1 parent 63a7413 commit af79d16
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/e2e/scenario/rum/actions.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,38 @@ describe('action collection', () => {
expect(resourceEvents[0].action!.id).toBe(actionEvents[0].action.id!)
})

createTest('increment the view.action.count of the view active when the action started')
.withRum({
// Frustrations need to be collected for this test case, else actions leading to a new view
// are ignored
trackFrustrations: true,
enableExperimentalFeatures: ['frustration-signals'],
})
.withBody(
html`
<button>click me</button>
<script>
const button = document.querySelector('button')
button.addEventListener('click', () => {
history.pushState(null, null, '/other-view')
})
</script>
`
)
.run(async ({ serverEvents }) => {
const button = await $('button')
await button.click()
await flushEvents()
const actionEvents = serverEvents.rumActions
expect(actionEvents.length).toBe(1)

const viewEvents = serverEvents.rumViews
const originalViewEvent = viewEvents.find((view) => view.view.url.endsWith('/'))!
const otherViewEvent = viewEvents.find((view) => view.view.url.endsWith('/other-view'))!
expect(originalViewEvent.view.action.count).toBe(1)
expect(otherViewEvent.view.action.count).toBe(0)
})

createTest('collect an "error click"')
.withRum({ trackFrustrations: true, enableExperimentalFeatures: ['frustration-signals'] })
.withBody(
Expand Down

0 comments on commit af79d16

Please sign in to comment.