jenkins-bot has submitted this change and it was merged.
Change subject: QUnit tests to verify that the extension works
......................................................................
QUnit tests to verify that the extension works
Lets test that each collector returns the right result structure.
Bug: T133520
Change-Id: Ib02c44d2d7cb4fe2e69a37fe9f44ee4cfce17eff
---
M PerformanceInspector.hooks.php
M tests/qunit/ext.performanceInspector.test.js
2 files changed, 46 insertions(+), 4 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/PerformanceInspector.hooks.php b/PerformanceInspector.hooks.php
index a5d78d6..ee3990a 100644
--- a/PerformanceInspector.hooks.php
+++ b/PerformanceInspector.hooks.php
@@ -31,7 +31,7 @@
ResourceLoader &$resourceLoader ) {
$testModules['qunit']['ext.performanceInspector.tests'] = array(
'scripts' => array(
'tests/qunit/ext.performanceInspector.test.js' ),
- 'dependencies' => array(
'ext.PerformanceInspector.startup' ),
+ 'dependencies' => array(
'ext.PerformanceInspector.analyze' ),
'localBasePath' => __DIR__,
'remoteExtPath' => 'PerformanceInspector'
);
diff --git a/tests/qunit/ext.performanceInspector.test.js
b/tests/qunit/ext.performanceInspector.test.js
index 8d2a237..340da36 100644
--- a/tests/qunit/ext.performanceInspector.test.js
+++ b/tests/qunit/ext.performanceInspector.test.js
@@ -1,8 +1,50 @@
( function ( mw, $ ) {
QUnit.module( 'ext.performanceInspector', QUnit.newMwEnvironment() );
- QUnit.test( 'Test that always succeeds', 1, function ( assert ) {
- assert.strictEqual( true, true, 'yay' );
- } );
+ QUnit.test( 'Test collector structure', function ( assert ) {
+ var collectors = require(
'ext.PerformanceInspector.analyze' ).collectors,
+ promises = [],
+ dummyModuleData = {
+ inspect: {
+ modules: [ {
+ name:
'ext.centralauth.centralautologin',
+ size: '1.8 KiB',
+ sizeInBytes:
1830
+ } ],
+ css: [ {
+ allSelectors:
262,
+
matchedSelectors: 11,
+ module: 'site',
+ percentMatched:
'4.20%'
+ } ],
+ store: [ {
+ enabled: true,
+ expired: 2,
+ hits: 98,
+ misses: 3,
+ totalSize: '1.4
MiB'
+ } ]
+ }
+ };
+
+ assert.ok( collectors.length > 0, 'We should
pick up the collectors' );
+
+ collectors.forEach( function ( collector ) {
+ promises.push( collector(
dummyModuleData ) );
+ } );
+
+ // instead of Promise.all, is there a better
way of doing it with jQuery?
+ $.when.apply( $, promises ).then( function () {
+ $.makeArray( arguments ).forEach(
function ( result ) {
+ var name = result.view &&
result.view.name ? result.view.name : 'unknown';
+ assert.ok( result.view, 'Each
collector should produce a view ' + name );
+ assert.ok( result.view.name,
'Each view should have a name ' + name );
+ assert.ok( result.view.label,
'Each view should have a label ' + name );
+ assert.ok(
result.view.template, 'Each view should have a mustache template ' + name );
+ assert.ok( result.view.data,
'Each view should have some data to show ' + name );
+ assert.ok( result.summary,
'Each collector should produce a summary ' + name );
+ } );
+ } );
+ } );
}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/285225
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib02c44d2d7cb4fe2e69a37fe9f44ee4cfce17eff
Gerrit-PatchSet: 16
Gerrit-Project: mediawiki/extensions/PerformanceInspector
Gerrit-Branch: master
Gerrit-Owner: Phedenskog <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Phedenskog <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits