chromaui / chromatic-e2e

Archive end-to-end tests to be replayed in Storybook and Chromatic
MIT License
13 stars 4 forks source link

Instead of creating an iframe, just render the html part of the snapshot #63

Closed tevanoff closed 6 months ago

tevanoff commented 6 months ago

Fixes AP-3900

What Changed

This is all from Tom's PR over from https://github.com/chromaui/archive-storybook/pull/14

Previously, we created an iframe to render the full document snapshot, as rrweb requires re-open()-ing the document (and dropping all event handlers, including the ones the preview uses).

Instead, we can use rrweb to just render the html element part of the document and do an innerHTML replacement of the result. This seems to work fine.

The only thing we need to do is a minor hack to ensure #storybook-root and #storybook-docs are always available, as the WebView assumes they are there and errors if they are not.

@shilman - perhaps we can either make the WebView more resilient, or even allow overriding the web view from a preset somehow (that might be tricky).

How to test

Include this canary in a project, check that you can render stories and run Chromatic builds.

shilman commented 6 months ago

@tevanoff thanks, I'll chat with @tmeasday about this