Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: don't delete style attributes in post-processing #468

Merged
merged 1 commit into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/__snapshots__/integration.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5573,6 +5573,7 @@ exports[`select2 1`] = `
\\"id\\": 36,
\\"attributes\\": {
\\"id\\": \\"select2-drop\\",
\\"style\\": \\"left: Npx; width: Npx; top: Npx; bottom: auto; display: block;\\",
\\"class\\": \\"select2-drop select2-display-none select2-with-searchbox select2-drop-active\\"
}
},
Expand Down Expand Up @@ -5721,7 +5722,8 @@ exports[`select2 1`] = `
\\"tagName\\": \\"div\\",
\\"attributes\\": {
\\"class\\": \\"select2-drop select2-display-none select2-with-searchbox select2-drop-active\\",
\\"id\\": \\"select2-drop\\"
\\"id\\": \\"select2-drop\\",
\\"style\\": \\"left: Npx; width: Npx; top: Npx; bottom: auto; display: block;\\"
},
\\"childNodes\\": [],
\\"id\\": 36
Expand Down Expand Up @@ -6033,7 +6035,8 @@ exports[`select2 1`] = `
{
\\"id\\": 36,
\\"attributes\\": {
\\"id\\": null
\\"id\\": null,
\\"style\\": \\"left: Npx; width: Npx; top: Npx; bottom: auto; display: none;\\"
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function stringifySnapshots(snapshots: eventWithTime[]): string {
s.data.href = 'about:blank';
}
// FIXME: travis coordinates seems different with my laptop
const coordinatesReg = /(bottom|top|left|right)/;
const coordinatesReg = /(bottom|top|left|right|width|height): \d+(\.\d+)?px/g
if (
s.type === EventType.IncrementalSnapshot &&
s.data.source === IncrementalSource.MouseInteraction
Expand All @@ -78,7 +78,7 @@ function stringifySnapshots(snapshots: eventWithTime[]): string {
'style' in a.attributes &&
coordinatesReg.test(a.attributes.style!)
) {
delete a.attributes.style;
a.attributes.style = a.attributes.style!.replace(coordinatesReg, '$1: Npx');
}
});
s.data.adds.forEach((add) => {
Expand All @@ -88,7 +88,7 @@ function stringifySnapshots(snapshots: eventWithTime[]): string {
typeof add.node.attributes.style === 'string' &&
coordinatesReg.test(add.node.attributes.style)
) {
delete add.node.attributes.style;
add.node.attributes.style = add.node.attributes.style.replace(coordinatesReg, '$1: Npx');
}
});
}
Expand Down