Migrate from onResourceLoaderTestModules to QUnitTestModule

The hook is deprecated as of this release cycle, see:
<https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules>.

Moving away from PHP code. This can now be done from JSON, and
encourages use of a single module that is automatically named and
registered as needed.

Change-Id: I382692c70ca8e5f5ea658b07ebea6c47dd541724
This commit is contained in:
Timo Tijhof 2019-09-20 21:50:23 +01:00 committed by Krinkle
parent f49183bd93
commit 30c12b3ddd
3 changed files with 36 additions and 57 deletions

View file

@ -131,59 +131,6 @@ class MinervaHooks {
}
}
/**
* ResourceLoaderTestModules hook handler
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
*
* @param array &$testModules
* @param ResourceLoader $resourceLoader
*/
public static function onResourceLoaderTestModules( array &$testModules,
ResourceLoader $resourceLoader
) {
$testModule = [
'dependencies' => [
'mobile.startup',
'mediawiki.user',
'mediawiki.experiments'
],
'templates' => [
"badge.mustache" => "includes/skins/userNotifications.mustache",
],
'localBasePath' => dirname( __DIR__ ),
'remoteSkinPath' => 'MinervaNeue',
'targets' => [ 'mobile', 'desktop' ],
'packageFiles' => [
// additional scaffolding (minus initialisation scripts)
'tests/qunit/skins.minerva.scripts/index.js',
'resources/skins.minerva.scripts/NotificationBadge.js',
'resources/skins.minerva.scripts/page-issues/parser.js',
'resources/skins.minerva.scripts/downloadPageAction.js',
'resources/skins.minerva.scripts/AB.js',
'resources/skins.minerva.scripts/page-issues/overlay/IssueNotice.js',
'resources/skins.minerva.scripts/page-issues/overlay/IssueList.js',
'resources/skins.minerva.scripts/page-issues/overlay/pageIssuesOverlay.js',
'resources/skins.minerva.scripts/page-issues/page/PageIssueLearnMoreLink.js',
'resources/skins.minerva.scripts/page-issues/page/PageIssueLink.js',
'resources/skins.minerva.scripts/page-issues/page/pageIssueFormatter.js',
'resources/skins.minerva.scripts/page-issues/index.js',
'resources/skins.minerva.scripts/UriUtil.js',
'resources/skins.minerva.scripts/TitleUtil.js',
// test files
'tests/qunit/skins.minerva.scripts/downloadPageAction.test.js',
'tests/qunit/skins.minerva.scripts/page-issues/parser.test.js',
'tests/qunit/skins.minerva.scripts/AB.test.js',
'tests/qunit/skins.minerva.scripts/page-issues/index.test.js',
'tests/qunit/skins.minerva.scripts/UriUtil.test.js',
'tests/qunit/skins.minerva.scripts/TitleUtil.test.js',
'tests/qunit/skins.minerva.scripts/NotificationBadge.test.js'
],
];
// Expose templates module
$testModules['qunit']['tests.skins.minerva'] = $testModule;
}
/**
* Invocation of hook SpecialPageBeforeExecute
*

View file

@ -114,9 +114,6 @@
"RequestContextCreateSkinMobile": [
"MinervaHooks::onRequestContextCreateSkinMobile"
],
"ResourceLoaderTestModules": [
"MinervaHooks::onResourceLoaderTestModules"
],
"SpecialPageBeforeExecute": [
"MinervaHooks::onSpecialPageBeforeExecute"
],
@ -673,6 +670,41 @@
]
}
},
"QUnitTestModule": {
"localBasePath": "",
"remoteSkinPath": "MinervaNeue",
"dependencies": [
"mobile.startup",
"mediawiki.user",
"mediawiki.experiments"
],
"templates": {
"badge.mustache": "includes/skins/userNotifications.mustache"
},
"packageFiles": [
"tests/qunit/skins.minerva.scripts/index.js",
"resources/skins.minerva.scripts/NotificationBadge.js",
"resources/skins.minerva.scripts/page-issues/parser.js",
"resources/skins.minerva.scripts/downloadPageAction.js",
"resources/skins.minerva.scripts/AB.js",
"resources/skins.minerva.scripts/page-issues/overlay/IssueNotice.js",
"resources/skins.minerva.scripts/page-issues/overlay/IssueList.js",
"resources/skins.minerva.scripts/page-issues/overlay/pageIssuesOverlay.js",
"resources/skins.minerva.scripts/page-issues/page/PageIssueLearnMoreLink.js",
"resources/skins.minerva.scripts/page-issues/page/PageIssueLink.js",
"resources/skins.minerva.scripts/page-issues/page/pageIssueFormatter.js",
"resources/skins.minerva.scripts/page-issues/index.js",
"resources/skins.minerva.scripts/UriUtil.js",
"resources/skins.minerva.scripts/TitleUtil.js",
"tests/qunit/skins.minerva.scripts/downloadPageAction.test.js",
"tests/qunit/skins.minerva.scripts/page-issues/parser.test.js",
"tests/qunit/skins.minerva.scripts/AB.test.js",
"tests/qunit/skins.minerva.scripts/page-issues/index.test.js",
"tests/qunit/skins.minerva.scripts/UriUtil.test.js",
"tests/qunit/skins.minerva.scripts/TitleUtil.test.js",
"tests/qunit/skins.minerva.scripts/NotificationBadge.test.js"
]
},
"ServiceWiringFiles": [
"includes/ServiceWiring.php"
],

View file

@ -3,7 +3,7 @@
// we have to stub certain templates to make it appear like its been loaded.
mw.template.add( 'skins.minerva.scripts', 'IssueNotice.mustache', '' );
mw.template.add( 'skins.minerva.scripts', 'badge.mustache',
mw.template.get( 'tests.skins.minerva', 'badge.mustache' ).getSource() );
mw.template.get( 'test.MinervaNeue', 'badge.mustache' ).getSource() );
module.exports = [
require( './NotificationBadge.test.js' ),
require( './downloadPageAction.test.js' ),