Skip to content

Commit

Permalink
✅ [RUM-253] add E2E tests related to compression
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Sep 5, 2023
1 parent 83f9442 commit 64156e4
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/e2e/scenario/transport.scenario.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { ExperimentalFeature } from '@datadog/browser-core'
import { createTest, flushEvents } from '../lib/framework'
import { withBrowserLogs } from '../lib/helpers/browser'

describe('transport', () => {
describe('data compression', () => {
createTest('send RUM data compressed')
.withRum({
enableExperimentalFeatures: [ExperimentalFeature.COMPRESS_BATCH],
})
.run(async ({ intakeRegistry }) => {
await flushEvents()

expect(intakeRegistry.rumRequests.length).toBe(2)

const plainRequest = intakeRegistry.rumRequests.find((request) => request.encoding === null)
const deflateRequest = intakeRegistry.rumRequests.find((request) => request.encoding === 'deflate')

// The last view update should be sent without compression
expect(plainRequest!.events).toEqual([
jasmine.objectContaining({
type: 'view',
}),
])

// Other data should be sent encoded
expect(deflateRequest!.events.length).toBeGreaterThan(0)
})

createTest("displays a message if the worker can't be started")
.withRum({
enableExperimentalFeatures: [ExperimentalFeature.COMPRESS_BATCH],
})
.withBasePath('/no-blob-worker-csp')
.run(async ({ intakeRegistry }) => {
await flushEvents()

expect(intakeRegistry.rumRequests.length).toBe(0)

await withBrowserLogs((logs) => {
const failedToStartLog = logs.find((log) => log.message.includes('Datadog RUM failed to start'))
const cspDocLog = logs.find((log) => log.message.includes('Please make sure CSP'))
expect(failedToStartLog).withContext("'Failed to start' log").toBeTruthy()
expect(cspDocLog).withContext("'CSP doc' log").toBeTruthy()
})
})
})
})

0 comments on commit 64156e4

Please sign in to comment.