addon-visual-tests
addon-visual-tests copied to clipboard
Update story status reporting for Storybook 8.3 and use new `SET_FILTER` event
Closes https://github.com/storybookjs/storybook/issues/28683
This makes the addon compatible with the upcoming changes in Storybook 8.3. See https://github.com/storybookjs/storybook/pull/28693 and https://github.com/storybookjs/storybook/pull/28739
- The
experimental_updateStatusAPI now accepts anonClickproperty. This is used to open the Visual Tests panel when clicking an error/warning status in the sidebar. - The
experimental_SIDEBAR_BOTTOMAPI is deprecated and ignored in SB 8.3. The VTA will continue to use this API for backwards compatibility, but will eventually be removed. When using the VTA with Storybook 8.3, it will rely on Storybook's own sidebar filtering UI. - Storybook 8.3 emits a
setFilterevent when a filter is set, similar to the VTA'schromaui/addon-visual-tests/enableFilterevent. Both events are listened for in order to be compatible with Storybook <8.3 and Storybook >=8.3.
Compatibility is as follows:
- Old VTA in SB >=8.3 will use the Storybook filter UI with no issue because the Storybook filter UI is based on the
experimental_updateStatusAPI which the VTA has always used. The VTA's filter UI is ignored (not applied). - New VTA in SB <=8.2 will still apply the VTA filter UI, and that will work as it used to. It will send an
onClickproperty for the story statuses, but that will be ignored by Storybook 8.2 and earlier. - New VTA in SB >=8.3 will try to apply the VTA filter UI but it will be ignored. Instead it will use the Storybook filter UI.
Filter UI in Storybook 8.3 is mostly identical to the VTA filter UI, but it's likely to change in a later version.
Given that this PR is not strictly necessary right now, let's leave it open until you're back from holidays so we can test it properly 👍