-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ [RUM-253] add E2E tests related to compression
- Loading branch information
1 parent
83f9442
commit 64156e4
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
}) | ||
}) | ||
}) |