Jdlrobson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/335713 )

Change subject: Remove unused code in repo
......................................................................

Remove unused code in repo

The existence of these files was causing me much confusion as I thought
they were still being used in the mpga branch.

If this is note the case they should be removed to make the repo easier
to understand.

Changes:
* Move the ext.popups.animation.less into ext.popups since that's where
its shipped.
* Remove files which are not being used.

Change-Id: Iae0a78d0b8a13353de70794b67387f2c3bab44c6
---
M extension.json
D resources/ext.popups.core/ext.popups.core.js
D resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js
D resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
R resources/ext.popups/styles/ext.popups.animation.less
D tests/qunit/ext.popups.core.test.js
D tests/qunit/ext.popups.desktopRenderer.test.js
D tests/qunit/ext.popups.renderer.article.test.js
D tests/qunit/ext.popups.schemaPopups.utils.test.js
9 files changed, 1 insertion(+), 1,134 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/13/335713/1

diff --git a/extension.json b/extension.json
index e9ec449..c59442c 100644
--- a/extension.json
+++ b/extension.json
@@ -112,7 +112,7 @@
                        },
                        "styles": [
                                
"resources/ext.popups/styles/ext.popups.core.less",
-                               
"resources/ext.popups.desktop/ext.popups.animation.less",
+                               
"resources/ext.popups/styles/ext.popups.animation.less",
                                
"resources/ext.popups/styles/ext.popups.settings.less"
                        ],
                        "messages": [
diff --git a/resources/ext.popups.core/ext.popups.core.js 
b/resources/ext.popups.core/ext.popups.core.js
deleted file mode 100644
index bc4fe65..0000000
--- a/resources/ext.popups.core/ext.popups.core.js
+++ /dev/null
@@ -1,134 +0,0 @@
-( function ( $, mw ) {
-       'use strict';
-       var previewCountStorageKey = 'ext.popups.core.previewCount',
-               popupsEnabledStorageKey = 'mwe-popups-enabled';
-
-       /**
-        * @class mw.popups
-        * @singleton
-        */
-       mw.popups = {};
-
-       /**
-        * The API object used for all this extension's requests
-        * @property {Object} api
-        */
-       mw.popups.api = new mw.Api();
-
-       /**
-        * Whether the page is being scrolled.
-        * @property {boolean} scrolled
-        */
-       mw.popups.scrolled = false;
-
-       /**
-        * Temporarily remove the title attribute of a link so that
-        * the tooltip doesn't show up alongside the Hovercard.
-        *
-        * @method removeTooltip
-        * @param {jQuery.Object} $link link from which to strip title
-        */
-       mw.popups.removeTooltip = function ( $link ) {
-               // We shouldn't empty the title attribute of links that
-               // can't have Hovercards, ie. TextExtracts didn't return
-               // anything. It's set in the article.init after attempting
-               // to make an API request.
-               if (
-                       $link.data( 'dont-empty-title' ) !== true &&
-                       $link.filter( '[title]:not([title=""])' ).length
-               ) {
-                       $link
-                               .data( 'title', $link.attr( 'title' ) )
-                               .attr( 'title', '' );
-               }
-       };
-
-       /**
-        * Restore previously-removed title attribute.
-        *
-        * @method restoreTooltip
-        * @param {jQuery.Object} $link link to which to restore title
-        */
-       mw.popups.restoreTooltip = function ( $link ) {
-               $link.attr( 'title', $link.data( 'title' ) );
-       };
-
-       /**
-        * Register a hover event that may render a popup on an appropriate 
link.
-        *
-        * @method setupTriggers
-        * @param {jQuery.Object} $elements to bind events to
-        * @param {string} events to bind to
-        */
-       mw.popups.setupTriggers = function ( $elements, events ) {
-               $elements.on( events, function ( event ) {
-                       if ( mw.popups.scrolled ) {
-                               return;
-                       }
-
-                       mw.popups.render.render( $( this ), event, 
mw.popups.getRandomToken() );
-               } );
-       };
-
-       /**
-        * Get action based on click event
-        *
-        * @method getAction
-        * @param {Object} event
-        * @return {string}
-        */
-       mw.popups.getAction = function ( event ) {
-               if ( event.which === 2 ) { // middle click
-                       return 'opened in new tab';
-               } else if ( event.which === 1 ) {
-                       if ( event.ctrlKey || event.metaKey ) {
-                               return 'opened in new tab';
-                       } else if ( event.shiftKey ) {
-                               return 'opened in new window';
-                       } else {
-                               return 'opened in same tab';
-                       }
-               }
-       };
-
-       /**
-        * Return edit count bucket based on the number of edits.
-        * The returned value is "unknown" is `window.localStorage` is not 
supported.
-        *
-        * @return {string}
-        */
-       mw.popups.getPreviewCountBucket = function () {
-               var bucket,
-                       previewCount = mw.storage.get( previewCountStorageKey );
-
-               // no support for localStorage
-               if ( previewCount === false ) {
-                       return 'unknown';
-               }
-
-               // Fall back to 0 if this is the first time.
-               previewCount = parseInt( previewCount || 0, 10 );
-
-               if ( previewCount === 0 ) {
-                       bucket = '0';
-               } else if ( previewCount >= 1 && previewCount <= 4 ) {
-                       bucket = '1-4';
-               } else if ( previewCount >= 5 && previewCount <= 20 ) {
-                       bucket = '5-20';
-               } else if ( previewCount >= 21 ) {
-                       bucket = '21+';
-               }
-
-               return bucket + ' previews';
-       };
-
-       /**
-        * Increment the preview count and save it to localStorage.
-        */
-       mw.popups.incrementPreviewCount = function () {
-               var previewCount = parseInt( mw.storage.get( 
previewCountStorageKey ) || 0, 10 );
-
-               mw.storage.set( previewCountStorageKey, ( previewCount + 1 
).toString() );
-       };
-
-} )( jQuery, mediaWiki );
diff --git 
a/resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js 
b/resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js
deleted file mode 100644
index f5368c0..0000000
--- a/resources/ext.popups.schemaPopups.utils/ext.popups.schemaPopups.utils.js
+++ /dev/null
@@ -1,165 +0,0 @@
-( function ( $, mw ) {
-       var dwellStartTime, perceivedWait;
-
-       /**
-        * Return data that will be logged with each EL request
-        *
-        * @return {Object}
-        */
-       function getDefaultValues() {
-               var defaults = {
-                       pageTitleSource: mw.config.get( 'wgTitle' ),
-                       namespaceIdSource: mw.config.get( 'wgNamespaceNumber' ),
-                       pageIdSource: mw.config.get( 'wgArticleId' ),
-                       isAnon: mw.user.isAnon(),
-                       hovercardsSuppressedByGadget: false,
-                       popupEnabled: mw.popups.getEnabledState(),
-                       popupDelay: mw.popups.render.POPUP_DELAY,
-                       pageToken: mw.user.generateRandomSessionId() +
-                               Math.floor( mw.now() ).toString() +
-                               mw.user.generateRandomSessionId(),
-                       sessionToken: mw.user.sessionId(),
-                       // arbitrary name that represents the current UI of the 
popups
-                       version: 'legacy',
-                       // current API version
-                       api: 'mwapi'
-               };
-
-               // Include edit count bucket to the list of default values if 
the user is logged in.
-               if ( !mw.user.isAnon() ) {
-                       defaults.editCountBucket = 
mw.popups.schemaPopups.getEditCountBucket(
-                               mw.config.get( 'wgUserEditCount' ) );
-               }
-
-               return defaults;
-       }
-
-       /**
-        * Return the sampling rate for the Schema:Popups
-        *
-        * User's session ID is used to determine the eligibility for logging,
-        * thus the function will result the same outcome as long as the browser
-        * hasn't been restarted or the cookie hasn't been cleared.
-        *
-        * @return {number}
-        */
-       function getSamplingRate() {
-               var bucket,
-                       samplingRate = mw.config.get( 
'wgPopupsSchemaPopupsSamplingRate', 0 );
-
-               if ( !$.isFunction( navigator.sendBeacon ) ) {
-                       return 0;
-               }
-
-               bucket = mw.experiments.getBucket( {
-                       name: 'ext.popups.schemaPopus',
-                       enabled: true,
-                       buckets: {
-                               control: 1 - samplingRate,
-                               A: samplingRate
-                       }
-               }, mw.user.sessionId() );
-
-               return bucket === 'A' ? 1 : 0;
-       }
-
-       /**
-        * Return edit count bucket based on the number of edits
-        *
-        * @param {number} editCount
-        * @return {string}
-        */
-       function getEditCountBucket( editCount ) {
-               var bucket;
-
-               if ( editCount === 0 ) {
-                       bucket = '0';
-               } else if ( editCount >= 1 && editCount <= 4 ) {
-                       bucket = '1-4';
-               } else if ( editCount >= 5 && editCount <= 99 ) {
-                       bucket = '5-99';
-               } else if ( editCount >= 100 && editCount <= 999 ) {
-                       bucket = '100-999';
-               } else if ( editCount >= 1000 ) {
-                       bucket = '1000+';
-               }
-
-               return bucket + ' edits';
-       }
-
-       /**
-        * Checks whether the event signals the end of a hovercards lifecycle
-        *
-        * @param {string} action
-        * @return {boolean}
-        */
-       function isFinalLifeCycleEvent( action ) {
-               return [ 'dwelledButAbandoned', 'opened in new window', 
'dismissed',
-                       'opened in new window', 'opened in same tab' ].indexOf( 
action ) > -1;
-       }
-
-       /**
-        * Return data after making some adjustments so that it's ready to be 
logged
-        * Returns false if the event should not be logged based on its 
contents or previous logged data
-        *
-        * @param {Object} data
-        * @param {Object} previousLogData
-        * @return {Object|boolean}
-        */
-       function processHovercardEvent( data, previousLogData ) {
-               // We don't log hover and display events as they are not 
compatible with the schema
-               // but they are useful for debugging
-               var action = data.action;
-
-               if ( dwellStartTime ) {
-                       // Calculate the perceived wait to show the hovercard 
(currently unused)
-                       // or the time elapsed before the user abandoned their 
hover
-                       if ( action === 'display' ) {
-                               perceivedWait = Math.round( mw.now() - 
dwellStartTime );
-                       } else {
-                               if ( perceivedWait ) {
-                                       data.perceivedWait = perceivedWait;
-                               }
-                               data.totalInteractionTime = Math.round( 
mw.now() - dwellStartTime );
-                       }
-               }
-
-               // Keep track of dwell time - a hover event should always be 
the first event in the hovercard lifecycle
-               if ( !dwellStartTime && action === 'hover' ) {
-                       dwellStartTime = mw.now();
-                       perceivedWait = false;
-               } else if ( isFinalLifeCycleEvent( action ) ) {
-                       // reset dwell start time to allow a new hover event to 
begin
-                       dwellStartTime = false;
-               }
-
-               if ( action && [ 'hover', 'display' ].indexOf( action ) > -1 ) {
-                       return false;
-               // Only one action is recorded per link interaction token...
-               } else if ( data.linkInteractionToken ) {
-                       // however, the 'disabled' action takes two clicks by 
nature, so allow it
-                       if ( previousLogData && data.linkInteractionToken === 
previousLogData.linkInteractionToken &&
-                               action !== 'disabled'
-                       ) {
-                               return false;
-                       // and a dwelled but abandoned event must following an 
event which has a dwell start
-                       } else if ( !data.totalInteractionTime && action === 
'dwelledButAbandoned' ) {
-                               return false;
-                       }
-               }
-               data.previewCountBucket = mw.popups.getPreviewCountBucket();
-               // Figure out `namespaceIdHover` from `pageTitleHover`.
-               if ( data.pageTitleHover && data.namespaceIdHover === undefined 
) {
-                       data.namespaceIdHover = new mw.Title( 
data.pageTitleHover ).getNamespaceId();
-               }
-               return data;
-       }
-
-       mw.popups.schemaPopups = {
-               getDefaultValues: getDefaultValues,
-               getSamplingRate: getSamplingRate,
-               getEditCountBucket: getEditCountBucket,
-               processHovercardEvent: processHovercardEvent
-       };
-
-} )( jQuery, mediaWiki );
diff --git a/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js 
b/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
deleted file mode 100644
index a471149..0000000
--- a/resources/ext.popups.schemaPopups/ext.popups.schemaPopups.js
+++ /dev/null
@@ -1,19 +0,0 @@
-( function ( mw ) {
-       var previousLogData,
-               // Log the popup event as defined in the schema
-               // https://meta.wikimedia.org/wiki/Schema:Popups
-               schemaPopups = new mw.eventLog.Schema(
-                       'Popups',
-                       mw.popups.schemaPopups.getSamplingRate(),
-                       mw.popups.schemaPopups.getDefaultValues()
-               );
-
-       mw.trackSubscribe( 'ext.popups.event', function ( topic, data ) {
-               data = mw.popups.schemaPopups.processHovercardEvent( data, 
previousLogData );
-
-               if ( data ) {
-                       schemaPopups.log( data );
-               }
-               previousLogData = data;
-       } );
-} )( mediaWiki );
diff --git a/resources/ext.popups.desktop/ext.popups.animation.less 
b/resources/ext.popups/styles/ext.popups.animation.less
similarity index 100%
rename from resources/ext.popups.desktop/ext.popups.animation.less
rename to resources/ext.popups/styles/ext.popups.animation.less
diff --git a/tests/qunit/ext.popups.core.test.js 
b/tests/qunit/ext.popups.core.test.js
deleted file mode 100644
index 5761013..0000000
--- a/tests/qunit/ext.popups.core.test.js
+++ /dev/null
@@ -1,291 +0,0 @@
-( function ( $, mw ) {
-
-       QUnit.module( 'ext.popups.core', QUnit.newMwEnvironment( {
-               config: {
-                       wgArticlePath: '/wiki/$1'
-               }
-       } ) );
-
-       // FIXME: This test should be split to cover each function separately 
and a browser test should
-       // be created to test user interactions with focus and mouseenter - 
planned for the Hovercards rewrite
-       QUnit.test( 'removeTooltip and restoreTooltip', function ( assert ) {
-               var $link = $( '<a>', {
-                       text: 'link with tooltip',
-                       title: 'link title',
-                       href: '#'  // `href` is needed for testing the `focus` 
event
-               } ).appendTo( 'body' );
-
-               QUnit.expect( 5 );
-
-               mw.popups.removeTooltip( $link );
-               assert.equal( $link.attr( 'title' ), '', 'The title should be 
removed by `removeTooltip`.' );
-
-               mw.popups.restoreTooltip( $link );
-               assert.equal( $link.attr( 'title' ), 'link title', 'The title 
should be restored by `restoreTooltip`.' );
-
-               mw.popups.removeTooltip( $link );
-               assert.equal( $link.attr( 'title' ), '', 'Multiple calls should 
still remove title attribute' );
-
-               mw.popups.restoreTooltip( $link );
-               assert.equal( $link.attr( 'title' ), 'link title', 'Multiple 
calls should still restore title attribute.' );
-
-               $link.data( 'dont-empty-title', true );
-               mw.popups.removeTooltip( $link );
-               assert.equal( $link.attr( 'title' ), 'link title',
-                       'The link title is not removed when `dont-empty-title` 
data attribute is `true`.' );
-
-               $link.remove();
-       } );
-
-       QUnit.test( 'setupTriggers', function ( assert ) {
-               var $link = $( '<a>', {
-                               text: 'Popups',
-                               title: 'Popups',
-                               href: '#'
-                       } ).appendTo( 'body' ),
-                       originalScrolled = mw.popups.scrolled,
-                       renderSpy = this.sandbox.stub( mw.popups.render, 
'render', $.noop ),
-                       $renderedElement;
-
-               assert.expect( 1 );
-
-               mw.popups.setupTriggers( $link, 'mouseenter focus' );
-
-               mw.popups.scrolled = false;
-               $link.trigger( 'mouseenter' );
-
-               $renderedElement = renderSpy.firstCall.args[ 0 ];
-
-               assert.strictEqual(
-                       // Compare the underlying element rather than (likely) 
differing instances of the jQuery
-                       // class.
-                       $renderedElement.get( 0 ),
-                       $link.get( 0 ),
-                       'When the "mouseenter" event fires then the underlying 
element is passed to the renderer.'
-               );
-
-               // Restore original state.
-               mw.popups.scrolled = originalScrolled;
-               $link.remove();
-       } );
-
-       QUnit.test( 'getAction', function ( assert ) {
-               var i, expected, actual,
-                       // 0 - main button, 1 - middle button
-                       cases = [
-                               [ { button: 0 }, 'opened in same tab' ],
-                               [ { button: 0, ctrlKey: true }, 'opened in new 
tab' ],
-                               [ { button: 0, metaKey: true }, 'opened in new 
tab' ],
-                               [ { button: 0, ctrlKey: true, shiftKey: true }, 
'opened in new tab' ],
-                               [ { button: 0, metaKey: true, shiftKey: true }, 
'opened in new tab' ],
-                               [ { button: 0, ctrlKey: true, metaKey: true, 
shiftKey: true }, 'opened in new tab' ],
-                               [ { button: 0, shiftKey: true }, 'opened in new 
window' ],
-                               [ { button: 1 }, 'opened in new tab' ],
-                               [ { button: 1, shiftKey: true }, 'opened in new 
tab' ]
-                       ];
-
-               QUnit.expect( cases.length );
-
-               for ( i = 0; i < cases.length; i++ ) {
-                       expected = cases[ i ][ 1 ];
-                       actual = mw.popups.getAction( new MouseEvent( 
'CustomEvent', cases[ i ][ 0 ] ) );
-                       assert.equal( actual, expected );
-               }
-       } );
-
-       QUnit.test( 'getRandomToken', function ( assert ) {
-               var token;
-
-               QUnit.expect( 3 );
-
-               token = mw.popups.getRandomToken();
-               assert.ok(
-                       token.length > mw.user.generateRandomSessionId().length,
-                       'Random token is long enough.'
-               );
-
-               assert.ok(
-                       typeof token === 'string',
-                       'Random token is a string.'
-               );
-
-               assert.notEqual(
-                       mw.popups.getRandomToken(),
-                       token,
-                       'Newly generated random token is not equal to the one 
generated earlier.'
-               );
-       } );
-
-       QUnit.test( 'getPreviewCountBucket', function ( assert ) {
-               var i, previewCount, bucket,
-                       cases = [
-                               [ '0', '0 previews' ],
-                               [ '1', '1-4 previews' ],
-                               [ '2', '1-4 previews' ],
-                               [ '4', '1-4 previews' ],
-                               [ '5', '5-20 previews' ],
-                               [ '10', '5-20 previews' ],
-                               [ '20', '5-20 previews' ],
-                               [ '21', '21+ previews' ],
-                               [ '100', '21+ previews' ],
-                               [ '1000', '21+ previews' ]
-                       ],
-                       storageKey = 'ext.popups.core.previewCount',
-                       mwStorageStub = this.sandbox.stub( mw.storage, 'get' )
-                               .withArgs( storageKey );
-
-               QUnit.expect( cases.length + 1 );
-
-               mwStorageStub.returns( false );
-               assert.equal(
-                       mw.popups.getPreviewCountBucket(),
-                       'unknown',
-                       'Preview count bucket is `unkown` when localStorage is 
unsupported.'
-               );
-
-               for ( i = 0; i < cases.length; i++ ) {
-                       previewCount = cases[ i ][ 0 ];
-                       mwStorageStub.returns( previewCount );
-                       bucket = mw.popups.getPreviewCountBucket();
-                       assert.equal(
-                               bucket,
-                               cases[ i ][ 1 ],
-                               'Preview count bucket is "' + bucket + '" when 
preview count is ' +
-                               previewCount + '.'
-                       );
-               }
-       } );
-
-       QUnit.test( 'incrementPreviewCount', function ( assert ) {
-               var storageKey = 'ext.popups.core.previewCount',
-                       mwStorageGetStub = this.sandbox.stub( mw.storage, 'get' 
)
-                               .withArgs( storageKey ),
-                       mwStorageSetStub = this.sandbox.stub( mw.storage, 'set' 
);
-
-               QUnit.expect( 3 );
-
-               mwStorageGetStub.returns( null );
-               mw.popups.incrementPreviewCount();
-               assert.equal(
-                       mwStorageSetStub.firstCall.args[ 1 ],
-                       1,
-                       'Incrementing the preview count to 1 when no value has' 
+
-                       ' been saved in localStorage yet.'
-               );
-
-               mwStorageGetStub.returns( '1' );
-               mw.popups.incrementPreviewCount();
-               assert.equal(
-                       mwStorageSetStub.secondCall.args[ 1 ],
-                       2,
-                       'Incrementing the preview count to 2 when the value in 
localStorage' +
-                       ' is already "1".'
-               );
-
-               mwStorageGetStub.returns( '5' );
-               mw.popups.incrementPreviewCount();
-               assert.equal(
-                       mwStorageSetStub.thirdCall.args[ 1 ],
-                       6,
-                       'Incrementing the preview count to 6 when the value in 
localStorage' +
-                       ' is already "5".'
-               );
-       } );
-
-       QUnit.test( 'saveEnabledState', function ( assert ) {
-               var storageKey = 'mwe-popups-enabled',
-                       deviceStorageStub = this.sandbox.stub( mw.storage, 
'set' )
-                               .withArgs( storageKey );
-
-               QUnit.expect( 2 );
-
-               mw.popups.saveEnabledState( true );
-               assert.equal(
-                       deviceStorageStub.firstCall.args[ 1 ],
-                       '1',
-                       'Popups enabled state has been saved as "true".'
-               );
-
-               mw.popups.saveEnabledState( false );
-               assert.equal(
-                       deviceStorageStub.secondCall.args[ 1 ],
-                       '0',
-                       'Popups enabled state has been saved as "false".'
-               );
-       } );
-
-       QUnit.test( 'getEnabledState', function ( assert ) {
-               var storageKey = 'mwe-popups-enabled',
-                       mwConfigStub = this.sandbox.stub( mw.config, 'get' )
-                               .withArgs( 'wgPopupsExperiment' ),
-                       deviceStorageStub = this.sandbox.stub( mw.storage, 
'get' )
-                               .withArgs( storageKey ),
-                       experimentStub = this.sandbox.stub( mw.popups,
-                               'isUserInCondition' );
-
-               QUnit.expect( 7 );
-
-               mwConfigStub.returns( null );
-               deviceStorageStub.returns( null );
-               assert.equal(
-                       mw.popups.getEnabledState(),
-                       true,
-                       'Popups are enabled when the experiment is not running, 
nor has' +
-                       ' Popups been disabled via the settings.'
-               );
-
-               mwConfigStub.returns( null );
-               deviceStorageStub.returns( '1' );
-               assert.equal(
-                       mw.popups.getEnabledState(),
-                       true,
-                       'Popups are enabled when the experiment is not running 
and when' +
-                       ' Popups has been enabled via the settings.'
-               );
-
-               mwConfigStub.returns( null );
-               deviceStorageStub.returns( '0' );
-               assert.equal(
-                       mw.popups.getEnabledState(),
-                       false,
-                       'Popups are disabled when the experiment is not running 
and when' +
-                       ' Popups has been disabled via the settings.'
-               );
-
-               mwConfigStub.returns( false );
-               deviceStorageStub.returns( '1' );
-               assert.equal(
-                       mw.popups.getEnabledState(),
-                       true,
-                       'Popups are enabled when the experiment is disabled and 
when' +
-                       ' Popups has been enabled via the settings.'
-               );
-
-               mwConfigStub.returns( false );
-               deviceStorageStub.returns( '0' );
-               assert.equal(
-                       mw.popups.getEnabledState(),
-                       false,
-                       'Popups are disabled when the experiment is disabled 
and when' +
-                       ' Popups has been disabled via the settings.'
-               );
-
-               mwConfigStub.returns( true );
-               experimentStub.returns( true );
-               assert.equal(
-                       mw.popups.getEnabledState(),
-                       true,
-                       'Popups are disabled when the experiment is running and 
' +
-                       ' the user is bucketed.'
-               );
-
-               mwConfigStub.returns( true );
-               experimentStub.returns( false );
-               assert.equal(
-                       mw.popups.getEnabledState(),
-                       false,
-                       'Popups are disabled when the experiment is running and 
' +
-                       ' the user is not bucketed.'
-               );
-       } );
-} )( jQuery, mediaWiki );
diff --git a/tests/qunit/ext.popups.desktopRenderer.test.js 
b/tests/qunit/ext.popups.desktopRenderer.test.js
deleted file mode 100644
index c26651e..0000000
--- a/tests/qunit/ext.popups.desktopRenderer.test.js
+++ /dev/null
@@ -1,27 +0,0 @@
-( function ( $, mw ) {
-       QUnit.module( 'ext.popups.renderer.desktopRenderer', {
-               setup: function () {
-                       mw.popups.$popup = $( '<div>' );
-                       mw.popups.render.cache[ '/wiki/Kittens' ] = {
-                               settings: {
-                                       title: 'Kittens'
-                               },
-                               popup: $( '<div>hello</div>' ),
-                               getClasses: function () {
-                                       return [ 'foo' ];
-                               },
-                               process: $.noop,
-                               getOffset: function () {
-                                       return {};
-                               }
-                       };
-               }
-       } );
-
-       QUnit.test( 'mw.popups.render.openPopup (T68496)', 1, function ( assert 
) {
-               mw.popups.render.openPopup( $( '<a href="/wiki/Kittens">' ) );
-               mw.popups.render.openPopup( $( '<a href="/wiki/Kittens">' ) );
-               assert.strictEqual( mw.popups.render.cache[ '/wiki/Kittens' 
].popup.text(), 'hello' );
-       } );
-
-} )( jQuery, mediaWiki );
diff --git a/tests/qunit/ext.popups.renderer.article.test.js 
b/tests/qunit/ext.popups.renderer.article.test.js
deleted file mode 100644
index 388e2da..0000000
--- a/tests/qunit/ext.popups.renderer.article.test.js
+++ /dev/null
@@ -1,203 +0,0 @@
-( function ( $, mw ) {
-
-       QUnit.module( 'ext.popups.renderer.renderers.article', {
-               setup: function () {
-                       mw.popups.render.cache[ '/wiki/Kittens' ] = {};
-                       this.sandbox.stub( mw.popups, 'getTitle' ).returns( 
'Kittens' );
-                       this.pageInfo = {
-                               thumbnail: {
-                                       source: 
'http://commons.wikimedia.org/kittypic.svg',
-                                       width: 100,
-                                       height: 300
-                               },
-                               revisions: [ { timestamp: '20160403020100' } ],
-                               extract: 'Cute.',
-                               title: 'Kittens',
-                               pagelanguagehtmlcode: 'en',
-                               pagelanguagedir: 'ltr'
-                       };
-                       this.kittenResponse = {
-                               query: {
-                                       pages: [
-                                               this.pageInfo
-                                       ]
-                               }
-                       };
-                       this.apiStub = this.sandbox.stub( mw.popups.api, 'get' 
).returns(
-                               $.Deferred().resolve( this.kittenResponse )
-                       );
-               }
-       } );
-
-       QUnit.test( 'render.article.getProcessedElements', function ( assert ) {
-               QUnit.expect( 15 );
-
-               function test( extract, title, expected, msg ) {
-                       var $div = $( '<div>' ).append(
-                               
mw.popups.render.renderers.article.getProcessedElements( extract, title )
-                       );
-                       assert.equal( $div.html(), expected, msg );
-               }
-
-               test(
-                       'Isaac Newton was born in', 'Isaac Newton',
-                       '<b>Isaac Newton</b> was born in',
-                       'Title as first word'
-               );
-
-               test(
-                       'The C* language not to be confused with C# or C', 'C*',
-                       'The <b>C*</b> language not to be confused with C# or 
C',
-                       'Title containing *'
-               );
-
-               test(
-                       'Person (was born in Location) is good', 'Person',
-                       '<b>Person</b> is good',
-                       'Extract with text in parentheses'
-               );
-
-               test(
-                       'Person, (was born in Location) is good', 'Person',
-                       '<b>Person</b>, is good',
-                       'Comma after title'
-               );
-
-               test(
-                       'Person (was born in Location (at Time)) is good', 
'Person',
-                       '<b>Person</b> is good',
-                       'Extract with nested parentheses'
-               );
-
-               test(
-                       'Person (was born in Location (at Time) ) is good', 
'Person',
-                       '<b>Person</b> is good',
-                       'Extract with nested parentheses and random spaces'
-               );
-
-               test(
-                       'I like trains', 'Train',
-                       'I like <b>train</b>s',
-                       'Make the simple plural bold'
-               );
-
-               test(
-                       'Brackets ) are funny ( when not used properly', 
'Brackets',
-                       '<b>Brackets</b> ) are funny ( when not used properly',
-                       'Extract with unbalanced parentheses'
-               );
-
-               test(
-                       'Vappu (born August 7), also known as Lexy', 'Vappu',
-                       '<b>Vappu</b>, also known as Lexy',
-                       'Spaces around bracketed text should be removed'
-               );
-
-               test(
-                       'Epic XSS <script>alert("XSS")</script> is epic', 'Epic 
XSS',
-                       '<b>Epic XSS</b> &lt;script&gt;alert&lt;/script&gt; is 
epic',
-                       'XSS Attack'
-               );
-
-               test(
-                       'Foo\'s pub is a pub in Bar', 'Foo\'s pub',
-                       '<b>Foo\'s pub</b> is a pub in Bar',
-                       'Correct escaping'
-               );
-
-               test(
-                       '\"Heroes\" is a David Bowie album', '\"Heroes\"',
-                       '<b>\"Heroes\"</b> is a David Bowie album',
-                       'Quotes in title'
-               );
-
-               test(
-                       '*Testing if Things are correctly identified', 'Things',
-                       '*Testing if <b>Things</b> are correctly identified',
-                       'Article that begins with asterisk'
-               );
-
-               test(
-                       'Testing if repeated words are not matched when 
repeated', 'Repeated',
-                       'Testing if <b>repeated</b> words are not matched when 
repeated',
-                       'Repeated title'
-               );
-
-               test(
-                       'Evil Empire is the second studio album', 'Evil Empire 
(album)',
-                       '<b>Evil Empire</b> is the second studio album',
-                       'Extra information in title in paranthesis'
-               );
-
-       } );
-       QUnit.test( 'render.article.getClosestYPosition', function ( assert ) {
-               QUnit.expect( 3 );
-               assert.equal( mw.popups.render.getClosestYPosition( 100, [
-                       {
-                               top: 99,
-                               bottom: 119
-                       },
-                       {
-                               top: 120,
-                               bottom: 140
-                       }
-               ] ), 119, 'Correct lower Y.' );
-
-               assert.equal( mw.popups.render.getClosestYPosition( 100, [
-                       {
-                               top: 99,
-                               bottom: 119
-                       },
-                       {
-                               top: 120,
-                               bottom: 140
-                       }
-               ], true ), 99, 'Correct upper Y.' );
-
-               assert.equal( mw.popups.render.getClosestYPosition( 135, [
-                       {
-                               top: 99,
-                               bottom: 119
-                       },
-                       {
-                               top: 120,
-                               bottom: 140
-                       }
-               ], true ), 120, 'Correct upper Y 2.' );
-       } );
-
-       QUnit.test( 'render.article.createPopup', function ( assert ) {
-               var $popup, $thumbLink, $extractLink, cache;
-
-               QUnit.expect( 6 );
-               $popup = mw.popups.render.renderers.article.createPopup( 
this.pageInfo, '/wiki/Kittens' );
-               $thumbLink = $popup.find( 'a' ).eq( 0 );
-               $extractLink = $popup.find( 'a' ).eq( 1 );
-
-               assert.ok( $thumbLink.hasClass( 'mwe-popups-discreet' ) );
-               assert.strictEqual( $thumbLink.attr( 'href' ), '/wiki/Kittens' 
);
-               assert.strictEqual( $extractLink.text(), 'Cute.', 'Text extract 
present.' );
-               cache = mw.popups.render.cache[ '/wiki/Kittens' ];
-               assert.strictEqual( cache.settings.title, 'Kittens' );
-               assert.strictEqual( cache.settings.tall, true,
-                       'height is greater than width so marked as tall.' );
-               assert.strictEqual( cache.settings.thumbnail, 
this.pageInfo.thumbnail,
-                       'thumbnail information got cached' );
-       } );
-
-       QUnit.asyncTest( 'render.article.init', function ( assert ) {
-               var $kittyLink = $( '<a href="/wiki/Kittens">' ),
-                       apiStub = this.apiStub;
-
-               QUnit.expect( 2 );
-               mw.popups.render.renderers.article.init( $kittyLink );
-               mw.popups.render.renderers.article.init( $kittyLink ).done( 
function () {
-                       var cache =  mw.popups.render.cache[ '/wiki/Kittens' ];
-                       QUnit.start();
-                       assert.ok( cache.popup.length, 'The popup is stored in 
cache.' );
-                       assert.ok( apiStub.calledTwice,
-                                       'This method in current form is dumb 
and if called more than once will not load from cache.' );
-               } );
-       } );
-
-} )( jQuery, mediaWiki );
diff --git a/tests/qunit/ext.popups.schemaPopups.utils.test.js 
b/tests/qunit/ext.popups.schemaPopups.utils.test.js
deleted file mode 100644
index 3113bc2..0000000
--- a/tests/qunit/ext.popups.schemaPopups.utils.test.js
+++ /dev/null
@@ -1,294 +0,0 @@
-( function ( $, mw ) {
-       var schemaPopups = mw.popups.schemaPopups;
-
-       /**
-        * Simulates a test run of several events.
-        *
-        * @param {Array} actions list of event actions
-        * @param {Object} [additionalData] to log
-        * @return {Array|false} the result of the last event to be run.
-        */
-       function runEventSequence( actions, additionalData ) {
-               var previousEvent;
-
-               $.each( actions, function ( i, action ) {
-                       previousEvent = schemaPopups.processHovercardEvent( 
$.extend( {
-                                       action: action
-                               }, additionalData || {} ), previousEvent );
-               } );
-               return previousEvent;
-       }
-
-       QUnit.module( 'ext.popups.schemaPopups.utils', {
-               setup: function () {
-                       var ts = 1477422540409;
-                       this.sandbox.stub( mw.popups, 'getPreviewCountBucket' 
).returns(
-                               '5-20 previews'
-                       );
-                       this.sandbox.stub( mw, 'now' )
-                               .onFirstCall().returns( ts ) // hover
-                               .onSecondCall().returns( ts + 5000 )
-                               .onThirdCall().returns( ts + 15000 ) // 
sometimes second hover if dwelled but abandoned is end of first sequence
-                               .onCall( 3 ).returns( ts + 15000 + 200 ) // 
second hover
-                               .onCall( 4 ).returns( ts + 15000 + 200 + 500 )
-                               .onCall( 5 ).returns( ts + 15000 + 200 + 700 );
-               }
-       } );
-
-       QUnit.test( 'getSamplingRate', function ( assert ) {
-               var configStub = this.sandbox.stub( mw.config, 'get' )
-                               .withArgs( 'wgPopupsSchemaPopupsSamplingRate' ),
-                       isFunctionStub = this.sandbox.stub( $, 'isFunction' )
-                               .withArgs( navigator.sendBeacon ),
-                       mwUserSessionIdStub = this.sandbox.stub( mw.user, 
'sessionId' );
-
-               QUnit.expect( 9 );
-
-               isFunctionStub.returns( false );
-               assert.equal( schemaPopups.getSamplingRate(), 0,
-                       'Sampling rate is 0 when `navigator.sendBeacon` is 
unavailable.' );
-
-               isFunctionStub.returns( true );
-
-               configStub.returns( null );
-               mwUserSessionIdStub.returns( 'abc' );
-               assert.equal( schemaPopups.getSamplingRate(), 0,
-                       'Sampling rate is 0 when the 
`wgPopupsSchemaPopupsSamplingRate`' +
-                       ' config variable is undefined and' +
-                       ' `mw.user.sessionId() = ' + mw.user.sessionId() + '`.' 
);
-
-               configStub.returns( null );
-               mwUserSessionIdStub.returns( 'def' );
-               assert.equal( schemaPopups.getSamplingRate(), 0,
-                       'Sampling rate is 0 when the 
`wgPopupsSchemaPopupsSamplingRate`' +
-                       ' config variable is undefined and' +
-                       ' `mw.user.sessionId() = ' + mw.user.sessionId() + '`.' 
);
-
-               configStub.returns( 0 );
-               mwUserSessionIdStub.returns( 'abc' );
-               assert.equal( schemaPopups.getSamplingRate(), 0,
-                       'Sampling rate is 0 when 
`wgPopupsSchemaPopupsSamplingRate = 0`' +
-                       ' `mw.user.sessionId() = ' + mw.user.sessionId() + '`.' 
);
-
-               configStub.returns( 0 );
-               mwUserSessionIdStub.returns( 'def' );
-               assert.equal( schemaPopups.getSamplingRate(), 0,
-                       'Sampling rate is 0 when 
`wgPopupsSchemaPopupsSamplingRate = 0`' +
-                       ' `mw.user.sessionId() = ' + mw.user.sessionId() + '`.' 
);
-
-               configStub.returns( 1 );
-               mwUserSessionIdStub.returns( 'abc' );
-               assert.equal( schemaPopups.getSamplingRate(), 1,
-                       'Sampling rate is 1 when 
`wgPopupsSchemaPopupsSamplingRate = 1`' +
-                       ' `mw.user.sessionId() = ' + mw.user.sessionId() + '`.' 
);
-
-               configStub.returns( 1 );
-               mwUserSessionIdStub.returns( 'def' );
-               assert.equal( schemaPopups.getSamplingRate(), 1,
-                       'Sampling rate is 1 when 
`wgPopupsSchemaPopupsSamplingRate = 1`' +
-                       ' `mw.user.sessionId() = ' + mw.user.sessionId() + '`.' 
);
-
-               configStub.returns( 0.5 );
-               mwUserSessionIdStub.returns( 'abc' );
-               assert.equal( schemaPopups.getSamplingRate(), 1,
-                       'Sampling rate is 1 when 
`wgPopupsSchemaPopupsSamplingRate = 0.5` and' +
-                       ' `mw.user.sessionId() = ' + mw.user.sessionId() + '`.' 
);
-
-               configStub.returns( 0.5 );
-               mwUserSessionIdStub.returns( 'def' );
-               assert.equal( schemaPopups.getSamplingRate(), 0,
-                       'Sampling rate is 0 when 
`wgPopupsSchemaPopupsSamplingRate = 0.5` and' +
-                       ' `mw.user.sessionId() = ' + mw.user.sessionId() + '`.' 
);
-       } );
-
-       QUnit.test( 'getEditCountBucket', function ( assert ) {
-               var i, bucket, editCount,
-                       cases = [
-                               [ 0, '0 edits' ],
-                               [ 1, '1-4 edits' ],
-                               [ 2, '1-4 edits' ],
-                               [ 4, '1-4 edits' ],
-                               [ 5, '5-99 edits' ],
-                               [ 25, '5-99 edits' ],
-                               [ 50, '5-99 edits' ],
-                               [ 99, '5-99 edits' ],
-                               [ 100, '100-999 edits' ],
-                               [ 101, '100-999 edits' ],
-                               [ 500, '100-999 edits' ],
-                               [ 999, '100-999 edits' ],
-                               [ 1000, '1000+ edits' ],
-                               [ 1500, '1000+ edits' ]
-                       ];
-
-               QUnit.expect( cases.length );
-
-               for ( i = 0; i < cases.length; i++ ) {
-                       editCount = cases[ i ][ 0 ];
-                       bucket = schemaPopups.getEditCountBucket( editCount );
-                       assert.equal(
-                               bucket,
-                               cases[ i ][ 1 ],
-                               'Edit count bucket is "' + bucket + '" when 
edit count is ' +
-                                       editCount + '.'
-                       );
-               }
-       } );
-
-       QUnit.test( 'processHovercardEvent - dwell start time gets deleted', 2, 
function ( assert ) {
-               var newData,
-                       initialData = {};
-
-               newData = schemaPopups.processHovercardEvent( initialData );
-               assert.equal( newData.previewCountBucket, '5-20 previews' );
-               assert.ok( newData.dwellStartTime === undefined );
-       } );
-
-       QUnit.test( 'processHovercardEvent - namespaceIdHover is added', 1, 
function ( assert ) {
-               var newData,
-                       initialData = {
-                               pageTitleHover: 'Talk:Foo'
-                       };
-
-               newData = schemaPopups.processHovercardEvent( initialData );
-               assert.ok( newData.namespaceIdHover === 1, 'namespace is added 
based on title' );
-       } );
-
-       QUnit.test( 'processHovercardEvent - returns false if the data should 
not be logged due to being a duplicate', 3, function ( assert ) {
-               var
-                       thisEvent = {
-                               action: 'myevent',
-                               dwellStartTime: 1,
-                               linkInteractionToken: 't'
-                       },
-                       previousEvent = {
-                               action: 'myevent',
-                               linkInteractionToken: 't'
-                       },
-                       settingsEvent = {
-                               action: 'disabled',
-                               linkInteractionToken: 't'
-                       };
-
-               assert.ok( schemaPopups.processHovercardEvent( thisEvent, 
previousEvent ) === false, 'duplicate events are ignored...' );
-               assert.ok( schemaPopups.processHovercardEvent( settingsEvent, 
thisEvent ) !== false, '... unless disabled event' );
-               assert.ok( thisEvent.dwellStartTime === 1, 'and no side 
effects' );
-       } );
-
-       QUnit.test( 'processHovercardEvent - returns false for hover and 
display events', 2, function ( assert ) {
-               assert.ok( runEventSequence( [ 'hover' ] ) === false );
-               assert.ok( runEventSequence( [ 'display' ] ) === false );
-       } );
-
-       QUnit.test( 'processHovercardEvent - check calculations of opened in 
new window', 1, function ( assert ) {
-               var logData = runEventSequence( [ 'hover', 'display', 'opened 
in new window' ] );
-
-               assert.ok( logData.totalInteractionTime === 15000 );
-       } );
-
-       QUnit.test( 'processHovercardEvent - check calculations of 
dwelledButAbandoned event', 2, function ( assert ) {
-               var logData = runEventSequence( [ 'hover', 
'dwelledButAbandoned' ] );
-               assert.ok( logData.perceivedWait === undefined );
-               assert.ok( logData.totalInteractionTime === 5000 );
-       } );
-
-       QUnit.test( 'processHovercardEvent - dwelledButAbandoned without 
hover', 1, function ( assert ) {
-               var logData = runEventSequence( [ 'hover', 
'dwelledButAbandoned', 'dwelledButAbandoned' ],
-                       { linkInteractionToken: 'a' } );
-
-               assert.ok( logData === false, 'if no interaction time reject 
it' );
-       } );
-
-       QUnit.test( 'processHovercardEvent - interaction time is reset on 
hover', 2, function ( assert ) {
-               var logData = runEventSequence( [
-                       'hover', 'dwelledButAbandoned',
-                       'hover', 'display', 'opened in new window'
-               ] );
-
-               assert.ok( logData.perceivedWait !== undefined );
-               assert.ok( logData.totalInteractionTime === 700 );
-       } );
-
-       QUnit.test( 'processHovercardEvent - multiple dwelledButAbandoned 
ignored', 1, function ( assert ) {
-               var logData = runEventSequence( [
-                       'hover', 'dwelledButAbandoned', 'dwelledButAbandoned'
-               ], {
-                       linkInteractionToken: 'a'
-               } );
-
-               assert.ok( logData === false, 'duplicate dwelledButAbandoned 
ignored' );
-       } );
-
-       QUnit.test( 'processHovercardEvent - no display event (opened in same 
tab)', 2, function ( assert ) {
-               var logData = runEventSequence( [
-                       'hover', 'opened in same tab'
-               ] );
-
-               assert.ok( logData.perceivedWait === undefined,
-                       'if no display event no perceived wait can be 
calculated' );
-               assert.ok( logData.totalInteractionTime === 5000,
-                       'but totalInteractionTime can be calculated' );
-       } );
-
-       QUnit.test( 'processHovercardEvent - dwelledButAbandoned triggered if 
no link interaction token', 1, function ( assert ) {
-               var logData = runEventSequence( [
-                       'hover', 'dwelledButAbandoned', 'dwelledButAbandoned'
-               ] );
-
-               assert.ok( logData.totalInteractionTime === undefined,
-                       // is this correct behaviour? We may want to revisit 
this.
-                       'if no link interaction time the duplicate event is 
generated but has no total interaction time' );
-       } );
-
-       QUnit.test( 'processHovercardEvent - opened in same tab without a 
hover', 2, function ( assert ) {
-               var logDataSequence = runEventSequence( [
-                       'opened in same tab'
-               ], {
-                       linkInteractionToken: 'a'
-               } ),
-               logDataSequenceTwo = runEventSequence( [
-                       'opened in same tab'
-               ] );
-
-               assert.ok( logDataSequence.totalInteractionTime === undefined,
-                       'If a end lifecycle event occurs without a hover event 
occuring beforehand it generates an invalid event' );
-               assert.ok( logDataSequenceTwo.totalInteractionTime === 
undefined,
-                       'If a end lifecycle event occurs without a hover event 
occuring beforehand it generates an invalid event' );
-       } );
-
-       QUnit.test( 'processHovercardEvent - dwell start time gets reset on 
dismissed events', 4, function ( assert ) {
-               var logDataSequence = runEventSequence( [
-                       'hover', 'display', 'dismissed'
-               ], {
-                       linkInteractionToken: 'a'
-               } ),
-               logDataSequenceTwo = runEventSequence( [
-                       'hover', 'display', 'dismissed'
-               ], {
-                       linkInteractionToken: 'b'
-               } );
-
-               assert.ok( logDataSequence.totalInteractionTime === 15000  );
-               assert.ok( logDataSequence.perceivedWait !== undefined  );
-               assert.ok( logDataSequenceTwo.totalInteractionTime === 700,
-                       'The first interaction leads to the rest of the timer.' 
);
-               assert.ok( logDataSequenceTwo.perceivedWait !== undefined  );
-       } );
-
-       QUnit.test( 'processHovercardEvent - perceivedWait should be set for 
"opened in" events', 2, function ( assert ) {
-               var data = runEventSequence( [
-                       'hover',
-                       'display',
-                       'opened in same tab'
-               ] );
-
-               assert.ok( data.perceivedWait !== undefined );
-
-               data = runEventSequence( [
-                       'hover',
-                       'display',
-                       'opened in new tab'
-               ] );
-
-               assert.ok( data.perceivedWait !== undefined );
-       } );
-} )( jQuery, mediaWiki );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iae0a78d0b8a13353de70794b67387f2c3bab44c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: mpga
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to