From b7dcd8ffa8b13abbd16f074c27b558129ad50d9e Mon Sep 17 00:00:00 2001 From: Jon Robson Date: Fri, 3 Nov 2023 11:45:59 -0700 Subject: [PATCH] Restore test and increase budget with debug information *. Current budget didn't take into account: ** RelatedArticles ** FlaggedRevisions ** VisualEditor * Vector legacy budget is set to Vector 2022 to ensure both skins have similar performance demands. * Adds workaround for T350514 Bug: T346813 Bug: T350338 Change-Id: I3377bec5e1c368d30e77e22e93b2e44bbfe883bd --- bundlesize.config.json | 6 +++--- tests/phpunit/structure/PerformanceBudgetTest.php | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bundlesize.config.json b/bundlesize.config.json index dd604a4e0..6ba8e408b 100644 --- a/bundlesize.config.json +++ b/bundlesize.config.json @@ -2,11 +2,11 @@ "total": { "vector-2022": { "scripts": "70.1KB", - "styles": "15KB" + "styles": "17.0KB" }, "vector": { - "scripts": "57.3KB", - "styles": "8.6KB" + "scripts": "70.1KB", + "styles": "17.0KB" } }, "modules": [ diff --git a/tests/phpunit/structure/PerformanceBudgetTest.php b/tests/phpunit/structure/PerformanceBudgetTest.php index 738a13a3c..79423b939 100644 --- a/tests/phpunit/structure/PerformanceBudgetTest.php +++ b/tests/phpunit/structure/PerformanceBudgetTest.php @@ -78,6 +78,11 @@ class PerformanceBudgetTest extends MediaWikiIntegrationTestCase { * @throws \SkinException */ protected function prepareSkin( string $skinName ): \Skin { + // FIXME: disable flagged revisions for purpose of this test by making + // sure the page is not "reviewable" until T350514 is resolved. + $this->overrideConfigValue( 'FlaggedRevsNamespaces', [] ); + // END FIXME + $skinFactory = MediaWikiServices::getInstance()->getSkinFactory(); $skin = $skinFactory->makeSkin( $skinName ); $title = $this->getExistingTestPage()->getTitle(); @@ -143,34 +148,36 @@ class PerformanceBudgetTest extends MediaWikiIntegrationTestCase { * @throws MediaWiki\Config\ConfigException */ public function testTotalModulesSize( $skinName, $maxSizes ) { - $this->markTestSkipped( 'T350338' ); - $skin = $this->prepareSkin( $skinName ); $moduleStyles = $skin->getOutput()->getModuleStyles(); $size = 0; foreach ( $moduleStyles as $moduleName ) { $size += $this->getContentTransferSize( $moduleName, $skinName ); } + $debugInformation = "The following modules are enabled on page load:\n" . + implode( "\n", $moduleStyles ); $stylesMaxSize = $this->getSizeInBytes( $maxSizes[ 'styles' ] ); $message = "T346813: Performance budget for style in skin" . " $skinName on main article namespace has been exceeded." . " Total size of style modules is $size bytes is greater" . " than the current budget size of $stylesMaxSize bytes" . " Please reduce styles that you are loading on page load" . - " or talk to the skin maintainer about modifying the budget."; + " or talk to the skin maintainer about modifying the budget. $debugInformation"; $this->assertLessThanOrEqual( $stylesMaxSize, $size, $message ); $modulesScripts = $skin->getOutput()->getModules(); $size = 0; foreach ( $modulesScripts as $moduleName ) { $size += $this->getContentTransferSize( $moduleName, $skinName ); } + $debugInformation = "The following modules are enabled on page load:\n" . + implode( "\n", $modulesScripts ); $scriptsMaxSize = $this->getSizeInBytes( $maxSizes[ 'scripts' ] ); $message = "T346813: Performance budget for scripts in skin" . " $skinName on main article namespace has been exceeded." . " Total size of script modules is $size bytes is greater" . " than the current budget size of $scriptsMaxSize bytes" . " Please reduce scripts that you are loading on page load" . - " or talk to the skin maintainer about modifying the budget."; + " or talk to the skin maintainer about modifying the budget. $debugInformation"; $this->assertLessThanOrEqual( $scriptsMaxSize, $size, $message ); } }