Skip to content

JetBrains: Add storybook for Chromatic tests

Warren Gifford requested to merge dv/jetbrains-chromatic into main

Created by: vdavid

Fixes https://github.com/sourcegraph/sourcegraph/issues/37681

I made webpack work with the project (needed some polyfills) and added a story.

Also:

  • Bug fix: The initial search was broken in the standalone version. Now it correctly triggers.
  • Bug fix: Path matches didn't send the "commit" field so the "Copy URL" feature didn't work for remote files in path matches. (I've found this out by accident during testing)
  • Extracted the mocked "callJava" function: it's reusable now (I've reused it) and more elegant too.

This is how it looks in both modes:

CleanShot 2022-07-12 at 19 49 45@2x CleanShot 2022-07-12 at 19 52 11@2x

Caveat:

  • To avoid a flaky test and make sure that the search finishes by the time Chromatic creates its snapshot, I set up a 10 second delay after page loading. I imagine that Chromatic works in a heavily multithreaded way (as we're generating hundreds of pages) so this should be non-blocking. I've tried to find a more dynamic solution, but haven't found anything in the docs and on Google, so I stayed with the fixed delay.

Test plan

I've tested all of these:

  • It works with yarn storybook:jetbrains
  • It works with yarn storybook
  • It works with both dark and light modes correctly
  • It still works with the standalone version
  • It still works in the IDE

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading