From 14b763d55306340d9b5111f9ecf3306cd2253aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Zugmeyer?= Date: Tue, 29 Aug 2023 14:38:51 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=85=20revamp=20serialization=20tests?= =?UTF-8?q?=20a=20bit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some tests were incorrectly labeled and hard to grasp. This commit improves a bit, and adds a test on how style element containing text are currently serialized. --- .../serialization/serializeNode.spec.ts | 257 +++++++++--------- 1 file changed, 134 insertions(+), 123 deletions(-) diff --git a/packages/rum/src/domain/record/serialization/serializeNode.spec.ts b/packages/rum/src/domain/record/serialization/serializeNode.spec.ts index bc9dfbe08f..6ed9a02c66 100644 --- a/packages/rum/src/domain/record/serialization/serializeNode.spec.ts +++ b/packages/rum/src/domain/record/serialization/serializeNode.spec.ts @@ -16,7 +16,7 @@ import { PRIVACY_ATTR_VALUE_MASK, PRIVACY_ATTR_VALUE_MASK_USER_INPUT, } from '../../../constants' -import type { ElementNode, SerializedNodeWithId, TextNode } from '../../../types' +import type { ElementNode, SerializedNodeWithId } from '../../../types' import { NodeType } from '../../../types' import type { IsolatedDom } from '../../../../../rum-core/test' import { createIsolatedDom } from '../../../../../rum-core/test' @@ -537,109 +537,135 @@ describe('serializeNodeWithId', () => { expect(addShadowRootSpy).toHaveBeenCalledWith(div.shadowRoot!) }) - it('serializes style node with local CSS', () => { - const styleNode = document.createElement('style') - isolatedDom.document.head.appendChild(styleNode) - const styleSheet = styleNode.sheet - styleSheet?.insertRule('body { width: 100%; }') - expect(serializeElement(styleNode)).toEqual({ - type: NodeType.Element, - tagName: 'style', - id: jasmine.any(Number) as unknown as number, - isSVG: undefined, - attributes: { _cssText: 'body { width: 100%; }' }, - childNodes: [], + describe('