From e4efb0cbf905380f87ebc65e03c9ccee8889f88b Mon Sep 17 00:00:00 2001 From: Tim Roes Date: Thu, 13 Oct 2022 11:16:20 +0200 Subject: [PATCH] Handle className removal on SVG --- airbyte-webapp/scripts/classname-serializer.js | 9 +++++++-- .../__snapshots__/CreateConnectionForm.test.tsx.snap | 12 ++++++------ .../GitBlock/__snapshots__/GitBlock.test.tsx.snap | 4 ++-- .../ConnectionReplicationTab.test.tsx.snap | 12 ++++++------ .../FrequentlyUsedDestinations.test.tsx.snap | 4 ++-- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/airbyte-webapp/scripts/classname-serializer.js b/airbyte-webapp/scripts/classname-serializer.js index 40bb27a80cd6..a9f86a9f14a1 100644 --- a/airbyte-webapp/scripts/classname-serializer.js +++ b/airbyte-webapp/scripts/classname-serializer.js @@ -5,8 +5,13 @@ import { prettyDOM } from "@testing-library/react"; * the count of classnames instead, e.g. "<3 classnames>" */ const traverseAndRedactClasses = (node) => { - if (node.className && typeof node.className === "string") { - node.className = ``; + if ( + node.className && + (typeof node.className === "string" || (node.className instanceof SVGAnimatedString && node.className.baseVal)) + ) { + // We need to use setAttribute here, since on SVGElement we can't + // set `className` to a string for the `SVGAnimatedString` case. + node.setAttribute("class", ``); } node.childNodes.forEach(traverseAndRedactClasses); }; diff --git a/airbyte-webapp/src/components/CreateConnection/__snapshots__/CreateConnectionForm.test.tsx.snap b/airbyte-webapp/src/components/CreateConnection/__snapshots__/CreateConnectionForm.test.tsx.snap index 4bd204d77b07..19aca020b0a1 100644 --- a/airbyte-webapp/src/components/CreateConnection/__snapshots__/CreateConnectionForm.test.tsx.snap +++ b/airbyte-webapp/src/components/CreateConnection/__snapshots__/CreateConnectionForm.test.tsx.snap @@ -160,7 +160,7 @@ exports[`CreateConnectionForm should render 1`] = ` >