Skip to content

Commit

Permalink
use non-forked rrweb
Browse files Browse the repository at this point in the history
  • Loading branch information
tevanoff committed Nov 10, 2023
1 parent f9c5b5b commit 012ea55
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 29 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions src/cypress-api/commands.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cypress-api/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/cypress-api/support.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { snapshot } from '@chromaui/rrweb-snapshot';
import { snapshot } from 'rrweb-snapshot';

Check failure on line 1 in src/cypress-api/support.ts

View workflow job for this annotation

GitHub Actions / release

Argument of type '{ noAbsolute: boolean; }' is not assignable to parameter of type '{ mirror?: Mirror; blockClass?: string | RegExp; blockSelector?: string; maskTextClass?: string | RegExp; maskTextSelector?: string; inlineStylesheet?: boolean; ... 13 more ...; keepIframeSrcFn?: KeepIframeSrcFn; }'.
import type { ResourceArchive } from '../resource-archive';
import './commands';

Expand Down
9 changes: 3 additions & 6 deletions src/playwright-api/takeArchive.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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) });
Expand Down
3 changes: 1 addition & 2 deletions src/write-archive/archive-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/write-archive/dom-snapshot.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/write-archive/index.test.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
16 changes: 5 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 012ea55

Please sign in to comment.