Skip to content

Commit

Permalink
Handle className removal on SVG (#17935)
Browse files Browse the repository at this point in the history
  • Loading branch information
timroes authored Oct 13, 2022
1 parent c241541 commit 2a4a5d3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
9 changes: 7 additions & 2 deletions airbyte-webapp/scripts/classname-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<removed-for-snapshot-test>`;
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", `<removed-for-snapshot-test>`);
}
node.childNodes.forEach(traverseAndRedactClasses);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ exports[`CreateConnectionForm should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-sort-down sc-dPyBCJ eGVczJ"
class="<removed-for-snapshot-test>"
data-icon="sort-down"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -283,7 +283,7 @@ exports[`CreateConnectionForm should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-sort-down sc-dPyBCJ eGVczJ"
class="<removed-for-snapshot-test>"
data-icon="sort-down"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -379,7 +379,7 @@ exports[`CreateConnectionForm should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-rotate tryArrow"
class="<removed-for-snapshot-test>"
data-icon="rotate"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -644,7 +644,7 @@ exports[`CreateConnectionForm should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-chevron-right sc-ehmTmK eOIlNv"
class="<removed-for-snapshot-test>"
data-icon="chevron-right"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -760,7 +760,7 @@ exports[`CreateConnectionForm should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-sort-down sc-dPyBCJ eGVczJ"
class="<removed-for-snapshot-test>"
data-icon="sort-down"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -977,7 +977,7 @@ exports[`CreateConnectionForm should render with an error 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-xmark "
class="<removed-for-snapshot-test>"
data-icon="xmark"
data-prefix="fas"
focusable="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`<GitBlock /> should render with default props 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-github icon"
class="<removed-for-snapshot-test>"
data-icon="github"
data-prefix="fab"
focusable="false"
Expand Down Expand Up @@ -66,7 +66,7 @@ exports[`<GitBlock /> should render with overwritten props 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-github icon"
class="<removed-for-snapshot-test>"
data-icon="github"
data-prefix="fab"
focusable="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ exports[`ConnectionReplicationTab should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-sort-down sc-BeQoi gptVmb"
class="<removed-for-snapshot-test>"
data-icon="sort-down"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -230,7 +230,7 @@ exports[`ConnectionReplicationTab should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-sort-down sc-BeQoi gptVmb"
class="<removed-for-snapshot-test>"
data-icon="sort-down"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -326,7 +326,7 @@ exports[`ConnectionReplicationTab should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-rotate tryArrow"
class="<removed-for-snapshot-test>"
data-icon="rotate"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -591,7 +591,7 @@ exports[`ConnectionReplicationTab should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-chevron-right sc-ckMVTt eVXgVK"
class="<removed-for-snapshot-test>"
data-icon="chevron-right"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -707,7 +707,7 @@ exports[`ConnectionReplicationTab should render 1`] = `
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-sort-down sc-BeQoi gptVmb"
class="<removed-for-snapshot-test>"
data-icon="sort-down"
data-prefix="fas"
focusable="false"
Expand Down Expand Up @@ -804,7 +804,7 @@ exports[`ConnectionReplicationTab should show an error if there is a schemaError
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-xmark "
class="<removed-for-snapshot-test>"
data-icon="xmark"
data-prefix="fas"
focusable="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`<FrequentlyUsedDestinations /> should renders with mock data without cr
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-chevron-left slick-arrow slick-prev slick-disabled"
class="<removed-for-snapshot-test>"
data-icon="chevron-left"
data-prefix="fas"
data-role="none"
Expand Down Expand Up @@ -314,7 +314,7 @@ exports[`<FrequentlyUsedDestinations /> should renders with mock data without cr
>
<svg
aria-hidden="true"
class="svg-inline--fa fa-chevron-right slick-arrow slick-next"
class="<removed-for-snapshot-test>"
data-icon="chevron-right"
data-prefix="fas"
data-role="none"
Expand Down

0 comments on commit 2a4a5d3

Please sign in to comment.