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

Change subject: Respect beta feature flag for logged in users
......................................................................


Respect beta feature flag for logged in users

Both in active and inactive state (not just active like before).

Bug: T146017
Change-Id: Ieb4cd39c2870fb701cabd0f1d01c0ab42b6ebe78
---
M resources/ext.popups.experiment.js
M tests/qunit/ext.popups.experiment.test.js
2 files changed, 17 insertions(+), 10 deletions(-)

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



diff --git a/resources/ext.popups.experiment.js 
b/resources/ext.popups.experiment.js
index 809fb02..990fa17 100644
--- a/resources/ext.popups.experiment.js
+++ b/resources/ext.popups.experiment.js
@@ -73,18 +73,19 @@
                        return false;
                }
 
-               // Users with the beta feature enabled are already in the 
experimental condition.
-               if ( mw.config.get( 'wgPopupsExperimentIsBetaFeatureEnabled', 
false ) ) {
-                       return true;
-               }
+               if ( mw.user.isAnon() ) {
+                       if ( !config ) {
+                               return false;
+                       }
 
-               if ( !config ) {
-                       return false;
+                       // FIXME: mw.experiments should expose the 
CONTROL_BUCKET constant, e.g.
+                       // `mw.experiments.CONTROL_BUCKET`.
+                       return mw.experiments.getBucket( config, getToken() ) 
!== 'control';
+               } else {
+                       // Logged in users are in condition depending on the 
beta feature flag
+                       // instead of bucketing
+                       return mw.config.get( 
'wgPopupsExperimentIsBetaFeatureEnabled', false );
                }
-
-               // FIXME: mw.experiments should expose the CONTROL_BUCKET 
constant, e.g.
-               // `mw.experiments.CONTROL_BUCKET`.
-               return mw.experiments.getBucket( config, getToken() ) !== 
'control';
        };
 
 }( mediaWiki ) );
diff --git a/tests/qunit/ext.popups.experiment.test.js 
b/tests/qunit/ext.popups.experiment.test.js
index 225cde7..2e52b81 100644
--- a/tests/qunit/ext.popups.experiment.test.js
+++ b/tests/qunit/ext.popups.experiment.test.js
@@ -13,6 +13,8 @@
                        wgPopupsExperimentIsBetaFeatureEnabled: null
                },
                setup: function () {
+                       // As anon user by default
+                       this.sandbox.stub( mw.user, 'isAnon', function () { 
return true; } );
                        mw.storage.remove( 'mwe-popups-enabled' );
                },
                teardown: function () {
@@ -21,6 +23,10 @@
        } ) );
 
        QUnit.test( '#isUserInCondition: user has beta feature enabled', 1, 
function ( assert ) {
+               // Be logged in for the beta feature test
+               mw.user.isAnon.restore();
+               this.sandbox.stub( mw.user, 'isAnon', function () { return 
false; } );
+
                mw.config.set( 'wgPopupsExperimentConfig', null );
                mw.config.set( 'wgPopupsExperimentIsBetaFeatureEnabled', true );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ieb4cd39c2870fb701cabd0f1d01c0ab42b6ebe78
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Phuedx <g...@samsmith.io>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to