From b63797bafb0fb306a8177aaffea2f328d6addbb7 Mon Sep 17 00:00:00 2001 From: Thomas Lebeau Date: Mon, 3 Jun 2024 16:17:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20add=20assembly=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/rum-core/src/domain/assembly.spec.ts | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/rum-core/src/domain/assembly.spec.ts b/packages/rum-core/src/domain/assembly.spec.ts index 5755df7c35..4bf820f267 100644 --- a/packages/rum-core/src/domain/assembly.spec.ts +++ b/packages/rum-core/src/domain/assembly.spec.ts @@ -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', () => {