Kaldari has uploaded a new change for review.

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

Change subject: Cherry-pick of: Enable WikiGrok A/B test using 
wgMFEnableWikiGrok
......................................................................

Cherry-pick of: Enable WikiGrok A/B test using wgMFEnableWikiGrok

* Sunset wgMFWikiGrokAbTest{Start,End}Date configuration variables
* Still use WikiGrokAbTest#isEnabled to determine if the A/B test is
  enabled
* Allow user to force WikiGrok to load even if A/B test is disabled

Change-Id: I3ec0190a34c1ae70e6becee904abdebde80ee038
---
M includes/skins/SkinMinerva.php
M javascripts/modules/wikigrok/WikiGrokAbTest.js
M javascripts/modules/wikigrok/init.js
M tests/qunit/modules/wikigrok/test_WikiGrokAbTest.js
4 files changed, 15 insertions(+), 48 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/07/177007/1

diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index a176bd4..d5caddc 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -814,8 +814,7 @@
                        $wgMFAnonymousEditing,
                        $wgMFPhotoUploadEndpoint, $wgMFPhotoUploadAppendToDesc,
                        $wgMFCollapseSectionsByDefault, $wgMFShowRedLinksAnon,
-                       $wgMFShowRedLinks,
-                       $wgMFWikiGrokAbTestStartDate, 
$wgMFWikiGrokAbTestEndDate;
+                       $wgMFShowRedLinks;
 
                $title = $this->getTitle();
                $user = $this->getUser();
@@ -861,8 +860,6 @@
                if ( $this->isMobileMode ) {
                        $vars['wgImagesDisabled'] = 
$this->mobileContext->imagesDisabled();
                        $vars['wgUserCanUpload'] = 
$this->mobileContext->userCanUpload();
-                       $vars['wgMFWikiGrokAbTestStartDate'] = 
$wgMFWikiGrokAbTestStartDate;
-                       $vars['wgMFWikiGrokAbTestEndDate'] = 
$wgMFWikiGrokAbTestEndDate;
                }
 
                return $vars;
diff --git a/javascripts/modules/wikigrok/WikiGrokAbTest.js 
b/javascripts/modules/wikigrok/WikiGrokAbTest.js
index 0461149..e2fa1a1 100644
--- a/javascripts/modules/wikigrok/WikiGrokAbTest.js
+++ b/javascripts/modules/wikigrok/WikiGrokAbTest.js
@@ -13,15 +13,10 @@
                        /**
                         * Initialises a new instance of the WikiGrokAbTest 
class.
                         *
-                        * @param {Number} startDate The date the test starts, 
specified as a Unix
-                        *  timestamp
-                        * @param {Number} endDate The date that the test ends, 
specified as a Unix
-                        *  timestamp
+                        * @param {Boolean} isEnabled Whether or not the A/B 
test is enabled
                         */
-                       initialize: function ( startDate, endDate ) {
-                               var now = new Date().getTime() / 1000;
-
-                               this.isEnabled = startDate && endDate && ( 
startDate <= now && now <= endDate );
+                       initialize: function ( isEnabled ) {
+                               this.isEnabled = isEnabled;
                        },
 
                        /**
@@ -38,22 +33,13 @@
                } );
 
        /**
-        * Creates a new instance of the WikiGrokAbTest using
-        * `wfMFWikiGrokAbTestStartDate` and `wgMFWikiGrokAbTestEndDate` as the 
`startDate`
-        * and `endDate` parameters respectively.
+        * Creates a new instance of the WikiGrokAbTest using 
`wgMFEnableWikiGrok` as
+        * the `isEnabled` parameter.
         *
         * @return {WikiGrokAbTest}
         */
        WikiGrokAbTest.newFromMwConfig = function () {
-               var config = mw.config.get( [
-                       'wgMFWikiGrokAbTestStartDate',
-                       'wgMFWikiGrokAbTestEndDate'
-               ] );
-
-               return new WikiGrokAbTest(
-                       config.wgMFWikiGrokAbTestStartDate,
-                       config.wgMFWikiGrokAbTestEndDate
-               );
+               return new WikiGrokAbTest( mw.config.get( 'wgMFEnableWikiGrok' 
) );
        };
 
        M.define( 'WikiGrokAbTest', WikiGrokAbTest );
diff --git a/javascripts/modules/wikigrok/init.js 
b/javascripts/modules/wikigrok/init.js
index f0af48b..b12c950 100644
--- a/javascripts/modules/wikigrok/init.js
+++ b/javascripts/modules/wikigrok/init.js
@@ -67,8 +67,8 @@
        }
 
        if (
-               // WikiGrok is enabled
-               mw.config.get( 'wgMFEnableWikiGrok' ) &&
+               // WikiGrok is enabled and configured for this user
+               versionConfig &&
                // We're not on the Main Page
                !mw.config.get( 'wgIsMainPage' ) &&
                // Permitted on this device
@@ -78,8 +78,7 @@
                // Wikibase is active and this page has an item ID
                wikidataID &&
                // We're in Main namespace,
-               mw.config.get( 'wgNamespaceNumber' ) === 0 &&
-               versionConfig
+               mw.config.get( 'wgNamespaceNumber' ) === 0
        ) {
 
                // Load the required module and view based on the version for 
the user
diff --git a/tests/qunit/modules/wikigrok/test_WikiGrokAbTest.js 
b/tests/qunit/modules/wikigrok/test_WikiGrokAbTest.js
index 5946e7e..be5ec0a 100644
--- a/tests/qunit/modules/wikigrok/test_WikiGrokAbTest.js
+++ b/tests/qunit/modules/wikigrok/test_WikiGrokAbTest.js
@@ -2,28 +2,13 @@
 
        var WikiGrokAbTest = M.require( 'WikiGrokAbTest' ),
                wikiGrokUser = M.require( 'wikiGrokUser' ),
-               now = new Date().getTime() / 1000,
-               enabledTest = new WikiGrokAbTest( now - 86400, now + 86400 );
+               enabledTest = new WikiGrokAbTest( true );
 
-       QUnit.module( 'MobileFrontend: modules/wikigrok/WikiGrokAbTest', {
-       } );
+       QUnit.module( 'MobileFrontend: modules/wikigrok/WikiGrokAbTest' );
 
-       QUnit.test( 'isEnabled returns false when the experiment isn\'t 
enabled', 2, function ( assert ) {
-               var dataProvider = [
-                               [now + 86400, now + 86401], // startDate is in 
the future
-                               [now - 86400, now - 86401], // endDate in the 
past
-                       ],
-                       test;
-
-               $.each( dataProvider, function ( i, data ) {
-                       test = new WikiGrokAbTest( data[0], data[1] );
-
-                       assert.strictEqual( test.isEnabled, false );
-               } );
-       } );
-
-       QUnit.test( 'isEnabled returns true when the test is active', 1, 
function ( assert ) {
-               assert.strictEqual( enabledTest.isEnabled, true );
+       QUnit.test( 'isEnabled simply exposes the isEnabled constructor 
parameter', 2, function ( assert ) {
+               assert.strictEqual( new WikiGrokAbTest( false ).isEnabled, 
false );
+               assert.strictEqual( new WikiGrokAbTest( true ).isEnabled, true 
);
        } );
 
        QUnit.test( 'getVersion()', 62, function ( assert ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ec0190a34c1ae70e6becee904abdebde80ee038
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: wmf/1.25wmf10
Gerrit-Owner: Kaldari <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>

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

Reply via email to