jenkins-bot has submitted this change and it was merged.

Change subject: Fix test failures
......................................................................


Fix test failures

Change-Id: If2c8af0ee3643ce7de556bd040fa129f12efca01
---
M ImageMetrics.php
M resources/ext.imageMetrics.js
M tests/qunit/ext.imageMetrics.test.js
3 files changed, 10 insertions(+), 28 deletions(-)

Approvals:
  Gilles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ImageMetrics.php b/ImageMetrics.php
index b621ca6..63e96a4 100644
--- a/ImageMetrics.php
+++ b/ImageMetrics.php
@@ -89,6 +89,9 @@
                'scripts' => array(
                        'tests/qunit/ext.imageMetrics.test.js',
                ),
+               'dependencies' => array(
+                       'ext.imageMetrics',
+               ),
                'localBasePath' => __DIR__,
                'remoteExtPath' => 'ImageMetrics',
        );
diff --git a/resources/ext.imageMetrics.js b/resources/ext.imageMetrics.js
index bb9efa5..ffebc8f 100644
--- a/resources/ext.imageMetrics.js
+++ b/resources/ext.imageMetrics.js
@@ -80,10 +80,12 @@
         * @param {jQuery} $file jQuery object containing the img element
         */
        ImageMetrics.prototype.addMediaWikiData = function ( data, $file ) {
-               data.fileType = $file.attr( 'alt' ).split( '.' ).pop();
                if ( this.geo && typeof this.geo.country === 'string' ) {
                        data.country = this.geo.country;
                }
+               if ( $file.attr( 'alt' ) ) {
+                       data.fileType = $file.attr( 'alt' ).split( '.' ).pop();
+               }
                data.isAnon = this.mwConfig.get( 'wgUserId' ) === null;
        };
 
diff --git a/tests/qunit/ext.imageMetrics.test.js 
b/tests/qunit/ext.imageMetrics.test.js
index 728eb55..e992ecb 100644
--- a/tests/qunit/ext.imageMetrics.test.js
+++ b/tests/qunit/ext.imageMetrics.test.js
@@ -20,30 +20,7 @@
                assert.ok( imageMetrics, 'Object created' );
        } );
 
-       QUnit.test( 'Sampling', 4, function ( assert ) {
-               var options = {},
-                       imageMetrics = createImageMetrics( this.sandbox, 
options );
-               imageMetrics.log();
-               assert.ok( !options.logEvent.called, 'Events not logged when 
sampling not set' );
-
-               options.config = { wgImageMetricsSamplingFactor: false };
-               imageMetrics = createImageMetrics( this.sandbox, options );
-               imageMetrics.log();
-               assert.ok( !options.logEvent.called, 'Events not logged when 
sampling set to false' );
-
-               options.config = { wgImageMetricsSamplingFactor: 0 };
-               imageMetrics = createImageMetrics( this.sandbox, options );
-               imageMetrics.log();
-               assert.ok( !options.logEvent.called, 'Events not logged when 
sampling set to 0' );
-
-               options.config = { wgImageMetricsSamplingFactor: 1 };
-               imageMetrics = createImageMetrics( this.sandbox, options );
-               $( '#qunit-fixture' ).append( '<div id="file"><img 
alt="Foo.jpg" /></div>' );
-               imageMetrics.log();
-               assert.ok( options.logEvent.called, 'Events logged when 
sampling set to 1' );
-       } );
-
-       QUnit.test( 'Minimal logging scenario', 10, function ( assert ) {
+       QUnit.test( 'Minimal logging scenario', 12, function ( assert ) {
                var data,
                        options = {
                                config: { wgImageMetricsSamplingFactor: 1 }
@@ -102,10 +79,10 @@
                imageMetrics.log();
                data = options.logEvent.firstCall.args[1];
 
-               assert.strictEqual( data.navigationType, 'navigation', 
'navigationType is logged correctly' );
+               assert.strictEqual( data.navigationType, 'navigate', 
'navigationType is logged correctly' );
        } );
 
-       QUnit.test( 'Resource Timing logging', 2, function ( assert ) {
+       QUnit.test( 'Resource Timing logging', 3, function ( assert ) {
                var data,
                        options = {
                                performance: { getEntriesByName: 
this.sandbox.stub().returns( [{
@@ -124,6 +101,6 @@
 
                assert.strictEqual( data.ownLoadingTime, 111, 'ownLoadingTime 
is logged correctly' );
                assert.strictEqual( data.fullLoadingTime, 10222, 
'fullLoadingTime is logged correctly' );
-               assert.strictEqual( data.fetchDelay, 22, 'fetchDelay is logged 
correctly' );
+               assert.strictEqual( data.fetchDelay, 89, 'fetchDelay is logged 
correctly' );
        } );
 } ( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/158891
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If2c8af0ee3643ce7de556bd040fa129f12efca01
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ImageMetrics
Gerrit-Branch: master
Gerrit-Owner: GergÅ‘ Tisza <[email protected]>
Gerrit-Reviewer: Gilles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to