-
Notifications
You must be signed in to change notification settings - Fork 141
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
519f1f3
commit 735e91c
Showing
1 changed file
with
55 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,55 @@ | ||
import { ExperimentalFeature } from '@datadog/browser-core' | ||
import { createTest, flushEvents } from '../lib/framework' | ||
import { getBrowserName, getPlatformName, 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) | ||
}) | ||
|
||
// Ignore this test on Safari desktop and Firefox because the Worker actually works even with | ||
// CSP restriction. | ||
// TODO: Remove this condition when upgrading to Safari 15 and Firefox 99 | ||
if (!((getBrowserName() === 'safari' && getPlatformName() === 'macos') || getBrowserName() === 'firefox')) { | ||
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() | ||
|
||
// Some non-deflate request can still be sent because on some browsers the Worker fails | ||
// asynchronously | ||
expect(intakeRegistry.rumRequests.filter((request) => request.encoding === 'deflate').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() | ||
}) | ||
}) | ||
} | ||
}) | ||
}) |