roundtrip-test.js is designed to be run against wiki pages and ensure that a round trip through transform/wikitext/to/html and transform/html/to/wikitext returns the same wikitext again.
We want to run this kind of test in CI as well. The easiest way to achieve this is to make roundtrip-test.js runnable as a Mocha test using the api-testing framework.
Rouch idea for implementation:
- Move much of the contents of roundtrip-test.js into a module, say lib/utils/RoundtripTestUtils.js. Keep only the command line interface in roundtrip-test.js, so it works as before. This should be easy, since roundtrip-test.js is already usable as a module.
- Create a new Mocha test under tests/api-testing, much like the Parsoid.js suite.
- Refactor the runTests() method and create a diffTest() that can be used in a mocha it() block with Chai assertions.
- Make a directory tests/roundtrip that contains at least two files with wikitext. Each file will be copied to a wiki page, and the round trip test will be run against it.
- To achieve this, loop over the files, and for each file, call it(). Inside the test, copy the contents of the file to a wiki page (see how we do it in before in Parsoid.js), and then call the diffTest() method on that page.