-
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.
Browse files
Browse the repository at this point in the history
* ✅♻️ [RUM-253] move segment file infos into a property * ✅ [RUM-253] read encoded requests and expose the 'encoding' on IntakeRequest objects * ✅ [RUM-253] add E2E tests related to compression
- Loading branch information
1 parent
0013510
commit 0c81b8e
Showing
4 changed files
with
111 additions
and
26 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
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
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
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() | ||
}) | ||
}) | ||
} | ||
}) | ||
}) |