From 4e3282e5ff054aa8dbda5e80155229a5ed134e89 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Thu, 26 Apr 2018 13:43:05 -0700 Subject: [PATCH] Remove BetaFeature code Popups is out of beta feature and this code is no longer needed. Removing code is the happiest activity a developer can do. Other changes: * Remove redundant type field on extension.json (If not set, the extension will default to the "other" section.) * Repurpose `name` with `namemsg` and make use of existing i18n messages Bug: T193053 Change-Id: Iea832cd1f37b0e7df6ff95efd66e4a1ff2a9004e --- README.md | 2 +- extension.json | 9 +- images/popups-rtl.svg | 36 -------- includes/PopupsContext.php | 29 +----- includes/PopupsHooks.php | 34 +------ images/popups-ltr.svg => popups.svg | 0 resources/dist/index.js | Bin 36833 -> 36718 bytes resources/dist/index.js.json | Bin 179911 -> 179172 bytes src/index.js | 2 +- src/isEnabled.js | 9 -- src/previewBehavior.js | 10 +-- tests/node-qunit/isEnabled.test.js | 22 ----- tests/node-qunit/previewBehavior.test.js | 29 +++--- tests/phpunit/PopupsContextTest.php | 109 +++-------------------- tests/phpunit/PopupsHooksTest.php | 50 ++--------- 15 files changed, 45 insertions(+), 296 deletions(-) delete mode 100644 images/popups-rtl.svg rename images/popups-ltr.svg => popups.svg (100%) diff --git a/README.md b/README.md index d6da39d74..caa4daad0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Popups](images/popups-ltr.svg) +![Popups](images/popups.svg) # mediawiki/extensions/Popups diff --git a/extension.json b/extension.json index cf8b773a4..5a6af4124 100644 --- a/extension.json +++ b/extension.json @@ -1,5 +1,6 @@ { "name": "Popups", + "namemsg": "popups-message", "author": [ "Prateek Saxena", "Yair Rand" @@ -7,7 +8,6 @@ "url": "https://www.mediawiki.org/wiki/Extension:Popups", "descriptionmsg": "popups-desc", "license-name": "GPL-2.0-or-later", - "type": "betafeatures", "requires": { "MediaWiki": ">= 1.30.0" }, @@ -25,9 +25,6 @@ "popups": "GlobalVarConfig::newInstance" }, "Hooks": { - "GetBetaFeaturePreferences": [ - "Popups\\PopupsHooks::onGetBetaPreferences" - ], "BeforePageDisplay": [ "Popups\\PopupsHooks::onBeforePageDisplay" ], @@ -59,9 +56,7 @@ "config": { "@PopupsVirtualPageViews": "@var bool: Whether the extension should log virtual pageviews.", "PopupsVirtualPageViews": false, - "@PopupsBetaFeature": "@var bool: Whether the extension should be enabled as an opt-in beta feature. If true, the BetaFeatures extension must be installed. False by default.", - "PopupsBetaFeature": false, - "@PopupsHideOptInOnPreferencesPage": "@var bool: Whether the option to enable/disable Page Previews should be hidden on Preferences page. Please note if PopupsBetaFeature is set to true this option will be always hidden. False by default", + "@PopupsHideOptInOnPreferencesPage": "@var bool: Whether the option to enable/disable Page Previews should be hidden on Preferences page. False by default", "PopupsHideOptInOnPreferencesPage": false, "@PopupsOptInDefaultState": "@var string:['1'|'0'] Default Page Previews visibility. Has to be a string as a compatibility with beta feature settings", "PopupsOptInDefaultState": "0", diff --git a/images/popups-rtl.svg b/images/popups-rtl.svg deleted file mode 100644 index cc83507f1..000000000 --- a/images/popups-rtl.svg +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/includes/PopupsContext.php b/includes/PopupsContext.php index 7e01b5ebb..a113695a5 100644 --- a/includes/PopupsContext.php +++ b/includes/PopupsContext.php @@ -45,30 +45,22 @@ class PopupsContext { const LOGGER_CHANNEL = 'popups'; /** * User preference value for enabled Page Previews - * Identical to \HTMLFeatureField::OPTION_ENABLED in BetaFeatures * * @var string */ const PREVIEWS_ENABLED = '1'; /** * User preference value for disabled Page Previews - * Identical to \HTMLFeatureField::OPTION_DISABLED in BetaFeatures * * @var string */ const PREVIEWS_DISABLED = '0'; /** - * User preference to enable/disable Page Previews - * Currently for BETA and regular opt in we use same preference name + * User preference key to enable/disable Page Previews * * @var string */ const PREVIEWS_OPTIN_PREFERENCE_NAME = 'popups'; - /** - * User preference to enable/disable Page Preivews as a beta feature - * @var string - */ - const PREVIEWS_BETA_PREFERENCE_NAME = 'popups'; /** * @var \Config */ @@ -102,14 +94,6 @@ class PopupsContext { public function conflictsWithNavPopupsGadget( \User $user ) { return $this->gadgetsIntegration->conflictsWithNavPopupsGadget( $user ); } - /** - * Is Beta Feature mode enabled - * - * @return bool - */ - public function isBetaFeatureEnabled() { - return $this->config->get( 'PopupsBetaFeature' ) === true; - } /** * Get default Page previews state @@ -127,8 +111,7 @@ class PopupsContext { * @return bool */ public function showPreviewsOptInOnPreferencesPage() { - return !$this->isBetaFeatureEnabled() - && $this->config->get( 'PopupsHideOptInOnPreferencesPage' ) === false; + return $this->config->get( 'PopupsHideOptInOnPreferencesPage' ) === false; } /** @@ -136,10 +119,6 @@ class PopupsContext { * @return bool */ public function shouldSendModuleToUser( \User $user ) { - if ( $this->isBetaFeatureEnabled() ) { - return $user->isAnon() ? false : - \BetaFeatures::isFeatureEnabled( $user, self::PREVIEWS_BETA_PREFERENCE_NAME ); - } return $user->isAnon() ? true : $user->getOption( self::PREVIEWS_OPTIN_PREFERENCE_NAME ) === self::PREVIEWS_ENABLED; } @@ -155,10 +134,6 @@ class PopupsContext { && $this->extensionRegistry->isLoaded( 'PageImages' ); } - if ( $this->isBetaFeatureEnabled() ) { - $areMet = $areMet && $this->extensionRegistry->isLoaded( 'BetaFeatures' ); - } - return $areMet; } diff --git a/includes/PopupsHooks.php b/includes/PopupsHooks.php index c4c56ad37..5178d2a70 100644 --- a/includes/PopupsHooks.php +++ b/includes/PopupsHooks.php @@ -33,33 +33,6 @@ use Skin; class PopupsHooks { const PREVIEWS_PREFERENCES_SECTION = 'rendering/reading'; - /** - * Hook executed on retrieving User beta preferences - * @param User $user User whose beta preferences are retrieved - * @param array &$prefs An associative array of all beta preferences - */ - static function onGetBetaPreferences( User $user, array &$prefs ) { - global $wgExtensionAssetsPath; - /** @var PopupsContext $context */ - $context = MediaWikiServices::getInstance()->getService( 'Popups.Context' ); - if ( $context->isBetaFeatureEnabled() !== true ) { - return; - } - $prefs[PopupsContext::PREVIEWS_BETA_PREFERENCE_NAME] = [ - 'label-message' => 'popups-message', - 'desc-message' => 'popups-desc', - 'screenshot' => [ - 'ltr' => "$wgExtensionAssetsPath/Popups/images/popups-ltr.svg", - 'rtl' => "$wgExtensionAssetsPath/Popups/images/popups-rtl.svg", - ], - 'info-link' => 'https://www.mediawiki.org/wiki/Special:MyLanguage/Beta_Features/Hovercards', - 'discussion-link' => 'https://www.mediawiki.org/wiki/Talk:Beta_Features/Hovercards', - 'requirements' => [ - 'javascript' => true, - ], - ]; - } - /** * Add Page Previews options to user Preferences page * @@ -116,13 +89,13 @@ class PopupsHooks { if ( !$context->areDependenciesMet() ) { $logger = $context->getLogger(); - $logger->error( 'Popups requires the PageImages and TextExtracts extensions. ' - . 'If Beta mode is on it requires also BetaFeatures extension' ); + $logger->error( 'Popups requires the PageImages extensions. + TextExtracts extension is required when using mwApiPlain gateway.' ); return; } $user = $out->getUser(); - if ( !$context->isBetaFeatureEnabled() || $context->shouldSendModuleToUser( $user ) ) { + if ( $context->shouldSendModuleToUser( $user ) ) { $out->addModules( [ 'ext.popups' ] ); } } @@ -132,7 +105,6 @@ class PopupsHooks { */ public static function onResourceLoaderGetConfigVars( array &$vars ) { $conf = MediaWikiServices::getInstance()->getService( 'Popups.Config' ); - $vars['wgPopupsBetaFeature'] = $conf->get( 'PopupsBetaFeature' ); $vars['wgPopupsVirtualPageViews'] = $conf->get( 'PopupsVirtualPageViews' ); $vars['wgPopupsGateway'] = $conf->get( 'PopupsGateway' ); $vars['wgPopupsEventLogging'] = $conf->get( 'PopupsEventLogging' ); diff --git a/images/popups-ltr.svg b/popups.svg similarity index 100% rename from images/popups-ltr.svg rename to popups.svg diff --git a/resources/dist/index.js b/resources/dist/index.js index 407d3673e6620b629a94529dc7804e38ea832a29..cbffa24e8f1e30856740d9d9e1f5c13bf719beab 100644 GIT binary patch delta 544 zcmYk2!Al!K6vmk)Cu{MLqLkFK5v8+b+%EJWtgaF&>7~V}SrmFG+vIf}vd-x2m=$bl zXenasZSF0-3kv%`c+!8sTfuX{i#^&|lc1N!_kQ2|9`ok!Z=?ImIK4L2crmYX#i#1p z%%@IqV)${%+k`p|)@Xy0iuySH3{}!E)87nKQn#y@{H%IVB}V(G+5_*y5nX+FIP|BdST?$;ki8Pv$kXnM5&2xYqMJyFMP(wAws zy>1{sef!TM17R|+$!Xnm2=x|i#`)GP*fcIN&akyW)$>CWOFQ1+ z$tp-mSr}uh?AWyZ4|SxagWtu-`^C~LgQ zbgP9`wS$*^3?u~mGv^Y-JMCg=S)@<1>ATDDJ?ou>#XX5-Amb*Mgl9}$bP8kr{NP0G Q(L3+9Q_w$OI6BMy2c3Mu`Tzg` delta 639 zcmaJ;&ui2`7$sp(wd!F@MQR}lwoY^!10D)lQ`uVLMd@lA{Be=t*R&>2*8ELqkmxRH5nPoI7tU$b{OQ6AU8~7Im*=#qoO3TI=$5-TsRi=;)ldti z>#wS_=hxNw!@r}2`QlP$E5+ydic&l#<@{&-Yg+M#&tB;v$kU6{`J0^+T2c4>Dfy{~ zM`b?j-P5%ozwy#5876gN5Xj2n8f$O0(`67*0Fl_@VA=EYNIu`asM-0)-3d+pJ~gof z|Dj{ahNIwpzX5?_TH<(c$`(g04^cV9+;q?Fj diff --git a/resources/dist/index.js.json b/resources/dist/index.js.json index d2a0170936719e5af3aa4dfee0f8a05bb45272c6..864335b73b64b88f2c71db22c9c51a71f3e57b77 100644 GIT binary patch delta 536 zcmY+B&ubGw6vx@9WhqK2ROv|t5u_b48q9al8iWD8I-4@jXORC=TSk{8@<16yJwP$kjdJl4ux&vn_wRpHvbYm zP?30m1FCT~zIEFo%*Rg2LxO;Ps-YMQcBUZ2p)%MJ;|;4e-i==>YPu{L?DLb|zX}QPv&TN(6onKbdHL(R$yZm&vavp2`kLfj`1}xw( zzqY0yQW=UD$cXV^;8Ws?zsQO*6Y(O^u@ZV+dape`o^KtGk~t+adY)50U3q%6ACQ}S zjox9WeKcA=Q&vWAA1afJ4S99*igps^l{m^Lp6$ljcZu&;%Xb(LUWXpDLh0-4KC*kiQLn`Z{BkzFw*dE9OiAfzx*iPuh zB#2>b5wwGIcj-cis`0!8t9%u0h=b=Lh<$+z23Vo<{6%|C7R#hISrq)nisP(smpSw9u27e5{jzs6zC50aNr8719`Hq0l zPm=zRXX_IQiVFFIO^Wr4!bo_~jRZMD~9&D-f4vFO$Y$5#ooF%aPN`Wu^C7^wQSpH{UB4lbP{c@PWrznEugw zJ#))(JMOr_N7E=wEdxQTB>Mkd@VToNqHmq { testCase[ 3 ] ); } - - // --- - - config.set( 'wgPopupsBetaFeature', true ); - - assert.notOk( - isEnabled( user, userSettings, config, BUCKETS.on ), - 'When Page Previews is enabled as a beta feature, then it\'s not' + - ' enabled for logged out users when they are in the on group.' - ); - - assert.notOk( - isEnabled( user, userSettings, config, BUCKETS.control ), - 'When Page Previews is enabled as a beta feature, then it\'s not' + - ' enabled for logged out users when they are not in the control group.' - ); - - assert.notOk( - isEnabled( user, userSettings, config, BUCKETS.off ), - 'When Page Previews is enabled as a beta feature, then it\'s not' + - ' enabled for logged out users when they are in the off group.' - ); } ); QUnit.test( 'it should handle logged in users', ( assert ) => { diff --git a/tests/node-qunit/previewBehavior.test.js b/tests/node-qunit/previewBehavior.test.js index 1bb4590e4..1d8501533 100644 --- a/tests/node-qunit/previewBehavior.test.js +++ b/tests/node-qunit/previewBehavior.test.js @@ -15,31 +15,22 @@ QUnit.module( 'ext.popups.preview.settingsBehavior', { } } ); -QUnit.test( 'it should set the settingsUrl on wgPopupsBetaFeature', function ( assert ) { +QUnit.test( 'it should set the settingsUrl', function ( assert ) { const user = createStubUser( /* isAnon = */ false ), actions = {}; - const cases = [ - [ true, 'Special:Preferences#mw-prefsection-betafeatures' ], - [ false, 'Special:Preferences#mw-prefsection-rendering' ] - ]; + const behavior = createPreviewBehavior( user, actions ); - cases.forEach( ( testCase ) => { - this.config.set( 'wgPopupsBetaFeature', testCase[ 0 ] ); - - const behavior = createPreviewBehavior( this.config, user, actions ); - - assert.deepEqual( - behavior.settingsUrl, - `url/${ testCase[ 1 ] }` - ); - } ); + assert.deepEqual( + behavior.settingsUrl, + 'url/Special:Preferences#mw-prefsection-rendering' + ); } ); QUnit.test( 'it shouldn\'t set the settingsUrl if the user is logged out', function ( assert ) { const user = createStubUser( /* isAnon = */ true ), actions = {}, - behavior = createPreviewBehavior( this.config, user, actions ); + behavior = createPreviewBehavior( user, actions ); assert.strictEqual( behavior.settingsUrl, undefined ); } ); @@ -47,7 +38,7 @@ QUnit.test( 'it shouldn\'t set the settingsUrl if the user is logged out', funct QUnit.test( 'it shouldn\'t set a showSettings handler if the user is logged in', function ( assert ) { const user = createStubUser( /* isAnon = */ false ), actions = {}, - behavior = createPreviewBehavior( this.config, user, actions ); + behavior = createPreviewBehavior( user, actions ); assert.strictEqual( behavior.showSettings, $.noop ); } ); @@ -60,7 +51,7 @@ QUnit.test( 'it should set a showSettings handler if the user is logged out', fu actions = { showSettings: this.sandbox.spy() }, - behavior = createPreviewBehavior( this.config, user, actions ); + behavior = createPreviewBehavior( user, actions ); behavior.showSettings( event ); @@ -84,7 +75,7 @@ QUnit.test( 'it should mix in default actions', function ( assert ) { actions.previewShow = () => {}; actions.linkClick = () => {}; - const behavior = createPreviewBehavior( this.config, user, actions ); + const behavior = createPreviewBehavior( user, actions ); assert.strictEqual( behavior.previewDwell, actions.previewDwell ); assert.strictEqual( behavior.previewAbandon, actions.abandon ); diff --git a/tests/phpunit/PopupsContextTest.php b/tests/phpunit/PopupsContextTest.php index 59be0dea7..f9f554da3 100644 --- a/tests/phpunit/PopupsContextTest.php +++ b/tests/phpunit/PopupsContextTest.php @@ -76,38 +76,27 @@ class PopupsContextTest extends MediaWikiTestCase { public function provideConfigForShowPreviewsInOptIn() { return [ [ - "options" => [ - "wgPopupsBetaFeature" => false, + [ "wgPopupsHideOptInOnPreferencesPage" => false ], - "expected" => true - ], [ - "options" => [ - "wgPopupsBetaFeature" => true, - "wgPopupsHideOptInOnPreferencesPage" => false - ], - "expected" => false - ], [ - "options" => [ - "wgPopupsBetaFeature" => false, + true + ], + [ + [ "wgPopupsHideOptInOnPreferencesPage" => true ], - "expected" => false + false ] ]; } /** * @covers ::shouldSendModuleToUser - * @covers ::isBetaFeatureEnabled * @dataProvider provideTestDataForShouldSendModuleToUser * @param bool $optIn * @param bool $expected */ public function testShouldSendModuleToUser( $optIn, $expected ) { - $this->setMwGlobals( [ - "wgPopupsBetaFeature" => false - ] ); $context = $this->getContext(); $user = $this->getMutableTestUser()->getUser(); $user->setOption( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME, $optIn ); @@ -130,41 +119,16 @@ class PopupsContextTest extends MediaWikiTestCase { ]; } - /** - * @covers ::shouldSendModuleToUser - * @covers ::isBetaFeatureEnabled - * @dataProvider provideTestDataForShouldSendModuleToUserWhenBetaEnabled - * @param bool $optIn - * @param bool $expected - */ - public function testShouldSendModuleToUserWhenBetaEnabled( $optIn, $expected ) { - if ( !class_exists( 'BetaFeatures' ) ) { - $this->markTestSkipped( 'Skipped as BetaFeatures is not available' ); - } - $this->setMwGlobals( [ - "wgPopupsBetaFeature" => true - ] ); - - $context = $this->getContext(); - $user = $this->getMutableTestUser()->getUser(); - $user->setOption( PopupsContext::PREVIEWS_BETA_PREFERENCE_NAME, $optIn ); - $this->assertEquals( $context->shouldSendModuleToUser( $user ), $expected ); - } - /** * Check tst Page Previews are disabled for anonymous user * @covers ::shouldSendModuleToUser - * @covers ::isBetaFeatureEnabled * @dataProvider providerAnonUserHasDisabledPagePreviews */ - public function testAnonUserHasDisabledPagePreviews( $betaFeatureEnabled, $expected ) { + public function testAnonUserHasDisabledPagePreviews( $expected ) { $user = $this->getMutableTestUser()->getUser(); $user->setId( self::ANONYMOUS_USER ); $user->setOption( PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME, PopupsContext::PREVIEWS_DISABLED ); - $this->setMwGlobals( [ - "wgPopupsBetaFeature" => $betaFeatureEnabled, - ] ); $context = $this->getContext(); $this->assertEquals( $expected, $context->shouldSendModuleToUser( $user ) ); @@ -172,43 +136,24 @@ class PopupsContextTest extends MediaWikiTestCase { public static function providerAnonUserHasDisabledPagePreviews() { return [ - // If beta feature is enabled we can assume it's opt in only. - [ true, false ], - // If beta feature is disabled we can assume it's rolled out to everyone. - [ false, true ], - ]; - } - /** - * @return array/ - */ - public function provideTestDataForShouldSendModuleToUserWhenBetaEnabled() { - return [ - [ - "optin" => PopupsContext::PREVIEWS_ENABLED, - 'expected' => true - ], [ - "optin" => PopupsContext::PREVIEWS_DISABLED, - 'expected' => false - ] + // Anons see this by default + [ true ], ]; } /** * @covers ::areDependenciesMet * @dataProvider provideTestDataForTestAreDependenciesMet - * @param bool $betaOn * @param bool $textExtracts * @param bool $pageImages - * @param bool $betaFeatures * @param bool $expected */ - public function testAreDependenciesMet( $betaOn, $textExtracts, $pageImages, - $betaFeatures, $gateway, $expected ) { + public function testAreDependenciesMet( $textExtracts, $pageImages, + $gateway, $expected ) { $this->setMwGlobals( [ - "wgPopupsBetaFeature" => $betaOn, "wgPopupsGateway" => $gateway, ] ); - $returnValues = [ $textExtracts, $pageImages, $betaFeatures ]; + $returnValues = [ $textExtracts, $pageImages ]; $mock = $this->getMock( ExtensionRegistry::class, [ 'isLoaded' ] ); $mock->expects( $this->any() ) @@ -223,57 +168,31 @@ class PopupsContextTest extends MediaWikiTestCase { */ public function provideTestDataForTestAreDependenciesMet() { return [ - // Beta is off, dependencies are met even BetaFeatures ext is not available + // Dependencies are met [ - "betaOn" => false, "textExtracts" => true, "pageImages" => true, - "betaFeatures" => false, "gateway" => "mwApiPlain", "expected" => true ], // textExtracts dep is missing [ - "betaOn" => false, "textExtracts" => false, "pageImages" => true, - "betaFeatures" => false, "gateway" => "mwApiPlain", "expected" => false ], // PageImages dep is missing [ - "betaOn" => false, "textExtracts" => true, "pageImages" => false, - "betaFeatures" => false, "gateway" => "mwApiPlain", "expected" => false ], - // Beta is on but BetaFeatures dep is missing - [ - "betaOn" => true, - "textExtracts" => true, - "pageImages" => true, - "betaFeatures" => false, - "gateway" => "mwApiPlain", - "expected" => false - ], - // beta is on and all deps are available - [ - "betaOn" => true, - "textExtracts" => true, - "pageImages" => true, - "betaFeatures" => true, - "gateway" => "mwApiPlain", - "expected" => true - ], // when Popups uses gateway!=mwApiPlain we don't require PageImages nor TextExtracts [ - "betaOn" => false, "textExtracts" => false, "pageImages" => false, - "betaFeatures" => false, "gateway" => "restbaseHTML", "expected" => true ], @@ -285,7 +204,7 @@ class PopupsContextTest extends MediaWikiTestCase { * @dataProvider provideTestIsTitleBLacklisted * @param array $blacklist * @param Title $title - $ @param bool $expected + * @param bool $expected */ public function testIsTitleBlacklisted( $blacklist, Title $title, $expected ) { $this->setMwGlobals( [ "wgPopupsPageBlacklist" => $blacklist ] ); diff --git a/tests/phpunit/PopupsHooksTest.php b/tests/phpunit/PopupsHooksTest.php index 5236b8e35..22a46697c 100644 --- a/tests/phpunit/PopupsHooksTest.php +++ b/tests/phpunit/PopupsHooksTest.php @@ -33,30 +33,6 @@ class PopupsHooksTest extends MediaWikiTestCase { parent::tearDown(); } - /** - * @covers ::onGetBetaPreferences - */ - public function testOnGetBetaPreferencesBetaDisabled() { - $prefs = [ 'someNotEmptyValue' => 'notEmpty' ]; - $this->setMwGlobals( [ 'wgPopupsBetaFeature' => false ] ); - - PopupsHooks::onGetBetaPreferences( $this->getTestUser()->getUser(), $prefs ); - $this->assertCount( 1, $prefs ); - $this->assertEquals( 'notEmpty', $prefs[ 'someNotEmptyValue'] ); - } - - /** - * @covers ::onGetBetaPreferences - */ - public function testOnGetBetaPreferencesBetaEnabled() { - $prefs = [ 'someNotEmptyValue' => 'notEmpty' ]; - $this->setMwGlobals( [ 'wgPopupsBetaFeature' => true ] ); - - PopupsHooks::onGetBetaPreferences( $this->getTestUser()->getUser(), $prefs ); - $this->assertCount( 2, $prefs ); - $this->assertArrayHasKey( PopupsContext::PREVIEWS_BETA_PREFERENCE_NAME, $prefs ); - } - /** * @covers ::onGetPreferences */ @@ -176,7 +152,6 @@ class PopupsHooksTest extends MediaWikiTestCase { $config = [ 'wgPopupsAnonsExperimentalGroupSize' => 0.1, 'wgPopupsEventLogging' => false, - 'wgPopupsBetaFeature' => true, 'wgPopupsRestGatewayEndpoint' => '/api', 'wgPopupsVirtualPageViews' => true, 'wgPopupsGateway' => 'mwApiPlain', @@ -184,7 +159,7 @@ class PopupsHooksTest extends MediaWikiTestCase { ]; $this->setMwGlobals( $config ); PopupsHooks::onResourceLoaderGetConfigVars( $vars ); - $this->assertCount( 8, $vars ); + $this->assertCount( 7, $vars ); foreach ( $config as $key => $value ) { $this->assertEquals( @@ -251,15 +226,12 @@ class PopupsHooksTest extends MediaWikiTestCase { public function providerOnBeforePageDisplay() { return [ - [ false, true, false, false ], - [ true, true, true, false ], - // if the user doesnt have the feature but the beta feature is disabled - // we can assume the user has it (as its rolled out to everyone) - [ false, false, true, false ], - // If the user has enabled it and the beta feature is disabled - // we can assume the code will be loaded. - [ true, false, true, false ], - [ false, false, false, true ] + [ false, false, false ], + [ true, true, false ], + // Code not sent if title blacklisted + [ true, false, true ], + // Code not sent if title blacklisted + [ false, false, true ] ]; } @@ -268,7 +240,7 @@ class PopupsHooksTest extends MediaWikiTestCase { * @dataProvider providerOnBeforePageDisplay */ public function testOnBeforePageDisplay( $shouldSendModuleToUser, - $isBetaFeatureEnabled, $isCodeLoaded, $isTitleBlacklisted ) { + $isCodeLoaded, $isTitleBlacklisted ) { $skinMock = $this->getMock( Skin::class ); $outPageMock = $this->getMock( @@ -284,7 +256,7 @@ class PopupsHooksTest extends MediaWikiTestCase { ->with( [ 'ext.popups' ] ); $contextMock = $this->getMockBuilder( PopupsContext::class ) - ->setMethods( [ 'areDependenciesMet', 'isBetaFeatureEnabled', + ->setMethods( [ 'areDependenciesMet', 'shouldSendModuleToUser', 'isTitleBlacklisted' ] ) ->disableOriginalConstructor() ->getMock(); @@ -295,10 +267,6 @@ class PopupsHooksTest extends MediaWikiTestCase { ->will( $this->returnValue( true ) ); } - $contextMock->expects( $this->any() ) - ->method( 'isBetaFeatureEnabled' ) - ->will( $this->returnValue( $isBetaFeatureEnabled ) ); - $contextMock->expects( $this->any() ) ->method( 'shouldSendModuleToUser' ) ->will( $this->returnValue( $shouldSendModuleToUser ) );