Page MenuHomePhabricator

Write tests for PHP MediaWiki widgets
Open, Needs TriagePublic

Description

https://doc.wikimedia.org/cover/mediawiki-core/includes/widget/index.html

The PHP MediaWiki widgets currently have no test coverage, we should have integration tests that verify the HTML output. I think this would be a good Google-Code-in-2018 task, and would be happy to mentor it, but I'd like at least one example test written by an OOUI expert to exist before asking students to write tests.

Event Timeline

In the past I've found tests like this to be more harmful than helpful.

We could easily add a test to verify that (string)new MediaWiki\Widget\TitleInputWidget() returns this:

<div aria-disabled='false' class='oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-textInputWidget oo-ui-textInputWidget-type-text oo-ui-textInputWidget-php mw-widget-titleInputWidget'><input type='text' tabindex='0' aria-disabled='false' value='' maxlength='255' class='oo-ui-inputWidget-input' /><span class='oo-ui-iconElement-icon oo-ui-iconElement-noIcon'></span><span class='oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator'></span></div>

…but that test is going to break every time we make a minor change to the HTML output of OOUI. For example, it would have been broken by the fix for T178437 (which added the oo-ui-iconElement-noIcon and oo-ui-indicatorElement-noIndicator classes), and it would be broken by a fix for T172110 (which would probably remove aria-disabled='false' on the <input>).

Since we don't run MediaWiki tests when making commits to OOUI this would be difficult to notice in advance, and since upgrading OOUI is such a mess (with mw/vendor and mw/core changes that must be merged at the same time and the tests only run for the second of them to be merged, and if one of them doesn't merge then all CI jobs for everyone start failing) it is a huge frustration whenever a new version of OOUI causes MW tests to fail.

Here's an example situation where a test in Wikibase (accidentally) depending on OOUI HTML output caused havoc: T160716: Wikibase unit tests assume inline <div>s don't get magically re-written as <span>s (holding up the OOUI release) (there was at least one other situation like this but I can't remember what exactly broke).