From c6c0ee38a5395cda8d5a4f91929a9bd69d17e4c9 Mon Sep 17 00:00:00 2001 From: Jeff Nguyen Date: Mon, 15 Jul 2024 22:17:06 -0400 Subject: [PATCH] Add test to show desired behavior for imported stylesheets from seperate directory --- .../test/__snapshots__/integration.test.ts.snap | 2 +- packages/rrweb-snapshot/test/alt-css/alt-style.css | 12 ++++++++++++ .../rrweb-snapshot/test/css/style-with-import.css | 1 + packages/rrweb-snapshot/test/snapshot.test.ts | 5 +---- 4 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 packages/rrweb-snapshot/test/alt-css/alt-style.css diff --git a/packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap b/packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap index ee9d95245d..7f3a4ac431 100644 --- a/packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap +++ b/packages/rrweb-snapshot/test/__snapshots__/integration.test.ts.snap @@ -500,7 +500,7 @@ exports[`integration tests > [html file]: with-style-sheet-with-import.html 1`] with style sheet with import - + " `; diff --git a/packages/rrweb-snapshot/test/alt-css/alt-style.css b/packages/rrweb-snapshot/test/alt-css/alt-style.css new file mode 100644 index 0000000000..0f935c87f2 --- /dev/null +++ b/packages/rrweb-snapshot/test/alt-css/alt-style.css @@ -0,0 +1,12 @@ +body { + margin: 0; + background: url('../c.jpg'); + border-image: url('data:image/svg+xml;utf8,'); + } + p { + color: red; + background: url('./d.jpg'); + } + body > p { + color: yellow; + } diff --git a/packages/rrweb-snapshot/test/css/style-with-import.css b/packages/rrweb-snapshot/test/css/style-with-import.css index 5fa59d8039..a24d901947 100644 --- a/packages/rrweb-snapshot/test/css/style-with-import.css +++ b/packages/rrweb-snapshot/test/css/style-with-import.css @@ -1,2 +1,3 @@ @import '//fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&family=Roboto:wght@100;300;400;500;700&display=swap"'; @import './style.css'; +@import '../alt-css/alt-style.css'; diff --git a/packages/rrweb-snapshot/test/snapshot.test.ts b/packages/rrweb-snapshot/test/snapshot.test.ts index 11f79f2d9e..bfab523940 100644 --- a/packages/rrweb-snapshot/test/snapshot.test.ts +++ b/packages/rrweb-snapshot/test/snapshot.test.ts @@ -3,10 +3,7 @@ */ import { JSDOM } from 'jsdom'; import { describe, it, expect } from 'vitest'; -import { - serializeNodeWithId, - _isBlockedElement, -} from '../src/snapshot'; +import { serializeNodeWithId, _isBlockedElement } from '../src/snapshot'; import snapshot from '../src/snapshot'; import { serializedNodeWithId, elementNode } from '../src/types'; import { Mirror, absoluteToStylesheet } from '../src/utils';