Skip to content

Commit bbf879f

Browse files
✅ add an e2e test
1 parent de33be9 commit bbf879f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,24 @@ test.describe('API calls and events around init', () => {
207207
const viewContext = await page.evaluate(() => window.DD_RUM?.getViewContext())
208208
expect(viewContext).toEqual({ foo: 'bar' })
209209
})
210+
211+
createTest('context set right after init should be applied to events generated during init')
212+
.withRum()
213+
.withRumInit((configuration) => {
214+
window.DD_RUM!.init(configuration)
215+
window.DD_RUM!.setViewContext({ viewContext: true })
216+
window.DD_RUM!.setGlobalContext({ globalContext: true })
217+
window.DD_RUM!.setUser({ id: 'user-id' })
218+
window.DD_RUM!.addFeatureFlagEvaluation('foo', true)
219+
})
220+
.run(async ({ intakeRegistry, flushEvents }) => {
221+
await flushEvents()
222+
223+
const initialView = intakeRegistry.rumViewEvents[0]
224+
expect(initialView.context).toEqual({ viewContext: true, globalContext: true })
225+
expect(initialView.usr).toEqual(expect.objectContaining({ id: 'user-id' }))
226+
expect(initialView.feature_flags).toEqual({ foo: true })
227+
})
210228
})
211229

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

0 commit comments

Comments
 (0)