Skip to content

Commit

Permalink
[RUM-3887] Add unit and E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Boutaib committed May 23, 2024
1 parent c5e1614 commit 488177d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/rum/src/boot/recorderApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ describe('makeRecorderApi', () => {
expect(startRecordingSpy).not.toHaveBeenCalled()
})

it('should start recording if session is tracked without session replay when forced', () => {
setupBuilder.withSessionManager(createRumSessionManagerMock().setTrackedWithoutSessionReplay()).build()
rumInit()
recorderApi.start({ force: true })
expect(startRecordingSpy).toHaveBeenCalledTimes(1)
})

it('uses the previously created worker if available', () => {
setupBuilder.build()
rumInit({ worker: mockWorker })
Expand Down
28 changes: 28 additions & 0 deletions test/e2e/scenario/recorder/recorder.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,34 @@ describe('recorder', () => {
})
})

describe('recording of sampled out sessions', () => {
createTest('should not start recording when session is sampled out')
.withRum({ sessionReplaySampleRate: 0 })
.withSetup(bundleSetup)
.run(async ({ intakeRegistry }) => {
await browser.execute(() => {
window.DD_RUM!.startSessionReplayRecording()
})

await flushEvents()

expect(intakeRegistry.replaySegments.length).toBe(0)
})

createTest('should start recording if forced when session is sampled out')
.withRum({ sessionReplaySampleRate: 0 })
.withSetup(bundleSetup)
.run(async ({ intakeRegistry }) => {
await browser.execute(() => {
window.DD_RUM!.startSessionReplayRecording({ force: true })
})

await flushEvents()

expect(intakeRegistry.replaySegments.length).toBe(1)
})
})

createTest('restarting recording should send a new full snapshot')
.withRum()
.withSetup(bundleSetup)
Expand Down

0 comments on commit 488177d

Please sign in to comment.