Skip to content

Commit d511589

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

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,22 @@ 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+
})
195+
.run(async ({ intakeRegistry, flushEvents }) => {
196+
await flushEvents()
197+
198+
const initialView = intakeRegistry.rumViewEvents[0]
199+
expect(initialView.context).toEqual({ viewContext: true, globalContext: true })
200+
expect(initialView.usr).toEqual(expect.objectContaining({ id: 'user-id' }))
201+
})
186202
})
187203

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

0 commit comments

Comments
 (0)