Skip to content

Commit

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

describe('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 Expand Up @@ -652,6 +603,50 @@ describe('rum assembly', () => {
expect(serverRumEvents[0].service).toEqual('new service')
expect(serverRumEvents[0].version).toEqual('new version')
})

describe('fields service and version', () => {
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('default service')
expect((serverRumEvents[0] as RumResourceEvent).version).toBe('default version')
})

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('url context', () => {
Expand Down

0 comments on commit 7d87b9d

Please sign in to comment.