Remove all BetaFeature code from ReferencePreviews

The extension is out of beta and will be enabled by default now.
Leaving some hints if we decide to also remove the feature flag.

Bug: T282999
Bug: T351708
Change-Id: I1556b2f3592294d094770ede2c276eddeef8bbe9
This commit is contained in:
WMDE-Fisch 2023-11-06 09:48:29 +01:00 committed by thiemowmde
parent 7596165a5d
commit b218a77ca4
21 changed files with 61 additions and 265 deletions

View file

@ -5,7 +5,6 @@ $cfg['directory_list'] = array_merge(
$cfg['directory_list'],
[
'../../extensions/Gadgets',
'../../extensions/BetaFeatures',
]
);
@ -13,7 +12,6 @@ $cfg['exclude_analysis_directory_list'] = array_merge(
$cfg['exclude_analysis_directory_list'],
[
'../../extensions/Gadgets',
'../../extensions/BetaFeatures',
]
);

View file

@ -25,7 +25,6 @@
"UserGetDefaultOptions": "PopupsHooks",
"MakeGlobalVariablesScript": "PopupsHooks",
"LocalUserCreated": "PopupsHooks",
"GetBetaFeaturePreferences": "PopupsHooks",
"ResourceLoaderRegisterModules": "PopupsHooks"
},
"HookHandlers": {
@ -86,10 +85,6 @@
"description": "Feature flag to enable or disable the separate popup type for references created via the Cite extension's <ref> tag.",
"value": true
},
"PopupsReferencePreviewsBetaFeature": {
"description": "Make Reference Previews a Beta feature.",
"value": true
},
"PopupsStatsvSamplingRate": {
"description": "Sampling rate for logging performance data to statsv.",
"value": 0

View file

@ -33,7 +33,5 @@
"popups-refpreview-note": "Note",
"popups-refpreview-web": "Web reference",
"popups-refpreview-collapsible-placeholder": "This reference includes a figure which does not fit in the preview.",
"popups-refpreview-user-preference-label": "Enable reference previews (get quick previews of a reference while reading a page)",
"popups-refpreview-beta-feature-message": "Reference Previews",
"popups-refpreview-beta-feature-description": "Show a preview of a reference by hovering over its footnote marker.\n\nPlease note: If you're using the [//en.wikipedia.org/wiki/Wikipedia:Tools/Navigation_popups Navigation popups] gadget or the [[mw:Special:MyLanguage/Reference Tooltips|Reference Tooltips]] gadget, you won't see reference previews."
"popups-refpreview-user-preference-label": "Enable reference previews (get quick previews of a reference while reading a page)"
}

View file

@ -49,7 +49,5 @@
"popups-refpreview-note": "Heading for a popup previewing a footnote.\n{{Identical|Note}}",
"popups-refpreview-web": "Heading for a popup previewing a citation from a website.\n{{Identical|Website}}",
"popups-refpreview-collapsible-placeholder": "Placeholder text for collapsible tables, templates, or other large elements inside of a reference.",
"popups-refpreview-user-preference-label": "Label for the user option to enable or disable reference preview popups",
"popups-refpreview-beta-feature-message": "Label for the Reference Previews Beta feature.",
"popups-refpreview-beta-feature-description": "Description for the Reference Previews Beta feature, describing the feature that will be enabled."
"popups-refpreview-user-preference-label": "Label for the user option to enable or disable reference preview popups"
}

View file

