Page MenuHomePhabricator

[Spike] Investigate alternatives to Storybooks.js
Closed, ResolvedPublic2 Estimated Story Points

Description

Background

During a recent meeting, the web team engineers discussed the pros & cons of a tool like Storybook, and why it was ultimately removed from the MobileFrontend repo. Despite that removal, the team still sees value in tool like this and would like to explore options that could achieve similar functionality without the maintenance burden.

User story

  • As a developer on the web team, when working on a component, I would like to see all (or most) permutations of that component during development, so that I can minimize regressions and edge-cases.

Requirements

During our meeting, we agreed to the following requirements:

  • Integration with resourceLoader - One of the biggest downsides to Storybook was that it didn't truly reflect the style/js output that ResourceLoader would produce. ResourceLoader has specific features like skins.variables.less and CSS flipping for RTL that had to be hacked around in Storybook.
  • i18n capabilities - MediaWiki has specific i18n functionality such as i18n messages in Less, icon-flipping, general CSS flipping with CSSJanus that cannot be easily replicated in Storybook.
  • LiveReload - Not crucial but improves development experience.
Open questions
  • Can we use a static page served from within Mediawiki? such as the docs folder
  • Can we somehow integrate this tool with Jest snapshots?
  • Can we use this tool in Pixel?

Design

N/A

Acceptance criteria

  • A proof-of-concept, perhaps using the Popups repo as a test case.

Communication criteria - does this need an announcement or discussion?

  • N/A

Event Timeline

SToyofuku-WMF changed the task status from Open to In Progress.Dec 11 2024, 7:09 PM
SToyofuku-WMF subscribed.

pending estimate

Jdrewniak set the point value for this task to 2.Dec 16 2024, 5:53 PM

Change #1110817 had a related patch set uploaded (by Jdrewniak; author: Jdrewniak):

[mediawiki/extensions/Popups@master] [POC] Create Special:PopupsUITest page as Storybook alternative

https://gerrit.wikimedia.org/r/1110817

Restating the requirements: Most issues we've come across in Popups recently have been related to Storybook.js not being integrated with the skins and MediaWiki in a way that reflects how page previews look in production. We've found that changes in the skin or elsewhere can affect popups in unexpected ways, so in order to bring more visibility into this, my recommendation is to create a Special Page as an alternative to Storybook.js. This solution would be similar to how Extension:VueTest works, but integrated into the Popups repo. Although that extension is being decommissioned T357475, it seems that the downsides listed in that task are actually upsides in this scenario.

In order to create this special page, we would need to expose the capability of rendering page previews on a page programmatically. Storybook.js did this by imported the required rendering classes from src and compiling them through webpack. This would have to be done differently in a ResourceLoader context (perhaps conditionally exposing necessary render functions, or compiling a separate popups UI test bundle?).

The patch above simply exposes a private function in order to render multiple popups on a page.

Hopefully the screenshot below gives an idea of what a Storybook style special page for popups could look like:

Screenshot 2025-01-13 at 12.02.38 PM.png (1×2 px, 1 MB)

Jdlrobson subscribed.

To be discussed in SHDT. I added it to our agenda.

For completion, pls note that Extension:VueTest has been archived in the meantime too. https://www.mediawiki.org/wiki/Extension:VueTest