Page MenuHomePhabricator

ArticlePlaceholder should use MediaWiki qunit runner
Closed, ResolvedPublic

Description

Instead of maintaining a separate setup, it should use the MediaWiki qunit runner

https://www.mediawiki.org/wiki/Manual:JavaScript_unit_testing

Same as T180172: DataTypes should use MediaWiki qunit runner

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

commented the wrong task

Change 393233 had a related patch set uploaded (by Hashar; owner: Hashar):
[integration/config@master] Switch ArticlePlaceholder to npm-browser-test

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

Change 393233 merged by jenkins-bot:
[integration/config@master] Switch ArticlePlaceholder to npm-browser-test

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

I have encountered the issue today. The extension relies on grunt-contrib-qunit which depends on phantomjs-prebuild and run qunit tests with PhantomJS. The tests are under tests/qunit:

tests/qunit/
├── index.html
└── modules/
    └── ext.articleplaceholder.createArticle/
        ├── ext.articleplaceholder.createArticle.test.js
        └── ext.articleplaceholder.createArticleTranslation.test.js

2 directories, 3 files

We should be able to migrate them to use Special:JavascriptTest.

Change 444936 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/extensions/ArticlePlaceholder@master] Port QUnit test to MediaWiki runner

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

I have poked wikitech-l and got feedback from @Aleksey_WMDE For reference the thread is:

The last post is pointing at node Blog Post: Fast and isolated JS unit tests, or how to run QUnit tests with NodeJS. Which is definitely developer friendly and probably faster but has its own drawbacks (using stubs since mediawiki JS not being available).

I have migrated the CI of almost all extensions to use Quibble and ArticlePlaceholder is one of the last left to migrate. It currently fails on CI due to grunt-contrib-qunit depending on phantomjs which can't be installed due to lack of bzip2. That itself could be fixed, then that repository is the sole using that mechanism and should be normalized to use the MediaWiki karma runner. There are a few reasons for that:

  • The mediawiki core karma runner is the standard way (for now) to run the QUnit tests
  • That uses MediaWiki JavaScript and its dependencies (oojs, oojs-ui, qunit, sinon)

I have proposed change 44936 which does the integration, but the tests fail. As I understand it there is an helper method (createAndShowDialog)to open an OOUi dialog, but by the time the assertion is run, the dialog is not opened yet.

The createAndShowDialog creates the dialog then ask OOUi window manager to open a window with it. But that is done asynchronously and the assertion runs first. That thus fails to find the ui element.

I have tried to make createAndShowDialog to return the opened promise and then write the test in it, but it still fails. My knowledge of Javascript, OOUi or Promises is rather limited and I can't find a way to fix it up :-/

Once fixed, ArticlePlaceholder will be aligned with all other extensions and I will be able to migrate it to the new CI jobs based on Quibble :]

Change 462897 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/extensions/ArticlePlaceholder@master] Remove grunt-contrib-qunit test runner

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

Change 462898 had a related patch set uploaded (by Hashar; owner: Hashar):
[integration/config@master] Migrate ArticlePlaceholder to Quibble

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

Change 462898 merged by jenkins-bot:
[integration/config@master] Migrate ArticlePlaceholder to Quibble

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

Change 462897 merged by jenkins-bot:
[mediawiki/extensions/ArticlePlaceholder@master] Remove grunt-contrib-qunit test runner

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

The reason I tackled this task was to migrate ArticlePlaceholder to Docker/Quibble. I have dropped grunt-contrib-qunit and migrated the repository.

There is a patch pending to migrate to Special:JavascriptTest but I cant complete it.

Change 444936 had a related patch set uploaded (by Addshore; owner: Hashar):
[mediawiki/extensions/ArticlePlaceholder@master] tests: Port QUnit suite to MediaWiki runner

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

Change 444936 merged by jenkins-bot:
[mediawiki/extensions/ArticlePlaceholder@master] tests: Port QUnit suite to MediaWiki runner

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

hashar claimed this task.
hashar added a subscriber: Krinkle.