@ -22,7 +22,6 @@ namespace Popups;
use Config;
use ExtensionRegistry;
use MediaWiki\Extension\BetaFeatures\BetaFeatures;
use MediaWiki\MediaWikiServices;
use MediaWiki\SpecialPage\SpecialPageFactory;
use MediaWiki\Title\Title;
@ -63,18 +62,12 @@ class PopupsContext {
*/
public const REFERENCE_PREVIEWS_PREFERENCE_NAME = 'popups-reference-previews';
/**
* User preference key to enable/disable Reference Previews
*/
public const REFERENCE_PREVIEWS_BETA_PREFERENCE_NAME = 'popupsreferencepreviews';
/**
* Flags passed on to JS representing preferences
*/
private const NAV_POPUPS_ENABLED = 1;
private const REF_TOOLTIPS_ENABLED = 2;
private const REFERENCE_PREVIEWS_ENABLED = 4;
private const REFERENCE_PREVIEWS_BETA = 8;
/**
* @var \Config
@ -163,28 +156,11 @@ class PopupsContext {
return false;
}
// TODO: Remove when not in Beta any more
if ( $this->isReferencePreviewsInBeta() ) {
return BetaFeatures::isFeatureEnabled(
$user,
self::REFERENCE_PREVIEWS_BETA_PREFERENCE_NAME
);
}
return !$user->isNamed() || $this->userOptionsLookup->getBoolOption(
$user, self::REFERENCE_PREVIEWS_PREFERENCE_NAME
);
}
/**
* @return bool whether or not reference previews are a beta feature
*/
public function isReferencePreviewsInBeta() {
// TODO: Remove when not in Beta any more
return $this->config->get( 'PopupsReferencePreviewsBetaFeature' ) &&
\ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' );
}
/**
* @param \User $user User whose preferences are checked
* @return int
@ -192,8 +168,7 @@ class PopupsContext {
public function getConfigBitmaskFromUser( \User $user ) {
return ( $this->conflictsWithNavPopupsGadget( $user ) ? self::NAV_POPUPS_ENABLED : 0 ) |
( $this->conflictsWithRefTooltipsGadget( $user ) ? self::REF_TOOLTIPS_ENABLED : 0 ) |
( $this->isReferencePreviewsEnabled( $user ) ? self::REFERENCE_PREVIEWS_ENABLED : 0 ) |
( $this->isReferencePreviewsInBeta() ? self::REFERENCE_PREVIEWS_BETA : 0 );
( $this->isReferencePreviewsEnabled( $user ) ? self::REFERENCE_PREVIEWS_ENABLED : 0 );
}
/**

View file

@ -93,9 +93,7 @@ class PopupsHooks implements
$readingOptions = self::getPagePreviewPrefToggle( $user, $context );
$config = MediaWikiServices::getInstance()->getService( 'Popups.Config' );
if ( $config->get( 'PopupsReferencePreviews' ) &&
!$config->get( 'PopupsReferencePreviewsBetaFeature' )
) {
if ( $config->get( 'PopupsReferencePreviews' ) ) {
$readingOptions = array_merge(
$readingOptions,
self::getReferencePreviewPrefToggle( $user, $context )
@ -230,9 +228,7 @@ class PopupsHooks implements
*
* Variables added:
* * `wgPopupsReferencePreviews' - The server's notion of whether or not the reference
* previews should be enabled. Depending on the general setting done on the wiki and
* - in cases where the feature is used as BetaFeature - of the user's BetaFeature
* setting.
* previews should be enabled. Depending on the general setting done on the wiki.
* * `wgPopupsConflictsWithNavPopupGadget' - The server's notion of whether or not the
* user has enabled conflicting Navigational Popups Gadget.
* * `wgPopupsConflictsWithRefTooltipsGadget' - The server's notion of whether or not the
@ -258,11 +254,7 @@ class PopupsHooks implements
$default = $config->get( 'PopupsOptInDefaultState' );
$defaultOptions[PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME] = $default;
// As long as in Beta, don't set a default for Reference Previews. Rely on it either being
// null (= disabled), or follow what the "betafeatures-auto-enroll" flag says.
if ( $config->get( 'PopupsReferencePreviews' ) &&
!$config->get( 'PopupsReferencePreviewsBetaFeature' )
) {
if ( $config->get( 'PopupsReferencePreviews' ) ) {
$defaultOptions[PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME] = '1';
}
}
@ -283,11 +275,7 @@ class PopupsHooks implements
$default
);
// As long as in Beta, don't set a default for Reference Previews. Rely on it either being
// null (= disabled), or follow what the "betafeatures-auto-enroll" flag says.
if ( $config->get( 'PopupsReferencePreviews' ) &&
!$config->get( 'PopupsReferencePreviewsBetaFeature' )
) {
if ( $config->get( 'PopupsReferencePreviews' ) ) {
$this->userOptionsManager->setOption(
$user,
PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME,
@ -296,33 +284,6 @@ class PopupsHooks implements
}
}
/**
* Register preferences that enable experimental features.
*
* @param User $user User whose preferences are being modified
* @param array[] &$prefs Array of beta features
*/
public function onGetBetaFeaturePreferences( User $user, array &$prefs ) {
/** @var Config $config */
$config = MediaWikiServices::getInstance()->getService( 'Popups.Config' );
$extensionAssetsPath = $config->get( 'ExtensionAssetsPath' );
if ( $config->get( 'PopupsReferencePreviewsBetaFeature' ) &&
$config->get( 'PopupsReferencePreviews' )
) {
$prefs[PopupsContext::REFERENCE_PREVIEWS_BETA_PREFERENCE_NAME] = [
'label-message' => 'popups-refpreview-beta-feature-message',
'desc-message' => 'popups-refpreview-beta-feature-description',
'screenshot' => [
'ltr' => "$extensionAssetsPath/Popups/resources/ext.popups.images/refpreview-beta-ltr.svg",
'rtl' => "$extensionAssetsPath/Popups/resources/ext.popups.images/refpreview-beta-rtl.svg",
],
'info-link' => 'https://mediawiki.org/wiki/Help:Reference_Previews',
'discussion-link' => 'https://mediawiki.org/wiki/Help_Talk:Reference_Previews',
];
}
}
/**
* ResourceLoaderRegisterModules hook handler.
*

Binary file not shown.

Binary file not shown.

View file

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="2560" height="1571" viewBox="0 0 2560 1571">
<defs>
<path id="a" d="M0 0v1474.025L116.364 1571l116.363-96.975L349.091 1571l116.364-96.975L581.818 1571l116.364-96.975L814.545 1571l116.364-96.975L1047.273 1571l116.363-96.975L1280 1571l116.364-96.975L1512.727 1571l116.364-96.975L1745.455 1571l116.363-96.975L1978.182 1571l116.363-96.975L2210.91 1571l116.364-96.975L2443.636 1571 2560 1474.025V0z"/>
</defs>
<g fill="none" fill-rule="evenodd">
<mask id="b" fill="#fff">
<use xlink:href="#a"/>
</mask>
<g mask="url(#b)">
<path fill="#FFF" d="M0 0h2560v1571H0"/>
<path fill="#EAECF0" d="M106.667 213.346c0-77.58 58.181-135.766 135.757-135.766 77.576 0 135.758 58.185 135.758 135.766 0 77.58-58.182 135.765-135.758 135.765-77.576 0-135.757-58.185-135.757-135.765zm261.818 223.043V387.9H126.06v48.488h242.424zm0 1144.309V562.457H126.06v1027.938h242.424v-9.697zM2259.394 48.488h252.121v58.185h-252.121V48.488zm-232.727 0H2240v58.185h-213.333V48.488zm-232.728 0h213.334v58.185h-213.334V48.488zm-223.03 0h126.06v58.185h-126.06V48.488zm145.455 0h58.181v58.185h-58.181V48.488zm-223.03 0h58.181v58.185h-58.182V48.488z"/>
<g fill="#EAECF0">
<path d="M2501.818 155.161v38.79h-892.121v-38.79h892.121zm9.697-9.698H1600v58.185h911.515v-58.185z"/>
<path d="M1629.09 164.858h19.395v19.395h-19.395z"/>
</g>
<path fill="#EAECF0" d="M0 0v1571h2560V0H0zm9.697 9.698h2540.606v1459.769l-106.667 88.926-116.363-96.975-116.364 96.975-116.364-96.975-116.363 96.975-116.364-96.975-116.363 96.975-116.364-96.975-116.364 96.975-116.363-96.975L1280 1558.393l-116.364-96.975-116.363 96.975-116.364-96.975-116.364 96.975-116.363-96.975-116.364 96.975-116.363-96.975-116.364 96.975-116.364-96.975-116.363 96.975-106.667-87.278V9.698z"/>
</g>
<path fill="#EAECF0" d="M2067 281h387v1290h-387V281zm-1602 0h1516v1344H465V281z" mask="url(#b)"/>
<path fill="#C8CCD1" d="M614 416h1105v78.774H614V416zm0 377.613h1105v78.774H614v-78.774zm0-188.806h1240v78.773H614v-78.773zm0 566.42h1240V1250H614v-78.774zm0-188.807h553v78.773H614V982.42zm651 0h504v78.773h-504V982.42z" mask="url(#b)"/>
<path fill="#36C" d="M1190 982h50v47h-50z" mask="url(#b)"/>
<g mask="url(#b)">
<g transform="translate(1173.13 580.297)">
<path fill="#FFF" d="M0 0h684v368.861H0z"/>
<ellipse cx="97.477" cy="79.511" fill="#36C" rx="37.5"/>
<path fill="#36C" d="M60 161h441.92v25.007H60zm0 48h560v25.007H60zm0 81h245.164v25.007H60z"/>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="2560" height="1571" viewBox="0 0 2560 1571">
<defs>
<path id="a" d="M0 0v1474.025L116.364 1571l116.363-96.975L349.091 1571l116.364-96.975L581.818 1571l116.364-96.975L814.545 1571l116.364-96.975L1047.273 1571l116.363-96.975L1280 1571l116.364-96.975L1512.727 1571l116.364-96.975L1745.455 1571l116.363-96.975L1978.182 1571l116.363-96.975L2210.91 1571l116.364-96.975L2443.636 1571 2560 1474.025V0z"/>
</defs>
<g fill="none" fill-rule="evenodd">
<mask id="b" fill="#fff">
<use xlink:href="#a"/>
</mask>
<g mask="url(#b)">
<path fill="#FFF" d="M2560 0H0v1571h2560"/>
<path fill="#EAECF0" d="M2453.333 213.346c0-77.58-58.181-135.766-135.757-135.766-77.576 0-135.758 58.185-135.758 135.766 0 77.58 58.182 135.765 135.758 135.765 77.576 0 135.757-58.185 135.757-135.765zm-261.818 223.043V387.9h242.425v48.488h-242.424zm0 1144.309V562.457h242.425v1027.938h-242.424v-9.697zM300.606 48.488H48.485v58.185h252.121V48.488zm232.727 0H320v58.185h213.333V48.488zm232.728 0H552.727v58.185h213.334V48.488zm223.03 0h-126.06v58.185h126.06V48.488zm-145.455 0h-58.181v58.185h58.181V48.488zm223.03 0h-58.181v58.185h58.182V48.488z"/>
<g fill="#EAECF0">
<path d="M58.182 155.161v38.79h892.121v-38.79H58.182zm-9.697-9.698H960v58.185H48.485v-58.185z"/>
<path d="M930.91 164.858h-19.395v19.395h19.395z"/>
</g>
<path fill="#EAECF0" d="M493 281H106v1344h387V281zm1602 0H579v1344h1516V281z"/>
<path fill="#C8CCD1" d="M1946 416H841v78.774h1105V416zm0 377.613H841v78.774h1105v-78.774zm0-188.806H706v78.773h1240v-78.773zm0 566.42H706V1250h1240v-78.774zm0-188.807h-553v78.773h553V982.42zm-651 0H791v78.773h504V982.42z"/>
<path fill="#36C" d="M1370 982h-50v47h50z"/>
<g transform="matrix(-1 0 0 1 1386.87 580.297)">
<path fill="#FFF" d="M0 0h684v368.861H0z"/>
<ellipse cx="97.477" cy="79.511" fill="#36C" rx="37.5"/>
<path fill="#36C" d="M60 161h441.92v25.007H60zm0 48h560v25.007H60zm0 81h245.164v25.007H60z"/>
</g>
<path fill="#EAECF0" d="M2560 0v1571H0V0h2560zm-9.697 9.698H9.697v1459.769l106.667 88.926 116.363-96.975 116.364 96.975 116.364-96.975 116.363 96.975 116.364-96.975 116.363 96.975 116.364-96.975 116.364 96.975 116.363-96.975L1280 1558.393l116.364-96.975 116.363 96.975 116.364-96.975 116.364 96.975 116.363-96.975 116.364 96.975 116.363-96.975 116.364 96.975 116.364-96.975 116.363 96.975 106.667-87.278V9.698z"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -15,7 +15,7 @@ const canSaveToUserPreferences = require( './canSaveToUserPreferences.js' );
*/
export default function isReferencePreviewsEnabled( user, userSettings, config ) {
// TODO: This and the final `mw.user.options` check are currently redundant. Only this here
// should be removed when the feature flag is not needed any more.
// should be removed when the wgPopupsReferencePreviews feature flag is not needed any more.
if ( !config.get( 'wgPopupsReferencePreviews' ) ) {
return null;
}
@ -35,11 +35,6 @@ export default function isReferencePreviewsEnabled( user, userSettings, config )
return userSettings.isReferencePreviewsEnabled();
}
// TODO: Remove when not in Beta any more
if ( config.get( 'wgPopupsReferencePreviews' ) ) {
return true;
}
// Registered users never can enable popup types at run-time.
return mw.user.options.get( 'popups-reference-previews' ) === '1' ? true : null;
}

