Skip to content

Commit e28ba32

Browse files
✅ add an e2e test
1 parent 999ab87 commit e28ba32

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/e2e/scenario/rum/init.scenario.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,24 @@ test.describe('API calls and events around init', () => {
183183
const viewContext = await page.evaluate(() => window.DD_RUM?.getViewContext())
184184
expect(viewContext).toEqual({ foo: 'bar' })
185185
})
186+
187+
createTest('context set right after init should be applied to events generated during init')
188+
.withRum()
189+
.withRumInit((configuration) => {
190+
window.DD_RUM!.init(configuration)
191+
window.DD_RUM!.setViewContext({ viewContext: true })
192+
window.DD_RUM!.setGlobalContext({ globalContext: true })
193+
window.DD_RUM!.setUser({ id: 'user-id' })
194+
window.DD_RUM!.addFeatureFlagEvaluation('foo', true)
195+
})
196+
.run(async ({ intakeRegistry, flushEvents }) => {
197+
await flushEvents()
198+
199+
const initialView = intakeRegistry.rumViewEvents[0]
200+
expect(initialView.context).toEqual({ viewContext: true, globalContext: true })
201+
expect(initialView.usr).toEqual(expect.objectContaining({ id: 'user-id' }))
202+
expect(initialView.feature_flags).toEqual({ foo: true })
203+
})
186204
})
187205

188206
test.describe('beforeSend', () => {

0 commit comments

Comments
 (0)