From 157f74f7c8dc1be9e234cb614da8b503a69b8f28 Mon Sep 17 00:00:00 2001 From: Thibaut Gery Date: Fri, 17 Feb 2023 14:15:44 +0100 Subject: [PATCH 1/3] [REPLAY] Fix serialization for checkbox & radio --- .../rum/src/domain/record/serialize.spec.ts | 60 +++++++++++++++++++ packages/rum/src/domain/record/serialize.ts | 2 +- packages/rum/test/htmlAst.ts | 4 -- 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/packages/rum/src/domain/record/serialize.spec.ts b/packages/rum/src/domain/record/serialize.spec.ts index 543eb1644c..87f856a081 100644 --- a/packages/rum/src/domain/record/serialize.spec.ts +++ b/packages/rum/src/domain/record/serialize.spec.ts @@ -359,6 +359,66 @@ describe('serializeNodeWithId', () => { ) }) + it('serializes elements checked state', () => { + const radio = document.createElement('input') + radio.type = 'radio' + expect(serializeNodeWithId(radio, DEFAULT_OPTIONS)! as ElementNode).toEqual( + jasmine.objectContaining({ + attributes: { + type: 'radio', + value: 'on', + checked: false, + }, + }) + ) + + radio.checked = true + + expect(serializeNodeWithId(radio, DEFAULT_OPTIONS)! as ElementNode).toEqual( + jasmine.objectContaining({ + attributes: { + type: 'radio', + value: 'on', + checked: true, + }, + }) + ) + }) + + it('serializes elements checked state with mask serialization', () => { + const radio = document.createElement('input') + radio.type = 'radio' + expect( + serializeNodeWithId(radio, { + ...DEFAULT_OPTIONS, + parentNodePrivacyLevel: NodePrivacyLevel.MASK_USER_INPUT, + })! as ElementNode + ).toEqual( + jasmine.objectContaining({ + attributes: { + type: 'radio', + value: '***', + }, + }) + ) + + radio.checked = true + + expect( + serializeNodeWithId(radio, { + ...DEFAULT_OPTIONS, + parentNodePrivacyLevel: NodePrivacyLevel.MASK_USER_INPUT, + })! as ElementNode + ).toEqual( + jasmine.objectContaining({ + attributes: { + type: 'radio', + value: '***', + }, + }) + ) + }) + it('serializes