View file

@ -7,8 +7,7 @@
*/
const NAV_POPUPS_ENABLED = 1,
REF_TOOLTIPS_ENABLED = 2,
REFERENCE_PREVIEWS_ENABLED = 4,
REFERENCE_PREVIEWS_BETA = 8;
REFERENCE_PREVIEWS_ENABLED = 4;
/**
* Decodes the bitmask that represents preferences to the related config options.
@ -31,9 +30,5 @@ export default function setUserConfigFlags( config ) {
'wgPopupsReferencePreviews',
!!( popupsFlags & REFERENCE_PREVIEWS_ENABLED )
);
config.set(
'wgPopupsReferencePreviewsBetaFeature',
!!( popupsFlags & REFERENCE_PREVIEWS_BETA )
);
/* eslint-enable no-bitwise */
}

View file

@ -25,9 +25,9 @@ export function createSettingsDialog( referencePreviewsAvaliable ) {
}
];
// TODO: Remove when not in Beta any more
if ( !referencePreviewsAvaliable ) {
// Anonymous users can't access reference previews as long as they are in beta
// Anonymous users can't access reference previews when they're disabled
// TODO: Remove when the wgPopupsReferencePreviews feature flag is not needed any more
choices.splice( 1, 1 );
}

View file

@ -167,21 +167,6 @@
}
}
// TODO: Remove when not in Beta any more (T276200)
.mwe-popups-container.footer-empty .mwe-popups-extract {
margin-bottom: @popupPadding;
.mwe-popups-scroll {
max-height: 403px - 2 * @popupPadding + @previewPointerHeight;
}
}
// TODO: Remove when not in Beta any more (T276200)
&.flipped-y .mwe-popups-container.footer-empty .mwe-popups-extract,
&.flipped-x-y .mwe-popups-container.footer-empty .mwe-popups-extract {
margin-bottom: @popupPadding + @previewPointerHeight;
}
/* Triangles/Pointers */
&.mwe-popups-no-image-pointer {
&::before {

View file

@ -103,8 +103,6 @@ export function renderReferencePreview(
Array.prototype.forEach.call( node.querySelectorAll( '.headerSort' ), undoHeaderSort );
} );
// TODO: Remove when not in Beta any more
if ( !mw.config.get( 'wgPopupsReferencePreviewsBetaFeature' ) ) {
// TODO: Do not remove this but move it up into the templateHTML constant!
const settingsButton = document.createElement( 'a' );
settingsButton.classList.add( 'cdx-button', 'cdx-button--fake-button', 'cdx-button--fake-button--enabled', 'cdx-button--weight-quiet', 'cdx-button--icon-only', 'mwe-popups-settings-button' );
@ -115,10 +113,6 @@ export function renderReferencePreview(
settingsButton.append( settingsIcon );
settingsButton.append( settingsButtonLabel );
el.querySelector( '.mwe-popups-settings' ).appendChild( settingsButton );
} else {
// Change the styling when there is no content in the footer (to prevent empty space)
el.querySelector( '.mwe-popups-container' ).classList.add( 'footer-empty' );
}
if ( isTrackingEnabled() ) {
el.querySelector( '.mw-parser-output' ).addEventListener( 'click', ( ev ) => {

View file

@ -5,30 +5,28 @@ QUnit.module( 'ext.popups#setUserConfigFlags' );
QUnit.test( 'config settings are successfully set from bitmask', ( assert ) => {
const config = new Map();
config.set( 'wgPopupsFlags', '15' );
config.set( 'wgPopupsFlags', '7' );
setUserConfigFlags( config );
assert.deepEqual(
[
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
config.get( 'wgPopupsReferencePreviews' ),
config.get( 'wgPopupsReferencePreviewsBetaFeature' )
config.get( 'wgPopupsReferencePreviews' )
],
[ true, true, true, true ]
[ true, true, true ]
);
config.set( 'wgPopupsFlags', '10' );
config.set( 'wgPopupsFlags', '2' );
setUserConfigFlags( config );
assert.deepEqual(
[
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
config.get( 'wgPopupsReferencePreviews' ),
config.get( 'wgPopupsReferencePreviewsBetaFeature' )
config.get( 'wgPopupsReferencePreviews' )
],
[ false, true, false, true ]
[ false, true, false ]
);
config.set( 'wgPopupsFlags', '5' );
@ -38,10 +36,9 @@ QUnit.test( 'config settings are successfully set from bitmask', ( assert ) => {
[
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
config.get( 'wgPopupsReferencePreviews' ),
config.get( 'wgPopupsReferencePreviewsBetaFeature' )
config.get( 'wgPopupsReferencePreviews' )
],
[ true, false, true, false ]
[ true, false, true ]
);
config.set( 'wgPopupsFlags', '0' );
@ -51,9 +48,8 @@ QUnit.test( 'config settings are successfully set from bitmask', ( assert ) => {
[
config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
config.get( 'wgPopupsConflictsWithRefTooltipsGadget' ),
config.get( 'wgPopupsReferencePreviews' ),
config.get( 'wgPopupsReferencePreviewsBetaFeature' )
config.get( 'wgPopupsReferencePreviews' )
],
[ false, false, false, false ]
[ false, false, false ]
);
} );

View file

@ -278,14 +278,12 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
* @param bool $navPops
* @param bool $refTooltips
* @param bool $refEnabled
* @param bool $refInBeta
* @param int $expected
*/
public function testGetConfigBitmaskFromUser(
$navPops,
$refTooltips,
$refEnabled,
$refInBeta,
$expected
) {
$contextMock = $this->createPartialMock(
@ -294,7 +292,6 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
'conflictsWithNavPopupsGadget',
'conflictsWithRefTooltipsGadget',
'isReferencePreviewsEnabled',
'isReferencePreviewsInBeta',
]
);
$contextMock->method( 'conflictsWithNavPopupsGadget' )
@ -303,8 +300,6 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
->willReturn( $refTooltips );
$contextMock->method( 'isReferencePreviewsEnabled' )
->willReturn( $refEnabled );
$contextMock->method( 'isReferencePreviewsInBeta' )
->willReturn( $refInBeta );
$this->assertSame(
$expected,
@ -318,28 +313,24 @@ class PopupsContextTest extends MediaWikiIntegrationTestCase {
true,
true,
true,
true,
15,
7,
],
[
false,
true,
false,
true,
10,
2,
],
[
true,
false,
true,
false,
5,
],
[
false,
false,
false,
false,
0,
],
];

View file

@ -55,15 +55,16 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
/**
* @covers ::onGetPreferences
* @dataProvider provideReferencePreviewsFlag
*/
public function testOnGetPreferencesNavPopupGadgetIsOn() {
public function testOnGetPreferencesNavPopupGadgetIsOn( bool $enabled ) {
$userMock = $this->createMock( User::class );
$contextMock = $this->createMock( PopupsContext::class );
$contextMock->expects( $this->once() )
->method( 'showPreviewsOptInOnPreferencesPage' )
->willReturn( true );
$contextMock->expects( $this->once() )
$contextMock->expects( $this->exactly( $enabled ? 2 : 1 ) )
->method( 'conflictsWithNavPopupsGadget' )
->with( $userMock )
->willReturn( true );
@ -71,6 +72,8 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
$this->setService( 'Popups.Context', $contextMock );
$prefs = [];
$this->setMwGlobals( 'wgPopupsReferencePreviews', $enabled );
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
( new PopupsHooks( $userOptionsManager ) )
->onGetPreferences( $userMock, $prefs );
@ -89,13 +92,14 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
/**
* @covers ::onGetPreferences
* @dataProvider provideReferencePreviewsFlag
*/
public function testOnGetPreferencesPreviewsEnabled() {
public function testOnGetPreferencesPreviewsEnabled( bool $enabled ) {
$contextMock = $this->createMock( PopupsContext::class );
$contextMock->expects( $this->once() )
->method( 'showPreviewsOptInOnPreferencesPage' )
->willReturn( true );
$contextMock->expects( $this->once() )
$contextMock->expects( $this->exactly( $enabled ? 2 : 1 ) )
->method( 'conflictsWithNavPopupsGadget' )
->willReturn( false );
@ -106,6 +110,8 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
'other' => 'notEmpty'
];
$this->setMwGlobals( 'wgPopupsReferencePreviews', $enabled );
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
( new PopupsHooks( $userOptionsManager ) )
->onGetPreferences( $this->createMock( User::class ), $prefs );
@ -124,13 +130,14 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
/**
* @covers ::onGetPreferences
* @dataProvider provideReferencePreviewsFlag
*/
public function testOnGetPreferencesPreviewsEnabledWhenSkinIsNotAvailable() {
public function testOnGetPreferencesPreviewsEnabledWhenSkinIsNotAvailable( bool $enabled ) {
$contextMock = $this->createMock( PopupsContext::class );
$contextMock->expects( $this->once() )
->method( 'showPreviewsOptInOnPreferencesPage' )
->willReturn( true );
$contextMock->expects( $this->once() )
$contextMock->expects( $this->exactly( $enabled ? 2 : 1 ) )
->method( 'conflictsWithNavPopupsGadget' )
->willReturn( false );
@ -140,6 +147,8 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
'other' => 'notEmpty'
];
$this->setMwGlobals( 'wgPopupsReferencePreviews', $enabled );
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
( new PopupsHooks( $userOptionsManager ) )
->onGetPreferences( $this->createMock( User::class ), $prefs );
@ -285,40 +294,39 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
/**
* @covers ::onUserGetDefaultOptions
* @dataProvider provideReferencePreviewsBetaFlag
* @dataProvider provideReferencePreviewsFlag
*/
public function testOnUserGetDefaultOptions( $beta ) {
public function testOnUserGetDefaultOptions( bool $enabled ) {
$userOptions = [
'test' => 'not_empty'
];
$this->setMwGlobals( [
'wgPopupsOptInDefaultState' => '1',
'wgPopupsReferencePreviews' => true,
'wgPopupsReferencePreviewsBetaFeature' => $beta,
'wgPopupsReferencePreviews' => $enabled,
] );
$userOptionsManager = $this->getServiceContainer()->getUserOptionsManager();
( new PopupsHooks( $userOptionsManager ) )
->onUserGetDefaultOptions( $userOptions );
$this->assertCount( 3 - $beta, $userOptions );
$this->assertCount( $enabled ? 3 : 2, $userOptions );
$this->assertSame( '1', $userOptions[ PopupsContext::PREVIEWS_OPTIN_PREFERENCE_NAME ] );
if ( $beta === false ) {
if ( $enabled ) {
$this->assertSame( '1', $userOptions[ PopupsContext::REFERENCE_PREVIEWS_PREFERENCE_NAME ] );
}
}
/**
* @covers ::onUserGetDefaultOptions
* @dataProvider provideReferencePreviewsBetaFlag
* @dataProvider provideReferencePreviewsFlag
*/
public function testOnLocalUserCreatedForNewlyCreatedUser( $beta ) {
public function testOnLocalUserCreatedForNewlyCreatedUser( bool $enabled ) {
$expectedState = '1';
$userMock = $this->createMock( User::class );
$userOptionsManagerMock = $this->createMock( UserOptionsManager::class );
$userOptionsManagerMock->expects( $this->exactly( 2 - $beta ) )
$userOptionsManagerMock->expects( $this->exactly( $enabled ? 2 : 1 ) )
->method( 'setOption' )
->withConsecutive(
[ $userMock, 'popups', $expectedState ],
@ -327,14 +335,13 @@ class PopupsHooksTest extends MediaWikiIntegrationTestCase {
$this->setMwGlobals( [
'wgPopupsOptInStateForNewAccounts' => $expectedState,
'wgPopupsReferencePreviews' => true,
'wgPopupsReferencePreviewsBetaFeature' => $beta,
'wgPopupsReferencePreviews' => $enabled,
] );
( new PopupsHooks( $userOptionsManagerMock ) )
->onLocalUserCreated( $userMock, false );
}
public static function provideReferencePreviewsBetaFlag() {
public static function provideReferencePreviewsFlag() {
return [
[ false ],
[ true ],

View file

@ -41,24 +41,6 @@ class PopupsPage extends Page {
await Util.waitForModuleState( POPUPS_MODULE_NAME );
}
async shouldUseReferencePopupsBetaFeature() {
await Util.waitForModuleState( 'mediawiki.base' );
await browser.execute( function () {
return mw.loader.using( 'mediawiki.api' ).then( function () {
return new mw.Api().saveOptions( {
// TODO: Remove the first option when all Beta code is gone
popupsreferencepreviews: '1',
'popups-reference-previews': '1'
} );
} );
} );
}
async hasReferencePopupsEnabled() {
// TODO Remove or adjust when not in Beta any more
return browser.execute( () => mw.config.get( 'wgPopupsReferencePreviews' ) );
}
async abandonLink() {
return $( '#content h1' ).moveTo();
}

View file

@ -1,15 +1,11 @@
'use strict';
const assert = require( 'assert' ),
page = require( '../pageobjects/popups.page' ),
UserLoginPage = require( 'wdio-mediawiki/LoginPage' );
page = require( '../pageobjects/popups.page' );
describe( 'Dwelling on a valid reference link', function () {
before( async function () {
await page.setupReferencePreviews();
// TODO Remove or adjust when not in Beta any more
await UserLoginPage.loginAdmin();
await page.shouldUseReferencePopupsBetaFeature();
} );
beforeEach( async function () {
@ -18,9 +14,6 @@ describe( 'Dwelling on a valid reference link', function () {
} );
it( 'I should see a reference preview', async function () {
if ( !( await page.hasReferencePopupsEnabled() ) ) {
this.skip();
}
await page.dwellReferenceLink( 'cite_ref-1' );
assert( await page.seeReferencePreview(), 'Reference preview is shown.' );
assert( !( await page.seeScrollableReferencePreview() ), 'Reference preview is not scrollable.' );
@ -28,9 +21,6 @@ describe( 'Dwelling on a valid reference link', function () {
} );
it( 'Abandoning link hides reference preview', async function () {
if ( !( await page.hasReferencePopupsEnabled() ) ) {
this.skip();
}
await page.dwellReferenceLink( 'cite_ref-1' );
await page.abandonLink();
assert( await page.doNotSeeReferencePreview(), 'Reference preview is kept hidden.' );
@ -38,18 +28,12 @@ describe( 'Dwelling on a valid reference link', function () {
// Skipped due to T341763
it.skip( 'References with lots of text are scrollable and fades', async function () {
if ( !( await page.hasReferencePopupsEnabled() ) ) {
this.skip();
}
await page.dwellReferenceLink( 'cite_ref-2' );
assert( await page.seeScrollableReferencePreview(), 'Reference preview is scrollable' );
assert( await page.seeFadeoutOnReferenceText(), 'Reference preview has a fading effect' );
} );
it.skip( 'Dwelling references links inside reference previews does not close the popup ', async function () {
if ( !( await page.hasReferencePopupsEnabled() ) ) {
this.skip();
}
await page.dwellReferenceLink( 'cite_ref-3' );
await page.dwellReferenceInceptionLink();
assert( await page.seeReferenceInceptionPreview(), 'The reference preview is still showing.' );

View file

@ -119,8 +119,8 @@ module.exports = ( env, argv ) => ( {
// Minified uncompressed size limits for chunks / assets and entrypoints. Keep these numbers
// up-to-date and rounded to the nearest 10th of a kibibyte so that code sizing costs are
// well understood. Related to bundlesize minified, gzipped compressed file size tests.
maxAssetSize: 47.1 * 1024,
maxEntrypointSize: 47.1 * 1024,
maxAssetSize: 46.8 * 1024,
maxEntrypointSize: 46.8 * 1024,
// The default filter excludes map files but we rename ours.
assetFilter: ( filename ) => !filename.endsWith( srcMapExt )