Skip to content

Commit

Permalink
🧪 add assembly test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-lebeau committed Jun 3, 2024
1 parent d04d0ac commit b63797b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions packages/rum-core/src/domain/assembly.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,55 @@ describe('rum assembly', () => {
expect((serverRumEvents[0] as RumResourceEvent).resource.graphql).toEqual({ operationType: 'query' })
})
})

fdescribe('fields service and version', () => {
extraConfigurationOptions = {
service: 'foo',
version: '1.0.0',
}

it('by default, it should not be modifiable', () => {
const { lifeCycle } = setupBuilder
.withConfiguration({
beforeSend: (event) => {
event.service = 'bar'
event.version = '0.2.0'

return true
},
})
.build()

notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE, { resource: { url: '/path?foo=bar' } }),
})

expect((serverRumEvents[0] as RumResourceEvent).service).toBe('foo')
expect((serverRumEvents[0] as RumResourceEvent).version).toBe('1.0.0')
})

it('when the micro_frontend experimental flag is set, it should be modifiable', () => {
mockExperimentalFeatures([ExperimentalFeature.MICRO_FRONTEND])

const { lifeCycle } = setupBuilder
.withConfiguration({
beforeSend: (event) => {
event.service = 'bar'
event.version = '0.2.0'

return true
},
})
.build()

notifyRawRumEvent(lifeCycle, {
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE, { resource: { url: '/path?foo=bar' } }),
})

expect((serverRumEvents[0] as RumResourceEvent).service).toBe('bar')
expect((serverRumEvents[0] as RumResourceEvent).version).toBe('0.2.0')
})
})
})

describe('context field', () => {
Expand Down

0 comments on commit b63797b

Please sign in to comment.