(I'm filing this task for the TODO comment in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/1004223/5/tests/cases/for-parser-cache-new/for-parser-cache-new.html, because I want to reference this problem elsewhere)
Most of the input files for integration tests in DiscussionTools in /tests/cases were created by saving the HTML generated by MediaWiki when viewing the page with ?action=render (as documented in tests/cases/README.txt)
This was fine when we started the development, but since then several things happened that caused these input files to diverge from reality:
- DiscussionTools was deployed to all projects, so some test cases added later are contaminated with DiscussionTools's own markup. I found two: timestamplink.html, wrappers2-oldparser.html. (Codesearch)
- DiscussionTools processing was moved from the OutputPageBeforeHTML hook to the ParserAfterTidy hook, which means we now operate on HTML before some of MediaWiki's own processing is applied – notably, there are no <span class="mw-headline"> tags since https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1004160.
This means that we have to have some workarounds in our discussion parser that only serve to make our own test cases pass, but is not actually used in production. You can find them by searching for "mw-headline", "data-mw-comment", "ext-discussiontools". (Codesearch)
Someone should figure out how to extract the "early stage" wikitext parser HTML from MediaWiki (it's not normally exposed), and then update all of the tests to use it, and then remove the workarounds in the parser. Currently the only "correct" test is for-parser-cache-new.html.
This work probably has to happen after T363030: Remove the mostly unused Parser.js from DiscussionTools, because the JS discussion parser actually expects to run on the "final" HTML with all the extra things.