From 486d853830e1fd9c9aa5a42f8ffb7e3e6e840850 Mon Sep 17 00:00:00 2001 From: Todd Evanoff Date: Thu, 9 Nov 2023 16:02:47 -0800 Subject: [PATCH] use non-forked rrweb --- package.json | 3 +-- src/cypress-api/commands.ts | 6 +++--- src/cypress-api/index.ts | 2 +- src/cypress-api/support.ts | 2 +- src/playwright-api/takeArchive.ts | 9 +++------ src/write-archive/archive-file.ts | 3 +-- src/write-archive/dom-snapshot.ts | 4 ++-- src/write-archive/index.test.ts | 2 +- yarn.lock | 16 +++++----------- 9 files changed, 18 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 49743e64..02d1fe31 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "@babel/preset-react": "^7.18.6", "@babel/preset-typescript": "^7.21.4", "@chromaui/archive-storybook": "^0.0.15", - "@chromaui/test-archiver": "^0.0.32", "@jest/types": "^27.0.6", "@playwright/test": "^1.39.0", "@storybook/addon-essentials": "^7.5.2", @@ -97,10 +96,10 @@ "access": "public" }, "dependencies": { - "@chromaui/rrweb-snapshot": "2.0.0-alpha.7-noAbsolute.2", "@segment/analytics-node": "^1.1.0", "fs-extra": "^11.1.1", "mime": "^3.0.0", + "rrweb-snapshot": "^2.0.0-alpha.4", "ts-dedent": "^2.2.0" }, "peerDependencies": { diff --git a/src/cypress-api/commands.ts b/src/cypress-api/commands.ts index 70f7a8f7..dc3ae887 100644 --- a/src/cypress-api/commands.ts +++ b/src/cypress-api/commands.ts @@ -1,10 +1,10 @@ -import { snapshot } from '@chromaui/rrweb-snapshot'; -import type { elementNode } from '@chromaui/rrweb-snapshot'; +import { snapshot } from 'rrweb-snapshot'; +import type { elementNode } from 'rrweb-snapshot'; // @ts-expect-error will fix when Cypress has its own package Cypress.Commands.add('takeChromaticArchive', () => { cy.document().then((doc) => { // here, handle the source map - const manualSnapshot = snapshot(doc, { noAbsolute: true }); + const manualSnapshot = snapshot(doc); // reassign manualSnapshots so it includes this new snapshot cy.get('@manualSnapshots') // @ts-expect-error will fix when Cypress has its own package diff --git a/src/cypress-api/index.ts b/src/cypress-api/index.ts index 152d6002..194d21d2 100644 --- a/src/cypress-api/index.ts +++ b/src/cypress-api/index.ts @@ -1,4 +1,4 @@ -import type { elementNode } from '@chromaui/rrweb-snapshot'; +import type { elementNode } from 'rrweb-snapshot'; import { writeTestResult } from '../write-archive'; import type { ChromaticStorybookParameters } from '../types'; import type { ResourceArchive } from '../resource-archive'; diff --git a/src/cypress-api/support.ts b/src/cypress-api/support.ts index 373ac9b7..2a7031bc 100644 --- a/src/cypress-api/support.ts +++ b/src/cypress-api/support.ts @@ -1,4 +1,4 @@ -import { snapshot } from '@chromaui/rrweb-snapshot'; +import { snapshot } from 'rrweb-snapshot'; import type { ResourceArchive } from '../resource-archive'; import './commands'; diff --git a/src/playwright-api/takeArchive.ts b/src/playwright-api/takeArchive.ts index 8f1c6d3e..6ab3abda 100644 --- a/src/playwright-api/takeArchive.ts +++ b/src/playwright-api/takeArchive.ts @@ -1,15 +1,12 @@ import type { Page, TestInfo } from '@playwright/test'; import { readFileSync } from 'fs'; -import type { elementNode } from '@chromaui/rrweb-snapshot'; +import type { elementNode } from 'rrweb-snapshot'; import dedent from 'ts-dedent'; import { logger } from '../utils/logger'; -const rrweb = readFileSync( - require.resolve('@chromaui/rrweb-snapshot/dist/rrweb-snapshot.js'), - 'utf8' -); +const rrweb = readFileSync(require.resolve('rrweb-snapshot/dist/rrweb-snapshot.js'), 'utf8'); export const contentType = 'application/rrweb.snapshot+json'; @@ -39,7 +36,7 @@ async function takeArchive( // Serialize and capture the DOM const domSnapshot: elementNode = await page.evaluate(dedent` ${rrweb}; - rrwebSnapshot.snapshot(document, { noAbsolute: true }); + rrwebSnapshot.snapshot(document); `); testInfo.attach(name, { contentType, body: JSON.stringify(domSnapshot) }); diff --git a/src/write-archive/archive-file.ts b/src/write-archive/archive-file.ts index 6cf422fc..a69276d4 100644 --- a/src/write-archive/archive-file.ts +++ b/src/write-archive/archive-file.ts @@ -30,8 +30,7 @@ export class ArchiveFile { } originalSrc() { - // Assets that we capture will be stripped of the domain in the source - return `${this.url.pathname}${this.url.search}`; + return this.url.toString(); } toFileSystemPath() { diff --git a/src/write-archive/dom-snapshot.ts b/src/write-archive/dom-snapshot.ts index c9b1927b..5251386d 100644 --- a/src/write-archive/dom-snapshot.ts +++ b/src/write-archive/dom-snapshot.ts @@ -1,7 +1,7 @@ /* eslint-disable no-underscore-dangle */ /* eslint-disable no-param-reassign */ -import type { serializedNodeWithId } from '@chromaui/rrweb-snapshot'; -import { NodeType } from '@chromaui/rrweb-snapshot'; +import type { serializedNodeWithId } from 'rrweb-snapshot'; +import { NodeType } from 'rrweb-snapshot'; // Matches `url(...)` function in CSS text, excluding data URLs const CSS_URL_REGEX = /url\((?!['"]?(?:data):)['"]?([^'")]*)['"]?\)/gi; diff --git a/src/write-archive/index.test.ts b/src/write-archive/index.test.ts index 34dee891..3348e497 100644 --- a/src/write-archive/index.test.ts +++ b/src/write-archive/index.test.ts @@ -1,7 +1,7 @@ import fs from 'fs-extra'; import { resolve } from 'path'; import type { TestInfo } from '@playwright/test'; -import { NodeType } from '@chromaui/rrweb-snapshot'; +import { NodeType } from 'rrweb-snapshot'; import { writeTestResult } from '.'; jest.mock('fs-extra'); diff --git a/yarn.lock b/yarn.lock index f2a5b144..7888ae01 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2052,17 +2052,6 @@ resolved "https://registry.npmjs.org/@chromaui/rrweb-snapshot/-/rrweb-snapshot-2.0.0-alpha.7-noAbsolute.2.tgz" integrity sha512-vOVSOgfNyxomxm6ENMqm1C4rLkLLOlyEyhR5J2SKBALuFfuJHjhIqNLSOgqVRO9J3++AUOCktknyJ/F+mSvEfA== -"@chromaui/test-archiver@^0.0.32": - version "0.0.32" - resolved "https://registry.yarnpkg.com/@chromaui/test-archiver/-/test-archiver-0.0.32.tgz#6e0560b39108581b9d3d55d3f5e462350b3cda9c" - integrity sha512-O6le42KqoliioAQG2RY+XhrwSttwnYHV2lIk3TNKJ1l9sTjQT5AUAZJ6N4CkUAsU8TVtX8wEDUY0mrNL00M/DQ== - dependencies: - "@chromaui/rrweb-snapshot" "2.0.0-alpha.7-noAbsolute.2" - "@segment/analytics-node" "^1.1.0" - fs-extra "^11.1.1" - mime "^3.0.0" - ts-dedent "^2.2.0" - "@colors/colors@1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" @@ -11571,6 +11560,11 @@ rollup@^3.2.5: optionalDependencies: fsevents "~2.3.2" +rrweb-snapshot@^2.0.0-alpha.4: + version "2.0.0-alpha.4" + resolved "https://registry.yarnpkg.com/rrweb-snapshot/-/rrweb-snapshot-2.0.0-alpha.4.tgz#2801bf5946177b9d685a01661a62d9d2e958f174" + integrity sha512-KQ2OtPpXO5jLYqg1OnXS/Hf+EzqnZyP5A+XPqBCjYpj3XIje/Od4gdUwjbFo3cVuWq5Cw5Y1d3/xwgIS7/XpQQ== + run-parallel@^1.1.9: version "1.2.0" resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz"