Page MenuHomePhabricator

Popups: To support testing it should be possible to generate all possible combinations of page previews
Closed, ResolvedPublic8 Estimated Story Points

Description

When analysing T204627 it was really difficult to work out what the problem was as page previews can vary based on several factors:

  • where the link is in the page relative to the corners of the screen
  • size of image thumbnail
    • whether image is portrait or landscape

It should be possible to generate all possible combinations of a page preview

The solution should not be tied to the API as that's prone to change.

It should empower us to be sure we have not introduced any UI regressions quickly

Acceptance criteria

  • At any time I can generate all possible page preview render permutations
  • It can be generated quickly via command line.

Details

Related Changes in Gerrit:

Event Timeline

Jdlrobson renamed this task from It should be possible to generate all possible combinations of page previews to To support testing it should be possible to generate all possible combinations of page previews.
Jdlrobson triaged this task as Medium priority.
Jdlrobson raised the priority of this task from Medium to High.Oct 2 2018, 5:01 PM
Jdlrobson moved this task from Incoming to Triaged but Future on the Web-Team-Backlog-Archived board.

Marking as high as this seems to block us feeling confident in making changes to our render code and its probably our most visible product.

Jdlrobson renamed this task from To support testing it should be possible to generate all possible combinations of page previews to Popups: To support testing it should be possible to generate all possible combinations of page previews.Nov 15 2018, 6:45 PM

We estimated this as high as we suspect this will require some refactoring to the render code to obtain an easy way to generate HTML of a preview.

We expect this will introduce a new JS bundle that is loaded on a static HTML file (we would not need any of the redux code)

We expect this would look something like this:

const { popupToHtml  } = require( './render' );

[
  [exampleParams1, 'Horizontal popup with row in top left"].
  [exampleParams2, 'Horizontal popup with row in top right"].
].forEach((example) => {
  const html = popupToHtml( example[0] );
  $( html ).appendTo( document.body );
  $( '<p>').text(  example[1]
} );

There is of course some risk as we would be refactoring code in production and we haven't worked on the codebase in a while and the render code is likely to benefit from an opportunistic refactor.

Jdlrobson set the point value for this task to 8.Nov 21 2018, 5:27 PM

@ovasileva Jan has made some great progress on this. Given we are looking at other popups tasks right now and this is high priority 8 pointer I'd like us to queue this up.

Change 479354 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[mediawiki/extensions/Popups@master] POC - Storybook.js for Popups

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

Th patch above is a big addition to the Popups repo. It introduces the Storybook framework. Storybook is a UI library for viewing and working with UI components.

https://storybook.js.org

This allows us to look at multiple Popups permutations at once.
So far I've created the following scenarios:

  • with thumbnails
  • without thumbnails
  • with SVG thumbnails
  • with narrow thumbnails
  • with white background thumbnails
  • in RTL languages
  • in non-latin languages
  • disambiguation popups

To boot, I also added the "knobs" plugin which lets users change the image or text of a popup, as well as just paste in the page-summary API response into a text-field and generate a popup based on that!

Here's the generated version of the Storybook app:
https://zen-pasteur-e92b1e.netlify.com/

Integrating Storybook with the repo proved rather challenging. Not because of the Popups code itself, but rather the dependencies. Storybook requires at least Node v8.3 to run, and Popups use v6. This is because that's the version in CI. Also, older versions of Webpack and Babel conflicted with the ones in Storybook. To get around this, I placed all the dependencies, including the package.json, into the .storybook folder.

Known bugs: images don't appear in Safari.

Change 479354 merged by jenkins-bot:
[mediawiki/extensions/Popups@master] Storybook.js for Popups

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

I'm currently chatting with RelEng about how we can get this documentation published on every commit. It seems like we can use node 8 there.
I made T213226 to track that but I'm happy with the status quo as at very least we can verify UI changes locally from now on.
@Niedzielski or @nray would you mind signing this off?

npm start in StoryPops master shows development changes live. This will help future Popups work greatly